13
13
14
14
#include " OffloadImpl.hpp"
15
15
#include " Helpers.hpp"
16
+ // Required for operator<< implementation of ol_device_info_t
17
+ #include " OffloadPrint.hpp"
16
18
#include " PluginManager.h"
17
19
#include " llvm/Support/FormatVariadic.h"
18
20
#include < OffloadAPI.h>
@@ -264,13 +266,16 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
264
266
265
267
return " " ;
266
268
};
267
- auto GetInfoXyz = [&](std::vector<std::string> Names) {
268
- if (!Device->Device )
269
- return ol_dimensions_t {0 , 0 , 0 };
269
+ auto GetInfoXyz = [&](std::vector<std::string> Names) -> Error {
270
+ if (Device == OffloadContext::get ().HostDevice ())
271
+ return ReturnValue (ol_dimensions_t {0u , 0u , 0u });
272
+
273
+ assert (Device->Device &&
274
+ " liboffload device handle contains a null plugin device" );
270
275
271
276
auto Info = Device->Device ->obtainInfoImpl ();
272
277
if (auto Err = Info.takeError ())
273
- return ol_dimensions_t { 0 , 0 , 0 } ;
278
+ return Err ;
274
279
275
280
for (auto Name : Names) {
276
281
if (auto Entry = Info->get (Name)) {
@@ -283,11 +288,14 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
283
288
Out.y = std::get<size_t >((*Y)->Value );
284
289
if (auto Z = Node->get (" z" ))
285
290
Out.z = std::get<size_t >((*Z)->Value );
286
- return Out;
291
+ return ReturnValue ( Out) ;
287
292
}
288
293
}
289
294
290
- return ol_dimensions_t {0 , 0 , 0 };
295
+ std::string ErrBuffer;
296
+ llvm::raw_string_ostream (ErrBuffer)
297
+ << " plugin did not provide information for " << PropName;
298
+ return Plugin::error (ErrorCode::UNIMPLEMENTED, ErrBuffer.c_str ());
291
299
};
292
300
293
301
switch (PropName) {
@@ -305,8 +313,8 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
305
313
return ReturnValue (
306
314
GetInfoString ({" CUDA Driver Version" , " HSA Runtime Version" }));
307
315
case OL_DEVICE_INFO_MAX_WORK_GROUP_SIZE:
308
- return ReturnValue ( GetInfoXyz ({" Workgroup Max Size per Dimension" /* AMD*/ ,
309
- " Maximum Block Dimensions" /* CUDA*/ }) );
316
+ return GetInfoXyz ({" Workgroup Max Size per Dimension" /* AMD*/ ,
317
+ " Maximum Block Dimensions" /* CUDA*/ });
310
318
default :
311
319
return createOffloadError (ErrorCode::INVALID_ENUMERATION,
312
320
" getDeviceInfo enum '%i' is invalid" , PropName);
0 commit comments