in src/nccl_ofi_topo.cpp [306:352]
static int get_info_for_node(hwloc_obj_t node, struct fi_info *info_list, struct fi_info **ret_info)
{
*ret_info = NULL;
union hwloc_obj_attr_u *node_attr;
struct fi_info *next;
if (!info_list) {
NCCL_OFI_WARN("No info list provided");
return -EINVAL;
}
node_attr = node->attr;
if (!node_attr) {
NCCL_OFI_WARN("Failed to retrieve attributes from hwloc topology node");
return -EINVAL;
}
if (node->type != HWLOC_OBJ_PCI_DEVICE) {
return 0;
}
/* Iterate through list, return info struct if found */
next = info_list;
do {
struct fi_info *info = next;
next = info->next;
struct fi_pci_attr *attr = ofi_info_get_pci_attr(info);
if (!attr) {
NCCL_OFI_WARN("Failed to retrieve PCI attributes from NIC");
return -EINVAL;
}
if (node_attr->pcidev.domain == attr->domain_id &&
node_attr->pcidev.bus == attr->bus_id &&
node_attr->pcidev.dev == attr->device_id &&
node_attr->pcidev.func == attr->function_id) {
*ret_info = info;
return 0;
}
/* Stop loop if end of list is reached or if info
* struct closes loop to list head */
} while (next && next != info_list);
return 0;
}