Skip to content

Commit 24a8299

Browse files
Merge pull request #2078 from callumfare/callum/fix_device_extensions_fpga
Add workaround for silently supported OpenCL extensions on Intel FPGA
2 parents eb63d1a + 2fea679 commit 24a8299

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

source/adapters/opencl/device.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ ur_result_t cl_adapter::getDeviceVersion(cl_device_id Dev,
3232
return UR_RESULT_SUCCESS;
3333
}
3434

35+
static bool isIntelFPGAEmuDevice(cl_device_id Dev) {
36+
size_t NameSize = 0;
37+
CL_RETURN_ON_FAILURE(
38+
clGetDeviceInfo(Dev, CL_DEVICE_NAME, 0, nullptr, &NameSize));
39+
std::string NameStr(NameSize, '\0');
40+
CL_RETURN_ON_FAILURE(
41+
clGetDeviceInfo(Dev, CL_DEVICE_NAME, NameSize, NameStr.data(), nullptr));
42+
43+
return NameStr.find("Intel(R) FPGA Emulation Device") != std::string::npos;
44+
}
45+
3546
ur_result_t cl_adapter::checkDeviceExtensions(
3647
cl_device_id Dev, const std::vector<std::string> &Exts, bool &Supported) {
3748
size_t ExtSize = 0;
@@ -46,6 +57,14 @@ ur_result_t cl_adapter::checkDeviceExtensions(
4657
Supported = true;
4758
for (const std::string &Ext : Exts) {
4859
if (!(Supported = (ExtStr.find(Ext) != std::string::npos))) {
60+
// The Intel FPGA emulation device does actually support these, even if it
61+
// doesn't report them.
62+
if (isIntelFPGAEmuDevice(Dev) &&
63+
(Ext == "cl_intel_device_attribute_query" ||
64+
Ext == "cl_intel_required_subgroup_size")) {
65+
Supported = true;
66+
continue;
67+
}
4968
break;
5069
}
5170
}

0 commit comments

Comments
 (0)