Skip to content

Commit e6eed4b

Browse files
authored
Merge pull request #5417 from hoopoepg/topic/fixed-ucx-abstraction-viola-v2.x
v2.x: MCA/ATOMICS/UCX: workaround for abstraction violation - v2.x
2 parents b645528 + 4d927ba commit e6eed4b

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ endif
3232
mcacomponentdir = $(ompilibdir)
3333
mcacomponent_LTLIBRARIES = $(component_install)
3434
mca_spml_ucx_la_SOURCES = $(ucx_sources)
35-
mca_spml_ucx_la_LIBADD = $(spml_ucx_LIBS)
35+
mca_spml_ucx_la_LIBADD = $(top_builddir)/oshmem/liboshmem.la \
36+
$(spml_ucx_LIBS) \
37+
$(top_builddir)/oshmem/mca/spml/libmca_spml.la
3638
mca_spml_ucx_la_LDFLAGS = -module -avoid-version $(spml_ucx_LDFLAGS)
3739

3840
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 */
@@ -73,7 +76,9 @@ mca_spml_ucx_t mca_spml_ucx = {
7376
NULL, /* ucp_peers */
7477
0, /* using_mem_hooks */
7578
1, /* num_disconnect */
76-
0 /* heap_reg_nb */
79+
0, /* heap_reg_nb */
80+
0, /* enabled */
81+
mca_spml_ucx_get_mkey_slow
7782
};
7883

7984
int mca_spml_ucx_enable(bool enable)
@@ -327,6 +332,7 @@ int mca_spml_ucx_add_procs(ompi_proc_t **procs, size_t nprocs)
327332
}
328333

329334

335+
static
330336
spml_ucx_mkey_t * mca_spml_ucx_get_mkey_slow(int pe, void *va, void **rva)
331337
{
332338
sshmem_mkey_t *r_mkey;
@@ -516,7 +522,7 @@ int mca_spml_ucx_get(void *src_addr, size_t size, void *dst_addr, int src)
516522
ucs_status_t status;
517523
spml_ucx_mkey_t *ucx_mkey;
518524

519-
ucx_mkey = mca_spml_ucx_get_mkey(src, src_addr, &rva);
525+
ucx_mkey = mca_spml_ucx_get_mkey(src, src_addr, &rva, &mca_spml_ucx);
520526
status = ucp_get(mca_spml_ucx.ucp_peers[src].ucp_conn, dst_addr, size,
521527
(uint64_t)rva, ucx_mkey->rkey);
522528

@@ -529,7 +535,7 @@ int mca_spml_ucx_get_nb(void *src_addr, size_t size, void *dst_addr, int src, vo
529535
ucs_status_t status;
530536
spml_ucx_mkey_t *ucx_mkey;
531537

532-
ucx_mkey = mca_spml_ucx_get_mkey(src, src_addr, &rva);
538+
ucx_mkey = mca_spml_ucx_get_mkey(src, src_addr, &rva, &mca_spml_ucx);
533539
status = ucp_get_nbi(mca_spml_ucx.ucp_peers[src].ucp_conn, dst_addr, size,
534540
(uint64_t)rva, ucx_mkey->rkey);
535541

@@ -542,7 +548,7 @@ int mca_spml_ucx_put(void* dst_addr, size_t size, void* src_addr, int dst)
542548
ucs_status_t status;
543549
spml_ucx_mkey_t *ucx_mkey;
544550

545-
ucx_mkey = mca_spml_ucx_get_mkey(dst, dst_addr, &rva);
551+
ucx_mkey = mca_spml_ucx_get_mkey(dst, dst_addr, &rva, &mca_spml_ucx);
546552
status = ucp_put(mca_spml_ucx.ucp_peers[dst].ucp_conn, src_addr, size,
547553
(uint64_t)rva, ucx_mkey->rkey);
548554

@@ -555,7 +561,7 @@ int mca_spml_ucx_put_nb(void* dst_addr, size_t size, void* src_addr, int dst, vo
555561
ucs_status_t status;
556562
spml_ucx_mkey_t *ucx_mkey;
557563

558-
ucx_mkey = mca_spml_ucx_get_mkey(dst, dst_addr, &rva);
564+
ucx_mkey = mca_spml_ucx_get_mkey(dst, dst_addr, &rva, &mca_spml_ucx);
559565
status = ucp_put_nbi(mca_spml_ucx.ucp_peers[dst].ucp_conn, src_addr, size,
560566
(uint64_t)rva, ucx_mkey->rkey);
561567

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

@@ -120,17 +124,16 @@ extern int mca_spml_ucx_quiet(void);
120124
extern int spml_ucx_progress(void);
121125

122126

123-
spml_ucx_mkey_t * mca_spml_ucx_get_mkey_slow(int pe, void *va, void **rva);
124-
125127
static inline spml_ucx_mkey_t *
126-
mca_spml_ucx_get_mkey(int pe, void *va, void **rva)
128+
mca_spml_ucx_get_mkey(int pe, void *va, void **rva, mca_spml_ucx_t* module)
127129
{
128130
spml_ucx_cached_mkey_t *mkey;
129131

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

0 commit comments

Comments
 (0)