Skip to content

Commit 698379c

Browse files
committed
mtl/ofi: set device only flag
In OFI, the FI_HMEM_DEVICE_ONLY registration flag signals to the provider that the memory is only on the device and is not unified memory (which can migrate between the GPU and host). IPC is only usable with device only memory and is not valid for unified memory. Without this flag, providers cannot provide optimizations like IPC. Set the flag if the address was found to be non-unified memory. This enables IPC copies in OFI. This also includes an indentation fix within the same function Signed-off-by: Zach Dworkin <[email protected]> Signed-off-by: Alexia Ingerson <[email protected]>
1 parent 448fa67 commit 698379c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ompi/mca/mtl/ofi/mtl_ofi_mr.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ompi_mtl_ofi_reg_mem(void *reg_data, void *base, size_t size,
2121
struct iovec iov = {0};
2222
ompi_mtl_ofi_reg_t *mtl_reg = (ompi_mtl_ofi_reg_t *)reg;
2323
int dev_id;
24-
uint64_t flags;
24+
uint64_t flags, mr_flags = 0;
2525

2626
iov.iov_base = base;
2727
iov.iov_len = size;
@@ -41,7 +41,7 @@ ompi_mtl_ofi_reg_mem(void *reg_data, void *base, size_t size,
4141
attr.iface = FI_HMEM_CUDA;
4242
opal_accelerator.get_device(&attr.device.cuda);
4343
#if OPAL_OFI_HAVE_FI_HMEM_ROCR
44-
} else if (0 == strcmp(opal_accelerator_base_selected_component.base_version.mca_component_name, "rocm")) {
44+
} else if (0 == strcmp(opal_accelerator_base_selected_component.base_version.mca_component_name, "rocm")) {
4545
attr.iface = FI_HMEM_ROCR;
4646
opal_accelerator.get_device(&attr.device.cuda);
4747
#endif
@@ -53,11 +53,13 @@ ompi_mtl_ofi_reg_mem(void *reg_data, void *base, size_t size,
5353
} else {
5454
return OPAL_ERROR;
5555
}
56+
mr_flags = flags & MCA_ACCELERATOR_FLAGS_UNIFIED_MEMORY ? 0 :
57+
FI_HMEM_DEVICE_ONLY
5658
}
5759
}
5860
#endif
5961

60-
ret = fi_mr_regattr(ompi_mtl_ofi.domain, &attr, 0, &mtl_reg->ofi_mr);
62+
ret = fi_mr_regattr(ompi_mtl_ofi.domain, &attr, mr_flags, &mtl_reg->ofi_mr);
6163
if (0 != ret) {
6264
opal_show_help("help-mtl-ofi.txt", "Buffer Memory Registration Failed", true,
6365
opal_accelerator_base_selected_component.base_version.mca_component_name,

0 commit comments

Comments
 (0)