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

[SYCL] Test native_specialization_constant() #1651

Open
wants to merge 2 commits into
base: intel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions SYCL/SpecConstants/2020/native_specialization_constants.cpp
Original file line number Diff line number Diff line change
@@ -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 <sycl/sycl.hpp>

int main() {
sycl::queue Q;
Q.submit([&](sycl::handler &h) { h.single_task<>([]() {}); });

#ifdef JIT
auto bundle =
sycl::get_kernel_bundle<sycl::bundle_state::input>(Q.get_context());
assert(bundle.native_specialization_constant());
#else
auto bundle =
sycl::get_kernel_bundle<sycl::bundle_state::executable>(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;
}