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

Commit fcbb20a

Browse files
[SYCL] Adds test for selective building in implicit kernel bundles (#726)
* 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. * Disable on CUDA and HIP Signed-off-by: Steffen Larsen <[email protected]>
1 parent 5ed4bac commit fcbb20a

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
// JIT compilation path is not taken on CUDA and HIP backend.
7+
// UNSUPPORTED: cuda || hip
8+
9+
// This tests checks that implicitly created kernel_bundles (i.e. through
10+
// setting a specialization ID from host) only builds the device image
11+
// containing the kernel it launches.
12+
13+
#include <CL/sycl.hpp>
14+
15+
#include <iostream>
16+
17+
class Kernel1;
18+
class Kernel2;
19+
20+
constexpr sycl::specialization_id<int> SpecConst;
21+
22+
int main() {
23+
sycl::queue Q;
24+
25+
int Ret = 0;
26+
{
27+
sycl::buffer<int, 1> Buf(&Ret, 1);
28+
Q.submit([&](sycl::handler &CGH) {
29+
auto Acc = Buf.template get_access<sycl::access::mode::write>(CGH);
30+
CGH.set_specialization_constant<SpecConst>(42);
31+
CGH.single_task<class Kernel1>([=](sycl::kernel_handler H) {
32+
Acc[0] = H.get_specialization_constant<SpecConst>();
33+
});
34+
});
35+
Q.wait_and_throw();
36+
}
37+
38+
if (Ret == 1) {
39+
// This should never happen but we need the kernel
40+
Q.submit(
41+
[&](sycl::handler &CGH) { CGH.single_task<class Kernel2>([=]() {}); });
42+
Q.wait_and_throw();
43+
}
44+
std::cout << "passed" << std::endl;
45+
return 0;
46+
}
47+
48+
// --- Check that only a single program is built:
49+
// CHECK: ---> piProgramBuild
50+
// CHECK-NOT: ---> piProgramBuild
51+
// --- Check that the test completed with expected results:
52+
// CHECK: passed

0 commit comments

Comments
 (0)