Skip to content
Merged
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
22 changes: 14 additions & 8 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,20 @@ getOrBuild(KernelProgramCache &KPCache, KeyT &&CacheKey, AcquireFT &&Acquire,
}
}

// TODO replace this with a new PI API function
static bool isDeviceBinaryTypeSupported(const context &C,
RT::PiDeviceBinaryType Format) {
// All formats except PI_DEVICE_BINARY_TYPE_SPIRV are supported.
if (Format != PI_DEVICE_BINARY_TYPE_SPIRV)
return true;

const backend ContextBackend =
detail::getSyclObjImpl(C)->getPlugin().getBackend();

// The CUDA backend cannot use SPIR-V
if (ContextBackend == backend::cuda && Format == PI_DEVICE_BINARY_TYPE_SPIRV)
if (ContextBackend == backend::cuda)
return false;

// All formats except PI_DEVICE_BINARY_TYPE_SPIRV are supported.
if (Format != PI_DEVICE_BINARY_TYPE_SPIRV)
return true;

vector_class<device> Devices = C.get_devices();

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

// OpenCL 2.1 and greater require clCreateProgramWithIL
if ((ContextBackend == backend::opencl) &&
C.get_platform().get_info<info::platform::version>() >= "2.1")
return true;
if (ContextBackend == backend::opencl) {
std::string ver = C.get_platform().get_info<info::platform::version>();
if (ver.find("OpenCL 1.0") == std::string::npos &&
ver.find("OpenCL 1.1") == std::string::npos &&
ver.find("OpenCL 1.2") == std::string::npos &&
ver.find("OpenCL 2.0") == std::string::npos)
return true;
}

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