Skip to content

Commit 0568928

Browse files
authored
[SYCL] Add e2e test for native_specialization_constant() (#9134)
This test was missed during e2e tests migration: intel/llvm-test-suite#1651
1 parent 7f38c67 commit 0568928

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// native_specialization_constant() returns true only in JIT mode
2+
// on opencl & level-zero backends
3+
// (because only SPIR-V supports specialization constants natively)
4+
5+
// REQUIRES: opencl, level-zero, cpu, gpu, opencl-aot, ocloc
6+
7+
// RUN: %clangxx -DJIT -fsycl %s -o %t.out
8+
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:cpu %t.out
9+
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:gpu %t.out
10+
// RUN: env ONEAPI_DEVICE_SELECTOR=level_zero:gpu %t.out
11+
12+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64,spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %s -o %t.out
13+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
14+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
15+
16+
#include <sycl/sycl.hpp>
17+
18+
constexpr sycl::specialization_id<float> float_id(3.14f);
19+
20+
int main() {
21+
sycl::queue Q;
22+
Q.submit([&](sycl::handler &cgh) {
23+
cgh.single_task<class Kernel>([=](sycl::kernel_handler h) {
24+
h.get_specialization_constant<float_id>();
25+
});
26+
});
27+
28+
#ifdef JIT
29+
auto bundle =
30+
sycl::get_kernel_bundle<sycl::bundle_state::input>(Q.get_context());
31+
assert(bundle.native_specialization_constant());
32+
#else
33+
auto bundle =
34+
sycl::get_kernel_bundle<sycl::bundle_state::executable>(Q.get_context());
35+
assert(!bundle.native_specialization_constant());
36+
#endif // JIT
37+
38+
return 0;
39+
}

0 commit comments

Comments
 (0)