Skip to content

Commit

Permalink
nvml: recognize and keep NVSwitches
Browse files Browse the repository at this point in the history
Set their subtype as NVSwitch so that the core doesn't remove
these bridges without any child.

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Apr 13, 2021
1 parent fa8fe41 commit dd1b27b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion hwloc/topology-nvml.c
Expand Up @@ -80,7 +80,11 @@ hwloc__nvml_get_peer_obj_by_pci(struct hwloc_topology *topology, hwloc_obj_t gpu
return obj;
}
case 0x10de: {
/* NVIDIA NVSwitch, return the PCI object, we don't have anything better. */
/* NVIDIA NVSwitch, return the PCI object, we don't have anything better.
* Mark it as subtype NVSwitch so that the core doesn't remove it.
*/
if (!obj->subtype)
obj->subtype = strdup("NVSwitch");
return obj;
}
default: {
Expand Down
4 changes: 3 additions & 1 deletion hwloc/topology.c
Expand Up @@ -2345,11 +2345,13 @@ hwloc__filter_bridges(hwloc_topology_t topology, hwloc_obj_t root, unsigned dept

/* remove bridges that have no child,
* and pci-to-non-pci bridges (pcidev) that no child either.
* keep NVSwitch since they may be used in NVLink matrices.
*/
if (filter == HWLOC_TYPE_FILTER_KEEP_IMPORTANT
&& !child->io_first_child
&& (child->type == HWLOC_OBJ_BRIDGE
|| (child->type == HWLOC_OBJ_PCI_DEVICE && (child->attr->pcidev.class_id >> 8) == 0x06))) {
|| (child->type == HWLOC_OBJ_PCI_DEVICE && (child->attr->pcidev.class_id >> 8) == 0x06
&& (!child->subtype || strcmp(child->subtype, "NVSwitch"))))) {
unlink_and_free_single_object(pchild);
topology->modified = 1;
}
Expand Down

0 comments on commit dd1b27b

Please sign in to comment.