Skip to content

Commit 702642c

Browse files
authored
[SYCL] Fix OpenCL version check when verifying SPIR-V online compilation support (#2445)
Enumerate through historic OpenCL versions, like in the plugin.
1 parent cb3a5d7 commit 702642c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,20 @@ getOrBuild(KernelProgramCache &KPCache, KeyT &&CacheKey, AcquireFT &&Acquire,
218218
}
219219
}
220220

221+
// TODO replace this with a new PI API function
221222
static bool isDeviceBinaryTypeSupported(const context &C,
222223
RT::PiDeviceBinaryType Format) {
224+
// All formats except PI_DEVICE_BINARY_TYPE_SPIRV are supported.
225+
if (Format != PI_DEVICE_BINARY_TYPE_SPIRV)
226+
return true;
227+
223228
const backend ContextBackend =
224229
detail::getSyclObjImpl(C)->getPlugin().getBackend();
225230

226231
// The CUDA backend cannot use SPIR-V
227-
if (ContextBackend == backend::cuda && Format == PI_DEVICE_BINARY_TYPE_SPIRV)
232+
if (ContextBackend == backend::cuda)
228233
return false;
229234

230-
// All formats except PI_DEVICE_BINARY_TYPE_SPIRV are supported.
231-
if (Format != PI_DEVICE_BINARY_TYPE_SPIRV)
232-
return true;
233-
234235
vector_class<device> Devices = C.get_devices();
235236

236237
// Program type is SPIR-V, so we need a device compiler to do JIT.
@@ -240,9 +241,14 @@ static bool isDeviceBinaryTypeSupported(const context &C,
240241
}
241242

242243
// OpenCL 2.1 and greater require clCreateProgramWithIL
243-
if ((ContextBackend == backend::opencl) &&
244-
C.get_platform().get_info<info::platform::version>() >= "2.1")
245-
return true;
244+
if (ContextBackend == backend::opencl) {
245+
std::string ver = C.get_platform().get_info<info::platform::version>();
246+
if (ver.find("OpenCL 1.0") == std::string::npos &&
247+
ver.find("OpenCL 1.1") == std::string::npos &&
248+
ver.find("OpenCL 1.2") == std::string::npos &&
249+
ver.find("OpenCL 2.0") == std::string::npos)
250+
return true;
251+
}
246252

247253
for (const device &D : Devices) {
248254
// We need cl_khr_il_program extension to be present

0 commit comments

Comments
 (0)