Skip to content

Commit 9d3a799

Browse files
committed
btl/vader: fix bugs in rma emulation
This commit fixes two bugs in the RMA/atomic emulation code: 1) Fix a fragment leak when using AMO emulation. 2) Always initialize the single-copy emulation code. This is required to use the AMO support. Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
1 parent 304a6a5 commit 9d3a799

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

opal/mca/btl/vader/btl_vader_atomic.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ static void mca_btl_vader_sc_emu_aop_complete (mca_btl_base_module_t *btl, mca_b
2121
{
2222
mca_btl_vader_frag_t *frag = (mca_btl_vader_frag_t *) desc;
2323
void *local_address = frag->rdma.local_address;
24+
void *context = frag->rdma.context;
25+
void *cbdata = frag->rdma.cbdata;
26+
mca_btl_base_rdma_completion_fn_t cbfunc = frag->rdma.cbfunc;
2427

25-
frag->rdma.cbfunc (btl, endpoint, local_address, NULL, frag->rdma.context, frag->rdma.cbdata, status);
28+
/* return the fragment first since the callback may call put/get/amo and could use this fragment */
29+
MCA_BTL_VADER_FRAG_RETURN(frag);
30+
31+
cbfunc (btl, endpoint, local_address, NULL, context, cbdata, status);
2632
}
2733

2834
int mca_btl_vader_emu_aop (struct mca_btl_base_module_t *btl, struct mca_btl_base_endpoint_t *endpoint,
@@ -50,12 +56,18 @@ static void mca_btl_vader_sc_emu_afop_complete (mca_btl_base_module_t *btl, mca_
5056
mca_btl_vader_frag_t *frag = (mca_btl_vader_frag_t *) desc;
5157
mca_btl_vader_sc_emu_hdr_t *hdr;
5258
void *local_address = frag->rdma.local_address;
59+
void *context = frag->rdma.context;
60+
void *cbdata = frag->rdma.cbdata;
61+
mca_btl_base_rdma_completion_fn_t cbfunc = frag->rdma.cbfunc;
5362

5463
hdr = (mca_btl_vader_sc_emu_hdr_t *) frag->segments[0].seg_addr.pval;
5564

5665
*((int64_t *) frag->rdma.local_address) = hdr->operand[0];
5766

58-
frag->rdma.cbfunc (btl, endpoint, local_address, NULL, frag->rdma.context, frag->rdma.cbdata, status);
67+
/* return the fragment first since the callback may call put/get/amo and could use this fragment */
68+
MCA_BTL_VADER_FRAG_RETURN(frag);
69+
70+
cbfunc (btl, endpoint, local_address, NULL, context, cbdata, status);
5971
}
6072

6173
int mca_btl_vader_emu_afop (struct mca_btl_base_module_t *btl, struct mca_btl_base_endpoint_t *endpoint,

opal/mca/btl/vader/btl_vader_component.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ static void mca_btl_vader_check_single_copy (void)
379379
{
380380
int initial_mechanism = mca_btl_vader_component.single_copy_mechanism;
381381

382+
/* single-copy emulation is always used to support AMO's right now */
383+
mca_btl_vader_sc_emu_init ();
384+
382385
#if OPAL_BTL_VADER_HAVE_XPMEM
383386
if (MCA_BTL_VADER_XPMEM == mca_btl_vader_component.single_copy_mechanism) {
384387
/* try to create an xpmem segment for the entire address space */
@@ -462,7 +465,6 @@ static void mca_btl_vader_check_single_copy (void)
462465
}
463466

464467
if (MCA_BTL_VADER_EMUL == mca_btl_vader_component.single_copy_mechanism) {
465-
mca_btl_vader_sc_emu_init ();
466468
/* limit to the maximum fragment size */
467469
mca_btl_vader.super.btl_put_limit = mca_btl_vader.super.btl_max_send_size - sizeof (mca_btl_vader_sc_emu_hdr_t);
468470
mca_btl_vader.super.btl_get_limit = mca_btl_vader.super.btl_max_send_size - sizeof (mca_btl_vader_sc_emu_hdr_t);

0 commit comments

Comments
 (0)