Skip to content

Commit 1c669b3

Browse files
committed
[Offload] Fix OL_DEVICE_INFO_MAX_MEM_ALLOC_SIZE on AMD
This wasn't handled with the normal info API, so needs special handling.
1 parent af5f16b commit 1c669b3

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

offload/liboffload/src/OffloadImpl.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,15 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
339339
// None of the existing plugins specify a limit on a single allocation,
340340
// so return the global memory size instead
341341
case OL_DEVICE_INFO_MAX_MEM_ALLOC_SIZE:
342-
PropName = OL_DEVICE_INFO_GLOBAL_MEM_SIZE;
343-
break;
342+
[[fallthrough]];
343+
// AMD doesn't provide the global memory size (trivially) with the device info
344+
// struct, so use the plugin interface
345+
case OL_DEVICE_INFO_GLOBAL_MEM_SIZE: {
346+
uint64_t Mem;
347+
if (auto Err = Device->Device->getDeviceMemorySize(Mem))
348+
return Err;
349+
return Info.write<uint64_t>(Mem);
350+
} break;
344351

345352
default:
346353
break;
@@ -368,14 +375,6 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
368375
return Info.writeString(std::get<std::string>(Entry->Value).c_str());
369376
}
370377

371-
case OL_DEVICE_INFO_GLOBAL_MEM_SIZE: {
372-
// Uint64 values
373-
if (!std::holds_alternative<uint64_t>(Entry->Value))
374-
return makeError(ErrorCode::BACKEND_FAILURE,
375-
"plugin returned incorrect type");
376-
return Info.write(std::get<uint64_t>(Entry->Value));
377-
}
378-
379378
case OL_DEVICE_INFO_MAX_WORK_GROUP_SIZE:
380379
case OL_DEVICE_INFO_VENDOR_ID:
381380
case OL_DEVICE_INFO_NUM_COMPUTE_UNITS:

0 commit comments

Comments
 (0)