Skip to content

Commit 2179f0e

Browse files
committed
Extend getOpenCLDevice error message for better UX
Signed-off-by: Mokhov, Dmitri N <[email protected]>
1 parent a1f09f1 commit 2179f0e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

opencl-aot/source/utils.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,19 +236,26 @@ getOpenCLPlatform(DeviceType Type) {
236236
}
237237
}
238238

239-
if (!clFailed(CLErr)) {
239+
std::string SupportedPlatforms;
240+
for (const auto &Platform : DeviceTypesToSupportedPlatformNames[Type]) {
241+
SupportedPlatforms += " " + Platform + '\n';
242+
}
243+
if (clFailed(CLErr)) {
244+
std::map<DeviceType, std::string> DeviceTypeToDeviceTypeName{
245+
{cpu, "CPU"}, {gpu, "GPU"}, {fpga_fast_emu, "accelerator"}};
246+
ErrorMessage += "Failed to find OpenCL " +
247+
DeviceTypeToDeviceTypeName[Type] +
248+
" device in these OpenCL platforms:\n" + SupportedPlatforms;
249+
} else {
240250
if (PlatformId == nullptr) {
241251
ErrorMessage += "OpenCL platform ID is empty\n";
242252
}
243253
if (PlatformName.empty()) {
244254
ErrorMessage += "OpenCL platform name is empty\n";
245255
}
246256
if (!ErrorMessage.empty()) {
247-
ErrorMessage += "Failed to find any of these OpenCL platforms:\n";
248-
for (const auto &SupportedPlatformName :
249-
DeviceTypesToSupportedPlatformNames[Type]) {
250-
ErrorMessage += " " + SupportedPlatformName + '\n';
251-
}
257+
ErrorMessage += "Failed to find any of these OpenCL platforms:\n" +
258+
SupportedPlatforms;
252259
CLErr = OPENCL_AOT_PLATFORM_NOT_FOUND;
253260
}
254261
}

0 commit comments

Comments
 (0)