Skip to content

Commit 72e5e0d

Browse files
authored
Merge pull request #11132 from wckzhang/cachebypass
Cachebypass
2 parents c74d333 + c3e3d87 commit 72e5e0d

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

opal/mca/btl/ofi/btl_ofi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ struct mca_btl_ofi_module_t {
140140

141141
/** registration cache */
142142
mca_rcache_base_module_t *rcache;
143+
/* If the underlying OFI provider has its own cache, we want to bypass
144+
* rcache registration */
145+
bool bypass_cache;
143146
};
144147
typedef struct mca_btl_ofi_module_t mca_btl_ofi_module_t;
145148

opal/mca/btl/ofi/btl_ofi_component.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ static int mca_btl_ofi_init_device(struct fi_info *info)
575575
module->outstanding_rdma = 0;
576576
module->use_virt_addr = false;
577577
module->use_fi_mr_bind = false;
578+
module->bypass_cache = false;
578579

579580
if (ofi_info->domain_attr->mr_mode == FI_MR_BASIC
580581
|| ofi_info->domain_attr->mr_mode & FI_MR_VIRT_ADDR) {
@@ -585,6 +586,13 @@ static int mca_btl_ofi_init_device(struct fi_info *info)
585586
module->use_fi_mr_bind = true;
586587
}
587588

589+
/* Currently there is no API to query whether the libfabric provider
590+
* uses an underlying registration cache. For now, just check for known
591+
* providers that use registration caching. */
592+
if (!strncasecmp(info->fabric_attr->prov_name, "efa", 3)) {
593+
module->bypass_cache = true;
594+
}
595+
588596
/* create endpoint list */
589597
OBJ_CONSTRUCT(&module->endpoints, opal_list_t);
590598
OBJ_CONSTRUCT(&module->module_lock, opal_mutex_t);

opal/mca/btl/ofi/btl_ofi_module.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,12 @@ mca_btl_ofi_register_mem(struct mca_btl_base_module_t *btl,
194194
mca_btl_ofi_reg_t *reg;
195195
int access_flags = flags & MCA_BTL_REG_FLAG_ACCESS_ANY;
196196
int rc;
197+
uint32_t cache_flags = 0;
198+
if (ofi_module->bypass_cache) {
199+
cache_flags |= MCA_RCACHE_FLAGS_CACHE_BYPASS;
200+
}
197201

198-
rc = ofi_module->rcache->rcache_register(ofi_module->rcache, base, size, 0, access_flags,
202+
rc = ofi_module->rcache->rcache_register(ofi_module->rcache, base, size, cache_flags, access_flags,
199203
(mca_rcache_base_registration_t **) &reg);
200204
if (OPAL_UNLIKELY(OPAL_SUCCESS != rc)) {
201205
return NULL;

opal/mca/rcache/grdma/rcache_grdma_module.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static int mca_rcache_grdma_register(mca_rcache_base_module_t *rcache, void *add
323323
base = OPAL_DOWN_ALIGN_PTR(addr, page_size, unsigned char *);
324324
bound = OPAL_ALIGN_PTR((intptr_t) addr + size, page_size, unsigned char *) - 1;
325325

326-
if (flags & MCA_RCACHE_FLAGS_ACCELERATOR_MEM) {
326+
if (flags & MCA_RCACHE_FLAGS_ACCELERATOR_MEM && !bypass_cache) {
327327
size_t psize;
328328
int res = opal_accelerator.get_address_range(MCA_ACCELERATOR_NO_DEVICE_ID, addr, (void **)&base, &psize);
329329
if (OPAL_SUCCESS != res) {
@@ -371,7 +371,7 @@ static int mca_rcache_grdma_register(mca_rcache_base_module_t *rcache, void *add
371371
grdma_reg->flags = flags;
372372
grdma_reg->access_flags = access_flags;
373373
grdma_reg->ref_count = 1;
374-
if (flags & MCA_RCACHE_FLAGS_ACCELERATOR_MEM) {
374+
if (flags & MCA_RCACHE_FLAGS_ACCELERATOR_MEM && !bypass_cache) {
375375
opal_accelerator.get_buffer_id(MCA_ACCELERATOR_NO_DEVICE_ID, grdma_reg->base, &grdma_reg->gpu_bufID);
376376
}
377377

0 commit comments

Comments
 (0)