Skip to content

Commit 273ca1f

Browse files
authored
[Offload] Fix OL_DEVICE_INFO_MAX_MEM_ALLOC_SIZE on AMD (#154521)
This wasn't handled with the normal info API, so needs special handling.
1 parent a969239 commit 273ca1f

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
@@ -340,8 +340,15 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
340340
// None of the existing plugins specify a limit on a single allocation,
341341
// so return the global memory size instead
342342
case OL_DEVICE_INFO_MAX_MEM_ALLOC_SIZE:
343-
PropName = OL_DEVICE_INFO_GLOBAL_MEM_SIZE;
344-
break;
343+
[[fallthrough]];
344+
// AMD doesn't provide the global memory size (trivially) with the device info
345+
// struct, so use the plugin interface
346+
case OL_DEVICE_INFO_GLOBAL_MEM_SIZE: {
347+
uint64_t Mem;
348+
if (auto Err = Device->Device->getDeviceMemorySize(Mem))
349+
return Err;
350+
return Info.write<uint64_t>(Mem);
351+
} break;
345352

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

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

0 commit comments

Comments
 (0)