in src/nccl_ofi_net.c [410:464]
static ncclResult_t register_mr_buffers(ofiComm_t *comm, void *data,
int size, int type,
struct fid_mr **mr_handle)
{
ncclResult_t ret = ncclSuccess;
int rc;
struct fi_mr_attr mr_attr = {0};
struct iovec iov = {0};
/* Check if provider requires registration of local buffers */
if ((local_mr != true) && (type == NCCL_PTR_HOST)) {
NCCL_OFI_TRACE(NCCL_INIT | NCCL_NET,
"Skip registering host buffer. local_mr: %d", local_mr);
goto exit;
}
/* Check if provider requires registration of cuda device buffers */
if ((hmem_mr != true) && (type == NCCL_PTR_CUDA)) {
NCCL_OFI_TRACE(NCCL_INIT | NCCL_NET,
"Skip registering CUDA buffer. hmem_mr: %d", hmem_mr);
goto exit;
}
/* Populate IOV vector for memory registration */
iov.iov_base = data;
iov.iov_len = size;
/* Initialize MR attributes */
mr_attr.mr_iov = &iov;
mr_attr.iov_count = 1;
mr_attr.access = FI_SEND | FI_RECV;
if (type == NCCL_PTR_HOST) {
mr_attr.iface = FI_HMEM_SYSTEM;
} else {
mr_attr.iface = FI_HMEM_CUDA;
/* Get CUDA device ID */
ret = get_cuda_device(data, &mr_attr.device.cuda);
if (OFI_UNLIKELY(ret != ncclSuccess)) {
goto exit;
}
}
rc = fi_mr_regattr(nccl_ofi_component[comm->dev]->domain,
&mr_attr, 0, mr_handle);
if (OFI_UNLIKELY(rc != 0)) {
NCCL_OFI_WARN("Unable to register memory (type = %d) for device %d. RC: %d, Error: %s",
type, comm->dev, rc, fi_strerror(-rc));
ret = ncclSystemError;
}
exit:
return ret;
}