Skip to content

Commit

Permalink
Fix available memory reporting for Arc devices (#6825)
Browse files Browse the repository at this point in the history
current PI Level Zero implementation assumed device memory is only HBM
and hence returned 0 for Alchemist GPUs.
  • Loading branch information
ph0b authored Sep 21, 2022
1 parent 86e9dcb commit c191fb0
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3153,20 +3153,15 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
PI_SUCCESS);
return PI_ERROR_PLUGIN_SPECIFIC_ERROR;
}
// Only report device memory which zeMemAllocDevice can allocate from.
// Currently this is only the one enumerated with ordinal 0.
uint64_t FreeMemory = 0;
uint32_t MemCount = 0;
ZE_CALL(zesDeviceEnumMemoryModules, (ZeDevice, &MemCount, nullptr));
std::vector<zes_mem_handle_t> MemHandles(MemCount);
ZE_CALL(zesDeviceEnumMemoryModules,
(ZeDevice, &MemCount, MemHandles.data()));

for (auto &ZesMemHandle : MemHandles) {
uint32_t MemCount = 1;
zes_mem_handle_t ZesMemHandle;
ZE_CALL(zesDeviceEnumMemoryModules, (ZeDevice, &MemCount, &ZesMemHandle));
if (MemCount != 0) {
ZesStruct<zes_mem_properties_t> ZeMemProperties;
ZE_CALL(zesMemoryGetProperties, (ZesMemHandle, &ZeMemProperties));
// Only report HBM which zeMemAllocDevice allocates from.
if (ZeMemProperties.type != ZES_MEM_TYPE_HBM)
continue;

ZesStruct<zes_mem_state_t> ZeMemState;
ZE_CALL(zesMemoryGetState, (ZesMemHandle, &ZeMemState));
FreeMemory += ZeMemState.free;
Expand Down

0 comments on commit c191fb0

Please sign in to comment.