2
2
/*
3
3
* Copyright (c) 2010-2017 Los Alamos National Security, LLC. All rights
4
4
* reserved.
5
+ * Copyright (c) 2019 Google, Inc. All rights reserved.
5
6
* $COPYRIGHT$
6
7
*
7
8
* Additional copyrights may follow
16
17
#include "btl_vader_endpoint.h"
17
18
#include "btl_vader_xpmem.h"
18
19
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
-
34
20
int mca_btl_vader_emu_aop (struct mca_btl_base_module_t * btl , struct mca_btl_base_endpoint_t * endpoint ,
35
21
uint64_t remote_address , mca_btl_base_registration_handle_t * remote_handle ,
36
22
mca_btl_base_atomic_op_t op , uint64_t operand , int flags , int order ,
37
23
mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext , void * cbdata )
38
24
{
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 );
71
28
}
72
29
73
30
int 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
76
33
uint64_t operand , int flags , int order , mca_btl_base_rdma_completion_fn_t cbfunc ,
77
34
void * cbcontext , void * cbdata )
78
35
{
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 );
92
39
}
93
40
94
41
int mca_btl_vader_emu_acswap (struct mca_btl_base_module_t * btl , struct mca_btl_base_endpoint_t * endpoint ,
95
42
void * local_address , uint64_t remote_address , mca_btl_base_registration_handle_t * local_handle ,
96
43
mca_btl_base_registration_handle_t * remote_handle , uint64_t compare , uint64_t value , int flags ,
97
44
int order , mca_btl_base_rdma_completion_fn_t cbfunc , void * cbcontext , void * cbdata )
98
45
{
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 );
112
49
}
0 commit comments