From e7689edab48db0f2c8feffb70c266fe027d84b32 Mon Sep 17 00:00:00 2001 From: KornevNikita Date: Thu, 20 Apr 2023 03:29:16 -0700 Subject: [PATCH 1/2] [SYCL] Add e2e test for native_specialization_constant() This test was missed during e2e tests migration: https://github.com/intel/llvm-test-suite/pull/1651 --- .../2020/native_specialization_constant.cpp | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sycl/test-e2e/SpecConstants/2020/native_specialization_constant.cpp diff --git a/sycl/test-e2e/SpecConstants/2020/native_specialization_constant.cpp b/sycl/test-e2e/SpecConstants/2020/native_specialization_constant.cpp new file mode 100644 index 0000000000000..b039db848251e --- /dev/null +++ b/sycl/test-e2e/SpecConstants/2020/native_specialization_constant.cpp @@ -0,0 +1,38 @@ +// native_specialization_constant() returns true only in JIT mode +// on opencl & level-zero backends +// (because only SPIR-V supports specialization constants natively) + +// REQUIRES: opencl, level-zero, cpu, gpu, opencl-aot, ocloc + +// RUN: %clangxx -DJIT -fsycl %s -o %t.out +// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:cpu %t.out +// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:gpu %t.out +// RUN: env ONEAPI_DEVICE_SELECTOR=level_zero:gpu %t.out + +// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64,spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %s -o %t.out +// RUN: %CPU_RUN_PLACEHOLDER %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out + +#include + +constexpr sycl::specialization_id float_id(3.14f); + +int main() { + sycl::queue Q; + Q.submit([&](sycl::handler &cgh) { + cgh.single_task([=](sycl::kernel_handler h) { + h.get_specialization_constant(); + }); + +#ifdef JIT + auto bundle = + sycl::get_kernel_bundle(Q.get_context()); + assert(bundle.native_specialization_constant()); +#else + auto bundle = + sycl::get_kernel_bundle(Q.get_context()); + assert(!bundle.native_specialization_constant()); +#endif // JIT + + return 0; +} From fb8a704a16d309f1f6ceaa1eb0dfba07d021e964 Mon Sep 17 00:00:00 2001 From: KornevNikita Date: Thu, 20 Apr 2023 03:31:53 -0700 Subject: [PATCH 2/2] Format --- .../SpecConstants/2020/native_specialization_constant.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sycl/test-e2e/SpecConstants/2020/native_specialization_constant.cpp b/sycl/test-e2e/SpecConstants/2020/native_specialization_constant.cpp index b039db848251e..cabef749c305f 100644 --- a/sycl/test-e2e/SpecConstants/2020/native_specialization_constant.cpp +++ b/sycl/test-e2e/SpecConstants/2020/native_specialization_constant.cpp @@ -20,8 +20,9 @@ constexpr sycl::specialization_id float_id(3.14f); int main() { sycl::queue Q; Q.submit([&](sycl::handler &cgh) { - cgh.single_task([=](sycl::kernel_handler h) { - h.get_specialization_constant(); + cgh.single_task([=](sycl::kernel_handler h) { + h.get_specialization_constant(); + }); }); #ifdef JIT