|
| 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