Skip to content

Commit cec7b8b

Browse files
authored
Merge pull request #5380 from hoopoepg/topic/fixed-ucx-abstraction-viola-v3.1
MCA/ATOMICS/UCX: workaround for abstraction violation - v3.1
2 parents bfb8606 + f42f1b7 commit cec7b8b

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

oshmem/mca/atomic/ucx/atomic_ucx_cswap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int mca_atomic_ucx_cswap(void *target,
3030
spml_ucx_mkey_t *ucx_mkey;
3131
uint64_t rva;
3232

33-
ucx_mkey = mca_spml_ucx_get_mkey(pe, target, (void *)&rva);
33+
ucx_mkey = mca_spml_ucx_get_mkey(pe, target, (void *)&rva, mca_spml_self);
3434
if (NULL == cond) {
3535
switch (nlong) {
3636
case 4:

oshmem/mca/atomic/ucx/atomic_ucx_fadd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ int mca_atomic_ucx_fadd(void *target,
2929
spml_ucx_mkey_t *ucx_mkey;
3030
uint64_t rva;
3131

32-
ucx_mkey = mca_spml_ucx_get_mkey(pe, target, (void *)&rva);
33-
32+
ucx_mkey = mca_spml_ucx_get_mkey(pe, target, (void *)&rva, mca_spml_self);
3433
if (NULL == prev) {
3534
switch (nlong) {
3635
case 4:

oshmem/mca/spml/ucx/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ mcacomponentdir = $(ompilibdir)
3434
mcacomponent_LTLIBRARIES = $(component_install)
3535
mca_spml_ucx_la_SOURCES = $(ucx_sources)
3636
mca_spml_ucx_la_LIBADD = $(top_builddir)/oshmem/liboshmem.la \
37-
$(spml_ucx_LIBS)
37+
$(spml_ucx_LIBS) \
38+
$(top_builddir)/oshmem/mca/spml/libmca_spml.la
3839
mca_spml_ucx_la_LDFLAGS = -module -avoid-version $(spml_ucx_LDFLAGS)
3940

4041
noinst_LTLIBRARIES = $(component_noinst)

oshmem/mca/spml/ucx/spml_ucx.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
#define SPML_UCX_PUT_DEBUG 0
4444
#endif
4545

46+
static
47+
spml_ucx_mkey_t * mca_spml_ucx_get_mkey_slow(int pe, void *va, void **rva);
48+
4649
mca_spml_ucx_t mca_spml_ucx = {
4750
{
4851
/* Init mca_spml_base_module_t */
@@ -74,7 +77,9 @@ mca_spml_ucx_t mca_spml_ucx = {
7477
NULL, /* ucp_peers */
7578
0, /* using_mem_hooks */
7679
1, /* num_disconnect */
77-
0 /* heap_reg_nb */
80+
0, /* heap_reg_nb */
81+
0, /* enabled */
82+
mca_spml_ucx_get_mkey_slow
7883
};
7984

8085
int mca_spml_ucx_enable(bool enable)
@@ -330,6 +335,7 @@ int mca_spml_ucx_add_procs(ompi_proc_t** procs, size_t nprocs)
330335
}
331336

332337

338+
static
333339
spml_ucx_mkey_t * mca_spml_ucx_get_mkey_slow(int pe, void *va, void **rva)
334340
{
335341
sshmem_mkey_t *r_mkey;
@@ -550,7 +556,7 @@ int mca_spml_ucx_get(void *src_addr, size_t size, void *dst_addr, int src)
550556
ucs_status_t status;
551557
spml_ucx_mkey_t *ucx_mkey;
552558

553-
ucx_mkey = mca_spml_ucx_get_mkey(src, src_addr, &rva);
559+
ucx_mkey = mca_spml_ucx_get_mkey(src, src_addr, &rva, &mca_spml_ucx);
554560
status = ucp_get(mca_spml_ucx.ucp_peers[src].ucp_conn, dst_addr, size,
555561
(uint64_t)rva, ucx_mkey->rkey);
556562

@@ -563,7 +569,7 @@ int mca_spml_ucx_get_nb(void *src_addr, size_t size, void *dst_addr, int src, vo
563569
ucs_status_t status;
564570
spml_ucx_mkey_t *ucx_mkey;
565571

566-
ucx_mkey = mca_spml_ucx_get_mkey(src, src_addr, &rva);
572+
ucx_mkey = mca_spml_ucx_get_mkey(src, src_addr, &rva, &mca_spml_ucx);
567573
status = ucp_get_nbi(mca_spml_ucx.ucp_peers[src].ucp_conn, dst_addr, size,
568574
(uint64_t)rva, ucx_mkey->rkey);
569575

@@ -576,7 +582,7 @@ int mca_spml_ucx_put(void* dst_addr, size_t size, void* src_addr, int dst)
576582
ucs_status_t status;
577583
spml_ucx_mkey_t *ucx_mkey;
578584

579-
ucx_mkey = mca_spml_ucx_get_mkey(dst, dst_addr, &rva);
585+
ucx_mkey = mca_spml_ucx_get_mkey(dst, dst_addr, &rva, &mca_spml_ucx);
580586
status = ucp_put(mca_spml_ucx.ucp_peers[dst].ucp_conn, src_addr, size,
581587
(uint64_t)rva, ucx_mkey->rkey);
582588

@@ -589,7 +595,7 @@ int mca_spml_ucx_put_nb(void* dst_addr, size_t size, void* src_addr, int dst, vo
589595
ucs_status_t status;
590596
spml_ucx_mkey_t *ucx_mkey;
591597

592-
ucx_mkey = mca_spml_ucx_get_mkey(dst, dst_addr, &rva);
598+
ucx_mkey = mca_spml_ucx_get_mkey(dst, dst_addr, &rva, &mca_spml_ucx);
593599
status = ucp_put_nbi(mca_spml_ucx.ucp_peers[dst].ucp_conn, src_addr, size,
594600
(uint64_t)rva, ucx_mkey->rkey);
595601

oshmem/mca/spml/ucx/spml_ucx.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ struct ucp_peer {
5858
};
5959
typedef struct ucp_peer ucp_peer_t;
6060

61+
typedef spml_ucx_mkey_t * (*mca_spml_ucx_get_mkey_slow_fn_t)(int pe, void *va, void **rva);
62+
6163
struct mca_spml_ucx {
6264
mca_spml_base_module_t super;
6365
ucp_context_h ucp_context;
@@ -68,6 +70,8 @@ struct mca_spml_ucx {
6870

6971
int priority; /* component priority */
7072
bool enabled;
73+
74+
mca_spml_ucx_get_mkey_slow_fn_t get_mkey_slow;
7175
};
7276
typedef struct mca_spml_ucx mca_spml_ucx_t;
7377

@@ -121,17 +125,16 @@ extern int mca_spml_ucx_quiet(void);
121125
extern int spml_ucx_progress(void);
122126

123127

124-
spml_ucx_mkey_t * mca_spml_ucx_get_mkey_slow(int pe, void *va, void **rva);
125-
126128
static inline spml_ucx_mkey_t *
127-
mca_spml_ucx_get_mkey(int pe, void *va, void **rva)
129+
mca_spml_ucx_get_mkey(int pe, void *va, void **rva, mca_spml_ucx_t* module)
128130
{
129131
spml_ucx_cached_mkey_t *mkey;
130132

131-
mkey = mca_spml_ucx.ucp_peers[pe].mkeys;
133+
mkey = module->ucp_peers[pe].mkeys;
132134
mkey = (spml_ucx_cached_mkey_t *)map_segment_find_va(&mkey->super.super, sizeof(*mkey), va);
133135
if (OPAL_UNLIKELY(NULL == mkey)) {
134-
return mca_spml_ucx_get_mkey_slow(pe, va, rva);
136+
assert(module->get_mkey_slow);
137+
return module->get_mkey_slow(pe, va, rva);
135138
}
136139
*rva = map_segment_va2rva(&mkey->super, va);
137140
return &mkey->key;

0 commit comments

Comments
 (0)