Skip to content

Commit 61eba7c

Browse files
[UR][L0] Added support to retrieve maximum memory bandwidth (#18770)
urDeviceGetInfo is now able to retrieve the max memory bandwidth. --------- Signed-off-by: Zhang, Winston <[email protected]>
1 parent f4fca6e commit 61eba7c

File tree

1 file changed

+16
-0
lines changed
  • unified-runtime/source/adapters/level_zero

1 file changed

+16
-0
lines changed

unified-runtime/source/adapters/level_zero/device.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,22 @@ ur_result_t urDeviceGetInfo(
273273
const auto &UUID = Device->ZeDeviceProperties->uuid.id;
274274
return ReturnValue(UUID, sizeof(UUID));
275275
}
276+
case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: {
277+
// ZeDeviceMemoryProperties should be set already by initialization
278+
if (Device->ZeDeviceMemoryProperties->second.empty())
279+
return ReturnValue(uint64_t{0});
280+
281+
uint32_t maxBandwidth = 0;
282+
for (const auto &extProp : Device->ZeDeviceMemoryProperties->second) {
283+
// Only consider bandwidth if the unit is BYTES_PER_NANOSEC
284+
if (extProp.bandwidthUnit == ZE_BANDWIDTH_UNIT_BYTES_PER_NANOSEC) {
285+
maxBandwidth = std::max(
286+
{maxBandwidth, extProp.readBandwidth, extProp.writeBandwidth});
287+
}
288+
}
289+
// Convert to Bytes/sec from Bytes/nanosec
290+
return ReturnValue(static_cast<uint64_t>(maxBandwidth * 1e9));
291+
}
276292
case UR_DEVICE_INFO_ATOMIC_64:
277293
return ReturnValue(
278294
static_cast<ur_bool_t>(Device->ZeDeviceModuleProperties->flags &

0 commit comments

Comments
 (0)