From 4c534a7b46a766539a9b2793f95a69d527bb41f2 Mon Sep 17 00:00:00 2001 From: KornevNikita Date: Thu, 9 Mar 2023 07:22:32 -0800 Subject: [PATCH] [SYCL] Implement native_specialization_constant() native_specialization_constant() returns true only in JIT mode on opencl & level-zero backends (because only SPIR-V supports them) --- sycl/source/detail/device_image_impl.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sycl/source/detail/device_image_impl.hpp b/sycl/source/detail/device_image_impl.hpp index f04fea1b8c774..b67a2b63137f1 100644 --- a/sycl/source/detail/device_image_impl.hpp +++ b/sycl/source/detail/device_image_impl.hpp @@ -110,8 +110,19 @@ class device_image_impl { } bool all_specialization_constant_native() const noexcept { - assert(false && "Not implemented"); - return false; + // Specialization constants are natively supported in JIT mode on backends, + // that are using SPIR-V as IR + auto IsAOTBinary = [](const char *Format) { + return ( + (strcmp(Format, __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_X86_64) == + 0) || + (strcmp(Format, __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_GEN) == 0) || + (strcmp(Format, __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_FPGA) == 0)); + }; + + return !IsAOTBinary(MBinImage->getRawData().DeviceTargetSpec) && + (MContext.get_backend() == backend::opencl || + MContext.get_backend() == backend::ext_oneapi_level_zero); } bool has_specialization_constant(const char *SpecName) const noexcept {