22/*
33 * Copyright (c) 2010-2017 Los Alamos National Security, LLC. All rights
44 * reserved.
5+ * Copyright (c) 2019 Google, Inc. All rights reserved.
56 * $COPYRIGHT$
67 *
78 * Additional copyrights may follow
1617#include "btl_vader_endpoint.h"
1718#include "btl_vader_xpmem.h"
1819
19- static void mca_btl_vader_sc_emu_aop_complete (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint ,
20- mca_btl_base_descriptor_t * desc , int status )
21- {
22- mca_btl_vader_frag_t * frag = (mca_btl_vader_frag_t * ) desc ;
23- 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 ;
27-
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 );
32- }
33-
3420int mca_btl_vader_emu_aop (struct mca_btl_base_module_t * btl , struct mca_btl_base_endpoint_t * endpoint ,
3521 uint64_t remote_address , mca_btl_base_registration_handle_t * remote_handle ,
3622 mca_btl_base_atomic_op_t op , uint64_t operand , int flags , int order ,
3723 mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext , void * cbdata )
3824{
39- mca_btl_vader_frag_t * frag ;
40-
41- frag = mca_btl_vader_rdma_frag_alloc (btl , endpoint , MCA_BTL_VADER_OP_ATOMIC , operand , 0 , op , 0 , order , flags , NULL ,
42- remote_address , cbfunc , cbcontext , cbdata , mca_btl_vader_sc_emu_aop_complete );
43- if (OPAL_UNLIKELY (NULL == frag )) {
44- return OPAL_ERR_OUT_OF_RESOURCE ;
45- }
46-
47- /* send is always successful */
48- (void ) mca_btl_vader_send (btl , endpoint , & frag -> base , MCA_BTL_TAG_VADER );
49-
50- return OPAL_SUCCESS ;
51- }
52-
53- static void mca_btl_vader_sc_emu_afop_complete (mca_btl_base_module_t * btl , mca_btl_base_endpoint_t * endpoint ,
54- mca_btl_base_descriptor_t * desc , int status )
55- {
56- mca_btl_vader_frag_t * frag = (mca_btl_vader_frag_t * ) desc ;
57- mca_btl_vader_sc_emu_hdr_t * hdr ;
58- 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 ;
62-
63- hdr = (mca_btl_vader_sc_emu_hdr_t * ) frag -> segments [0 ].seg_addr .pval ;
64-
65- * ((int64_t * ) frag -> rdma .local_address ) = hdr -> operand [0 ];
66-
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 );
25+ size_t size = (flags & MCA_BTL_ATOMIC_FLAG_32BIT ) ? 4 : 8 ;
26+ return mca_btl_vader_rdma_frag_start (btl , endpoint , MCA_BTL_VADER_OP_ATOMIC , operand , 0 , op , order , flags ,
27+ size , NULL , remote_address , cbfunc , cbcontext , cbdata );
7128}
7229
7330int mca_btl_vader_emu_afop (struct mca_btl_base_module_t * btl , struct mca_btl_base_endpoint_t * endpoint ,
@@ -76,37 +33,17 @@ int mca_btl_vader_emu_afop (struct mca_btl_base_module_t *btl, struct mca_btl_ba
7633 uint64_t operand , int flags , int order , mca_btl_base_rdma_completion_fn_t cbfunc ,
7734 void * cbcontext , void * cbdata )
7835{
79- mca_btl_vader_frag_t * frag ;
80-
81- frag = mca_btl_vader_rdma_frag_alloc (btl , endpoint , MCA_BTL_VADER_OP_ATOMIC , operand , 0 , op , 0 , order , flags ,
82- local_address , remote_address , cbfunc , cbcontext , cbdata ,
83- mca_btl_vader_sc_emu_afop_complete );
84- if (OPAL_UNLIKELY (NULL == frag )) {
85- return OPAL_ERR_OUT_OF_RESOURCE ;
86- }
87-
88- /* send is always successful */
89- (void ) mca_btl_vader_send (btl , endpoint , & frag -> base , MCA_BTL_TAG_VADER );
90-
91- return OPAL_SUCCESS ;
36+ size_t size = (flags & MCA_BTL_ATOMIC_FLAG_32BIT ) ? 4 : 8 ;
37+ return mca_btl_vader_rdma_frag_start (btl , endpoint , MCA_BTL_VADER_OP_ATOMIC , operand , 0 , op , order , flags ,
38+ size , local_address , remote_address , cbfunc , cbcontext , cbdata );
9239}
9340
9441int mca_btl_vader_emu_acswap (struct mca_btl_base_module_t * btl , struct mca_btl_base_endpoint_t * endpoint ,
9542 void * local_address , uint64_t remote_address , mca_btl_base_registration_handle_t * local_handle ,
9643 mca_btl_base_registration_handle_t * remote_handle , uint64_t compare , uint64_t value , int flags ,
9744 int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext , void * cbdata )
9845{
99- mca_btl_vader_frag_t * frag ;
100-
101- frag = mca_btl_vader_rdma_frag_alloc (btl , endpoint , MCA_BTL_VADER_OP_CSWAP , compare , value , 0 , 0 , order ,
102- flags , local_address , remote_address , cbfunc , cbcontext , cbdata ,
103- mca_btl_vader_sc_emu_afop_complete );
104- if (OPAL_UNLIKELY (NULL == frag )) {
105- return OPAL_ERR_OUT_OF_RESOURCE ;
106- }
107-
108- /* send is always successful */
109- (void ) mca_btl_vader_send (btl , endpoint , & frag -> base , MCA_BTL_TAG_VADER );
110-
111- return OPAL_SUCCESS ;
46+ size_t size = (flags & MCA_BTL_ATOMIC_FLAG_32BIT ) ? 4 : 8 ;
47+ return mca_btl_vader_rdma_frag_start (btl , endpoint , MCA_BTL_VADER_OP_CSWAP , compare , value , 0 , order ,
48+ flags , size , local_address , remote_address , cbfunc , cbcontext , cbdata );
11249}
0 commit comments