From 2fea679d7e244482ab6f609cfaf205d8f324ea46 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 10 Sep 2024 17:35:27 +0100 Subject: [PATCH] Add workaround for silently supported OpenCL extensions on Intel FPGA --- source/adapters/opencl/device.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/adapters/opencl/device.cpp b/source/adapters/opencl/device.cpp index 071a3a7c5a..36d08548c3 100644 --- a/source/adapters/opencl/device.cpp +++ b/source/adapters/opencl/device.cpp @@ -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 &Exts, bool &Supported) { size_t ExtSize = 0; @@ -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; } }