From ec83f1fc33f34fd1392ebcc0ff824aec2c65aa88 Mon Sep 17 00:00:00 2001 From: KornevNikita Date: Fri, 10 Mar 2023 07:22:39 -0800 Subject: [PATCH 1/2] [SYCL] Test native_specialization_constant() --- .../2020/native_specialization_constants.cpp | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 SYCL/SpecConstants/2020/native_specialization_constants.cpp diff --git a/SYCL/SpecConstants/2020/native_specialization_constants.cpp b/SYCL/SpecConstants/2020/native_specialization_constants.cpp new file mode 100644 index 0000000000..1d2448345f --- /dev/null +++ b/SYCL/SpecConstants/2020/native_specialization_constants.cpp @@ -0,0 +1,33 @@ +// native_specialization_constant() returns true only in JIT mode +// on opencl & level-zero backends (because only SPIR-V supports them) + +// 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=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 + +int main() { + sycl::queue Q; + Q.submit([&](sycl::handler &h) { + h.single_task<>([]() {}); + }); + + #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()); + // This assert will fail in JIT mode, because there are no images in + // executable state, so native_specialization_constant() will return true + assert(!bundle.native_specialization_constant()); + #endif // JIT + + return 0; +} From 722c7b843e6d74b342eec943b174aa583a7d0bfb Mon Sep 17 00:00:00 2001 From: KornevNikita Date: Mon, 13 Mar 2023 10:35:12 -0700 Subject: [PATCH 2/2] Format --- .../2020/native_specialization_constants.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/SYCL/SpecConstants/2020/native_specialization_constants.cpp b/SYCL/SpecConstants/2020/native_specialization_constants.cpp index 1d2448345f..7360149aa2 100644 --- a/SYCL/SpecConstants/2020/native_specialization_constants.cpp +++ b/SYCL/SpecConstants/2020/native_specialization_constants.cpp @@ -15,19 +15,19 @@ int main() { sycl::queue Q; - Q.submit([&](sycl::handler &h) { - h.single_task<>([]() {}); - }); + Q.submit([&](sycl::handler &h) { h.single_task<>([]() {}); }); - #ifdef JIT - auto bundle = sycl::get_kernel_bundle(Q.get_context()); +#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()); +#else + auto bundle = + sycl::get_kernel_bundle(Q.get_context()); // This assert will fail in JIT mode, because there are no images in // executable state, so native_specialization_constant() will return true assert(!bundle.native_specialization_constant()); - #endif // JIT +#endif // JIT return 0; }