1
+ // UNSUPPORTED: cuda
2
+
3
+ // RUN: %clangxx -fsycl -fno-sycl-early-optimizations -fsycl-device-code-split=per_kernel %s -o %t_per_kernel.out
4
+ // RUN: %clangxx -fsycl -fno-sycl-early-optimizations -fsycl-device-code-split=per_source %s -o %t_per_source.out
5
+ // RUN: %clangxx -fsycl -fno-sycl-early-optimizations -fsycl-device-code-split=off %s -o %t_off.out
6
+ // RUN: %clangxx -fsycl -fno-sycl-early-optimizations -fsycl-device-code-split=auto %s -o %t_auto.out
7
+ // RUN: %GPU_RUN_PLACEHOLDER %t_per_kernel.out %GPU_CHECK_PLACEHOLDER
8
+ // RUN: %CPU_RUN_PLACEHOLDER %t_per_kernel.out %CPU_CHECK_PLACEHOLDER
9
+ // RUN: %ACC_RUN_PLACEHOLDER %t_per_kernel.out %ACC_CHECK_PLACEHOLDER
10
+
11
+ // RUN: %GPU_RUN_PLACEHOLDER %t_per_source.out %GPU_CHECK_PLACEHOLDER
12
+ // RUN: %CPU_RUN_PLACEHOLDER %t_per_source.out %CPU_CHECK_PLACEHOLDER
13
+ // RUN: %ACC_RUN_PLACEHOLDER %t_per_source.out %ACC_CHECK_PLACEHOLDER
14
+
15
+ // RUN: %GPU_RUN_PLACEHOLDER %t_auto.out %GPU_CHECK_PLACEHOLDER
16
+ // RUN: %CPU_RUN_PLACEHOLDER %t_auto.out %CPU_CHECK_PLACEHOLDER
17
+ // RUN: %ACC_RUN_PLACEHOLDER %t_auto.out %ACC_CHECK_PLACEHOLDER
18
+
19
+ // RUN: %GPU_RUN_PLACEHOLDER %t_off.out %GPU_CHECK_PLACEHOLDER
20
+ // RUN: %CPU_RUN_PLACEHOLDER %t_off.out %CPU_CHECK_PLACEHOLDER
21
+ // RUN: %ACC_RUN_PLACEHOLDER %t_off.out %ACC_CHECK_PLACEHOLDER
22
+
23
+ #include < CL/sycl.hpp>
24
+
25
+ using namespace sycl ;
26
+
27
+ // This function is used by two different kernels.
28
+ // We want to ensure that it does not lead so multiple symbol collision
29
+ // when building an executable via sycl::compile and sycl::link.
30
+ int foo (int a) { return a + 1 ; }
31
+
32
+ template <int ID> class kernel_name {};
33
+
34
+ int main () {
35
+ try {
36
+ queue q;
37
+ auto input = get_kernel_bundle<bundle_state::input>(
38
+ q.get_context (), {q.get_device ()},
39
+ {get_kernel_id<kernel_name<0 >>(), get_kernel_id<kernel_name<1 >>()});
40
+
41
+ auto compiled = sycl::compile (input);
42
+ kernel_bundle<bundle_state::executable> linked = sycl::link (compiled);
43
+
44
+ buffer<int > b (range{1 });
45
+ q.submit ([&](handler &cgh) {
46
+ cgh.use_kernel_bundle (linked);
47
+ auto acc = b.get_access <access_mode::read_write>(cgh);
48
+ cgh.single_task <kernel_name<0 >>([=]() { acc[0 ] = foo (acc[0 ]); });
49
+ });
50
+
51
+ q.submit ([&](handler &cgh) {
52
+ auto acc = b.get_access <access_mode::read_write>(cgh);
53
+ cgh.single_task <kernel_name<1 >>([=]() { acc[0 ] = foo (acc[0 ]); });
54
+ });
55
+ } catch (exception &e) {
56
+ std::cout << " Exception: " << e.what () << std::endl;
57
+ return 1 ;
58
+ }
59
+
60
+ std::cout << " OK" ;
61
+ return 0 ;
62
+ }
63
+
64
+ // CHECK: OK
0 commit comments