Skip to content

Commit d081c32

Browse files
committed
levelzero/xelink: accumulate subdevice link bandwidths in parents
Fix f207b0f moved root BWs to subdevices, which means there's nothing in root anymore whenever there are subdevices. Accumulate in parents so that parent BWs are identical to what they were before the fix. Signed-off-by: Brice Goglin <[email protected]>
1 parent f207b0f commit d081c32

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

doc/hwloc.doxy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,6 +2452,9 @@ or between two subdevices of the same parent.
24522452

24532453
The matrix interconnects all LevelZero devices and subdevices (if any),
24542454
even if some of them may have no link at all.
2455+
2456+
The bandwidths of links between subdevices are accumulated in the
2457+
bandwidth between their parents.
24552458
</dd>
24562459
<dt>NVLinkBandwidth (NVML)</dt>
24572460
<dd>This is the matrix of unidirectional NVLink bandwidths between

hwloc/topology-levelzero.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ struct hwloc_levelzero_ports {
382382
unsigned nr;
383383
struct hwloc_levelzero_port {
384384
hwloc_obj_t osdev;
385+
hwloc_obj_t parent_osdev;
385386
zes_fabric_port_properties_t props;
386387
zes_fabric_port_state_t state;
387388
} *ports;
@@ -443,12 +444,14 @@ hwloc__levelzero_ports_get(zes_device_handle_t dvh,
443444
i, hports->ports[id].props.subdeviceId);
444445
if (hports->ports[id].props.subdeviceId < nr_sub_osdevs) {
445446
hports->ports[id].osdev = sub_osdevs[hports->ports[id].props.subdeviceId];
447+
hports->ports[id].parent_osdev = root_osdev;
446448
} else {
447449
hwloc_debug(" no such subdevice exists, ignoring\n");
448450
continue;
449451
}
450452
} else {
451453
hports->ports[id].osdev = root_osdev;
454+
hports->ports[id].parent_osdev = NULL;
452455
}
453456

454457
res = zesFabricPortGetState(ports[i], &hports->ports[id].state);
@@ -549,7 +552,14 @@ hwloc__levelzero_ports_connect(struct hwloc_topology *topology,
549552
if (iindex<0 || jindex<0)
550553
continue;
551554
bws[iindex*oarray->nr+jindex] += hports->ports[i].state.rxSpeed.bitRate >> 20; /* MB/s */
552-
/* TODO: way to accumulate subdevs bw into rootdevs? tranformation? different matrix? */
555+
if (hports->ports[i].parent_osdev && hports->ports[j].parent_osdev) {
556+
/* also accumulate in root devices */
557+
iindex = hwloc__levelzero_osdev_array_find(oarray, hports->ports[i].parent_osdev);
558+
jindex = hwloc__levelzero_osdev_array_find(oarray, hports->ports[j].parent_osdev);
559+
if (iindex<0 || jindex<0)
560+
continue;
561+
bws[iindex*oarray->nr+jindex] += hports->ports[i].state.rxSpeed.bitRate >> 20; /* MB/s */
562+
}
553563
gotbw++;
554564
}
555565
}

0 commit comments

Comments
 (0)