Skip to content

Commit 284d7d2

Browse files
Andrew Savonichevromanovvlad
authored andcommitted
[SYCL] Change a check for a device compiler availability (#997)
Before this patch we checked for a device compiler in ProgramManager::build, but this function is called for AOT compiled programs as well as required by the OpenCL specification: clBuildProgram must be called for program created using either clCreateProgramWithSource or clCreateProgramWithBinary to build the program executable for one or more devices associated with program. Signed-off-by: Andrew Savonichev <[email protected]>
1 parent 24c5249 commit 284d7d2

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,23 +197,30 @@ static bool isDeviceBinaryTypeSupported(const context &C,
197197
if (Format != PI_DEVICE_BINARY_TYPE_SPIRV)
198198
return true;
199199

200+
vector_class<device> Devices = C.get_devices();
201+
202+
// Program type is SPIR-V, so we need a device compiler to do JIT.
203+
for (const device &D : Devices) {
204+
if (!D.get_info<info::device::is_compiler_available>())
205+
return false;
206+
}
207+
200208
// OpenCL 2.1 and greater require clCreateProgramWithIL
201209
if (pi::useBackend(pi::SYCL_BE_PI_OPENCL) &&
202210
C.get_platform().get_info<info::platform::version>() >= "2.1")
203211
return true;
204212

205-
// Otherwise we need cl_khr_il_program extension to be present
206-
// and we can call clCreateProgramWithILKHR using the extension
207-
for (const device &D : C.get_devices()) {
213+
for (const device &D : Devices) {
214+
// We need cl_khr_il_program extension to be present
215+
// and we can call clCreateProgramWithILKHR using the extension
208216
vector_class<string_class> Extensions =
209217
D.get_info<info::device::extensions>();
210-
if (std::find(Extensions.begin(), Extensions.end(),
211-
string_class("cl_khr_il_program")) != Extensions.end())
212-
return true;
218+
if (Extensions.end() ==
219+
std::find(Extensions.begin(), Extensions.end(), "cl_khr_il_program"))
220+
return false;
213221
}
214222

215-
// This device binary type is not supported.
216-
return false;
223+
return true;
217224
}
218225

219226
static const char *getFormatStr(RT::PiDeviceBinaryType Format) {
@@ -618,14 +625,6 @@ ProgramManager::build(ProgramPtr Program, RT::PiContext Context,
618625
}
619626
const char *Opts = std::getenv("SYCL_PROGRAM_BUILD_OPTIONS");
620627

621-
for (const auto &DeviceId : Devices) {
622-
if (!createSyclObjFromImpl<device>(std::make_shared<device_impl>(DeviceId))
623-
.get_info<info::device::is_compiler_available>()) {
624-
throw feature_not_supported(
625-
"Online compilation is not supported by this device");
626-
}
627-
}
628-
629628
if (!Opts)
630629
Opts = Options.c_str();
631630

0 commit comments

Comments
 (0)