Skip to content

Commit a27db8b

Browse files
committed
levelzero.h: fix the lookup of parent pci devices
L0 osdevs may have subdevices, hence the PCI parent isn't always the first parent. Signed-off-by: Brice Goglin <[email protected]> (cherry picked from commit 8bc2304)
1 parent 0334ea1 commit a27db8b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

include/hwloc/levelzero.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2021-2023 Inria. All rights reserved.
2+
* Copyright © 2021-2024 Inria. All rights reserved.
33
* See COPYING in top-level directory.
44
*/
55

@@ -131,11 +131,17 @@ hwloc_levelzero_get_device_osdev(hwloc_topology_t topology, ze_device_handle_t d
131131

132132
osdev = NULL;
133133
while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
134-
hwloc_obj_t pcidev = osdev->parent;
134+
hwloc_obj_t pcidev;
135135

136136
if (strncmp(osdev->name, "ze", 2))
137137
continue;
138138

139+
pcidev = osdev;
140+
while (pcidev && pcidev->type != HWLOC_OBJ_PCI_DEVICE)
141+
pcidev = pcidev->parent;
142+
if (!pcidev)
143+
continue;
144+
139145
if (pcidev
140146
&& pcidev->type == HWLOC_OBJ_PCI_DEVICE
141147
&& pcidev->attr->pcidev.domain == pci.address.domain

0 commit comments

Comments
 (0)