Skip to content

Commit

Permalink
Merge pull request #2078 from callumfare/callum/fix_device_extensions…
Browse files Browse the repository at this point in the history
…_fpga

Add workaround for silently supported OpenCL extensions on Intel FPGA
  • Loading branch information
omarahmed1111 authored Sep 11, 2024
2 parents eb63d1a + 2fea679 commit 24a8299
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions source/adapters/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ ur_result_t cl_adapter::getDeviceVersion(cl_device_id Dev,
return UR_RESULT_SUCCESS;
}

static bool isIntelFPGAEmuDevice(cl_device_id Dev) {
size_t NameSize = 0;
CL_RETURN_ON_FAILURE(
clGetDeviceInfo(Dev, CL_DEVICE_NAME, 0, nullptr, &NameSize));
std::string NameStr(NameSize, '\0');
CL_RETURN_ON_FAILURE(
clGetDeviceInfo(Dev, CL_DEVICE_NAME, NameSize, NameStr.data(), nullptr));

return NameStr.find("Intel(R) FPGA Emulation Device") != std::string::npos;
}

ur_result_t cl_adapter::checkDeviceExtensions(
cl_device_id Dev, const std::vector<std::string> &Exts, bool &Supported) {
size_t ExtSize = 0;
Expand All @@ -46,6 +57,14 @@ ur_result_t cl_adapter::checkDeviceExtensions(
Supported = true;
for (const std::string &Ext : Exts) {
if (!(Supported = (ExtStr.find(Ext) != std::string::npos))) {
// The Intel FPGA emulation device does actually support these, even if it
// doesn't report them.
if (isIntelFPGAEmuDevice(Dev) &&
(Ext == "cl_intel_device_attribute_query" ||
Ext == "cl_intel_required_subgroup_size")) {
Supported = true;
continue;
}
break;
}
}
Expand Down

0 comments on commit 24a8299

Please sign in to comment.