static ncclResult_t ofi_getProperties()

in src/nccl_ofi_net.c [1177:1222]


static ncclResult_t ofi_getProperties(int dev, ncclNetProperties_t *props)
{
	ncclResult_t ret = ncclSuccess;
	ncclNetProperties_t dev_props = {0};
	struct fi_info *nic_prov = NULL;
	struct fid_nic *nic_info = NULL;

	if (dev < 0 || dev >= ofi_ndevices) {
		NCCL_OFI_WARN("Incorrect dev %d provided", dev);
		ret = ncclSystemError;
		goto error;
	}

	nic_prov = get_nic_info(dev, ofi_info_list);
	if (nic_prov == NULL) {
		NCCL_OFI_INFO(NCCL_INIT | NCCL_NET,
			      "Unable to find provider for dev %d", dev);
		ret = ncclSystemError;
		goto error;
	}

	ret = set_nic_props_default(dev, nic_prov, &dev_props);
	if (ret != ncclSuccess)
		goto error;

	/* Change default values as set by NIC attributes */
	nic_info = (struct fid_nic *)nic_prov->nic;
	if (nic_info == NULL) {
		NCCL_OFI_INFO(NCCL_INIT | NCCL_NET,
			      "No NIC info for dev %d. Supplying default values for NIC properties.",
			      dev);
		goto exit;
	}

	dev_props.name = strdup(nic_info->device_attr->name);
	/* Speed reported in Mbps */
	dev_props.speed = nic_info->link_attr->speed / (1e6);

	goto exit;

error:
	props = NULL;
exit:
	*props = dev_props;
	return ret;
}