Skip to content

Commit 4a41230

Browse files
authored
[SYCL] Implement native_specialization_constant() (#8613)
native_specialization_constant() returns true only in JIT mode on opencl & level-zero backends (because only SPIR-V supports them)
1 parent 7771b64 commit 4a41230

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

sycl/source/detail/device_image_impl.hpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,19 @@ class device_image_impl {
110110
}
111111

112112
bool all_specialization_constant_native() const noexcept {
113-
assert(false && "Not implemented");
114-
return false;
113+
// Specialization constants are natively supported in JIT mode on backends,
114+
// that are using SPIR-V as IR
115+
auto IsAOTBinary = [](const char *Format) {
116+
return (
117+
(strcmp(Format, __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_X86_64) ==
118+
0) ||
119+
(strcmp(Format, __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_GEN) == 0) ||
120+
(strcmp(Format, __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_FPGA) == 0));
121+
};
122+
123+
return !IsAOTBinary(MBinImage->getRawData().DeviceTargetSpec) &&
124+
(MContext.get_backend() == backend::opencl ||
125+
MContext.get_backend() == backend::ext_oneapi_level_zero);
115126
}
116127

117128
bool has_specialization_constant(const char *SpecName) const noexcept {

0 commit comments

Comments
 (0)