Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 35272a4

Browse files
[SYCL] Adds regression test for ensuring SYCL_EXTERNAL is ignored by kernel bundles (#486)
These changes add a regression test to ensure that exported device functions do not appear as kernels in kernel bundles. Signed-off-by: Steffen Larsen <steffen.larsen@intel.com>
1 parent 249d196 commit 35272a4

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
3+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
4+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
5+
//
6+
// XFAIL: cuda || hip
7+
8+
#include <CL/sycl.hpp>
9+
10+
class KernelName;
11+
12+
SYCL_EXTERNAL
13+
int f(int a) { return a + 1; }
14+
15+
int main() {
16+
const sycl::device Dev{sycl::default_selector{}};
17+
const sycl::context Ctx{Dev};
18+
sycl::queue Q{Ctx, Dev};
19+
20+
assert(sycl::get_kernel_ids().size() == 1);
21+
22+
sycl::kernel_bundle EmptyKernelBundle =
23+
sycl::get_kernel_bundle<sycl::bundle_state::executable>(Ctx, {Dev}, {});
24+
25+
assert(EmptyKernelBundle.get_kernel_ids().size() == 0);
26+
27+
sycl::kernel_bundle KernelBundle =
28+
sycl::get_kernel_bundle<sycl::bundle_state::executable>(Ctx, {Dev});
29+
sycl::kernel_id KernelID = sycl::get_kernel_id<KernelName>();
30+
31+
assert(KernelBundle.get_kernel_ids().size() == 1);
32+
assert(KernelBundle.has_kernel(KernelID));
33+
34+
cl::sycl::buffer<int, 1> Buf(sycl::range<1>{1});
35+
Q.submit([&](sycl::handler &CGH) {
36+
auto Acc = Buf.get_access<sycl::access::mode::write>(CGH);
37+
CGH.use_kernel_bundle(KernelBundle);
38+
CGH.single_task<KernelName>([=]() { Acc[0] = 42; });
39+
});
40+
}

0 commit comments

Comments
 (0)