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

Commit ee6bb56

Browse files
committed
[SYCL] Adds test for selective building in implicit kernel bundles
In select cases the SYCL runtime may create an implicit kernel bundle to for example track specialization constants. These kernel bundles should only build the device image that contains the kernel being launched. This commit adds a test for checking that only one device image is built by an implicit kernel bundle when only a single kernel is launched and using per-kernel device-code splitting. Signed-off-by: Steffen Larsen <[email protected]>
1 parent 97c22be commit ee6bb56

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsycl-device-code-split=per_kernel %s -o %t.out
2+
// RUN: env SYCL_PI_TRACE=2 %CPU_RUN_PLACEHOLDER %t.out 2>&1 %CPU_CHECK_PLACEHOLDER
3+
// RUN: env SYCL_PI_TRACE=2 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER
4+
// RUN: env SYCL_PI_TRACE=2 %ACC_RUN_PLACEHOLDER %t.out 2>&1 %ACC_CHECK_PLACEHOLDER
5+
6+
// This tests checks that implicitly created kernel_bundles (i.e. through
7+
// setting a specialization ID from host) only builds the device image
8+
// containing the kernel it launches.
9+
10+
#include <CL/sycl.hpp>
11+
12+
#include <iostream>
13+
14+
class Kernel1;
15+
class Kernel2;
16+
17+
constexpr sycl::specialization_id<int> SpecConst;
18+
19+
int main() {
20+
sycl::queue Q;
21+
22+
int Ret = 0;
23+
{
24+
sycl::buffer<int, 1> Buf(&Ret, 1);
25+
Q.submit([&](sycl::handler &CGH) {
26+
auto Acc = Buf.template get_access<sycl::access::mode::write>(CGH);
27+
CGH.set_specialization_constant<SpecConst>(42);
28+
CGH.single_task<class Kernel1>([=](sycl::kernel_handler H) {
29+
Acc[0] = H.get_specialization_constant<SpecConst>();
30+
});
31+
});
32+
Q.wait_and_throw();
33+
}
34+
35+
if (Ret == 1) {
36+
// This should never happen but we need the kernel
37+
Q.submit([&](sycl::handler &CGH) {
38+
CGH.single_task<class Kernel2>([=]() { });
39+
});
40+
Q.wait_and_throw();
41+
}
42+
std::cout << "passed" << std::endl;
43+
return 0;
44+
}
45+
46+
// --- Check that only a single program is built:
47+
// CHECK: ---> piProgramBuild
48+
// CHECK-NOT: ---> piProgramBuild
49+
// --- Check that the test completed with expected results:
50+
// CHECK: passed

0 commit comments

Comments
 (0)