@@ -195,6 +195,7 @@ getOpenCLPlatform(DeviceType Type) {
195
195
formatCLError (" Failed to retrieve OpenCL platform IDs" , CLErr), CLErr);
196
196
}
197
197
198
+ std::string ErrorMessage;
198
199
for (const auto &Platform : Platforms) {
199
200
size_t PlatformNameLength = 0 ;
200
201
CLErr = clGetPlatformInfo (Platform, CL_PLATFORM_NAME, 0 , nullptr ,
@@ -225,28 +226,31 @@ getOpenCLPlatform(DeviceType Type) {
225
226
auto Result =
226
227
std::find (SupportedPlatformNames.begin (), SupportedPlatformNames.end (),
227
228
PlatformNameOnLoopIteration);
228
- if (Result != SupportedPlatformNames.end () && // name match
229
- !clFailed (std::get<2 >(getOpenCLDevice (Platform, Type)))) { // type match
230
- PlatformId = Platform;
231
- PlatformName = PlatformNameOnLoopIteration;
232
- break ;
229
+ if (Result != SupportedPlatformNames.end ()) {
230
+ tie (std::ignore, ErrorMessage, CLErr) = getOpenCLDevice (Platform, Type);
231
+ if (!clFailed (CLErr)) {
232
+ PlatformId = Platform;
233
+ PlatformName = PlatformNameOnLoopIteration;
234
+ break ;
235
+ }
233
236
}
234
237
}
235
238
236
- std::string ErrorMessage;
237
- if (PlatformId == nullptr ) {
238
- ErrorMessage += " OpenCL platform ID is empty\n " ;
239
- }
240
- if (PlatformName.empty ()) {
241
- ErrorMessage += " OpenCL platform name is empty\n " ;
242
- }
243
- if (!ErrorMessage.empty ()) {
244
- ErrorMessage += " Failed to find any of these OpenCL platforms:\n " ;
245
- for (const auto &SupportedPlatformName :
246
- DeviceTypesToSupportedPlatformNames[Type]) {
247
- ErrorMessage += " " + SupportedPlatformName + ' \n ' ;
239
+ if (!clFailed (CLErr)) {
240
+ if (PlatformId == nullptr ) {
241
+ ErrorMessage += " OpenCL platform ID is empty\n " ;
242
+ }
243
+ if (PlatformName.empty ()) {
244
+ ErrorMessage += " OpenCL platform name is empty\n " ;
245
+ }
246
+ 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
+ }
252
+ CLErr = OPENCL_AOT_PLATFORM_NOT_FOUND;
248
253
}
249
- CLErr = OPENCL_AOT_PLATFORM_NOT_FOUND;
250
254
}
251
255
252
256
return std::make_tuple (PlatformId, PlatformName, ErrorMessage, CLErr);
0 commit comments