Skip to content

Commit d3d661c

Browse files
jtamznwckzhang
authored andcommitted
Add OFI BTL flags for OSC when using accelerator memory
Adds the capability for the OSC RDMA component to handle GPU windows during the query API. Also adds flags to the OFI BTL showing accelerator support. Signed-off-by: Jingyin Tang <jytang@amazon.com>
1 parent 202b50f commit d3d661c

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

ompi/mca/osc/rdma/osc_rdma_component.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,16 +372,20 @@ static int ompi_osc_rdma_component_query (struct ompi_win_t *win, void **base, s
372372
struct ompi_communicator_t *comm, struct opal_info_t *info,
373373
int flavor)
374374
{
375+
376+
opal_list_t *btls = NULL;
377+
mca_btl_base_selected_module_t* selected_btl;
378+
int gpu_check = 0;
379+
375380
if (MPI_WIN_FLAVOR_SHARED == flavor) {
376381
return -1;
377382
}
378383

379-
/* GPU buffers are not supported by the rdma component */
380384
if (MPI_WIN_FLAVOR_CREATE == flavor) {
381385
uint64_t flags;
382386
int dev_id;
383387
if (opal_accelerator.check_addr(*base, &dev_id, &flags)) {
384-
return -1;
388+
gpu_check = 1;
385389
}
386390
}
387391

@@ -392,6 +396,28 @@ static int ompi_osc_rdma_component_query (struct ompi_win_t *win, void **base, s
392396
return -1;
393397
}
394398

399+
/* Not on GPU at all, skip the check */
400+
if (!gpu_check) {
401+
goto ok;
402+
}
403+
404+
/* If we have any btls, we check again if any btl supports
405+
* MCA_BTL_FLAGS_ACCELERATOR_RDMA */
406+
btls = &mca_btl_base_modules_initialized;
407+
OPAL_LIST_FOREACH(selected_btl, btls, mca_btl_base_selected_module_t) {
408+
opal_output_verbose(MCA_BASE_VERBOSE_INFO, ompi_osc_base_framework.framework_output,
409+
"osc_rdma_component_query: check ACCELERATOR_RDMA flag: %s",
410+
selected_btl->btl_component->btl_version.mca_component_name);
411+
mca_btl_base_module_t *btl = selected_btl->btl_module;
412+
// Check flag: MCA_BTL_FLAGS_ACCELERATOR_RDMA
413+
if (btl->btl_flags & MCA_BTL_FLAGS_ACCELERATOR_RDMA) {
414+
goto ok;
415+
}
416+
}
417+
/* No BTL supports the accelerator flag */
418+
return -1;
419+
420+
ok:
395421
return mca_osc_rdma_component.priority;
396422
}
397423

opal/mca/btl/ofi/btl_ofi_component.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,10 @@ static int mca_btl_ofi_init_device(struct fi_info *info)
604604
module->use_fi_mr_bind = false;
605605
module->bypass_cache = false;
606606

607+
if (ofi_info->caps & FI_HMEM) {
608+
module->super.btl_flags |= MCA_BTL_FLAGS_ACCELERATOR_RDMA;
609+
}
610+
607611
if (ofi_info->domain_attr->mr_mode == FI_MR_BASIC
608612
|| ofi_info->domain_attr->mr_mode & FI_MR_VIRT_ADDR) {
609613
module->use_virt_addr = true;

opal/mca/btl/ofi/btl_ofi_module.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ int mca_btl_ofi_reg_mem(void *reg_data, void *base, size_t size,
252252
attr.access = access_flags;
253253
attr.offset = 0;
254254
attr.context = NULL;
255+
attr.requested_key = (uint64_t) reg;
255256

256257
if (OPAL_LIKELY(NULL != base)) {
257258
rc = opal_accelerator.check_addr(base, &dev_id, &flags);

0 commit comments

Comments
 (0)