8
8
* Copyright (c) 2019 Triad National Security, LLC. All rights
9
9
* reserved.
10
10
* Copyright (c) 2019-2021 Google, LLC. All rights reserved.
11
+ * Copyright (c) 2021 IBM Corporation. All rights reserved.
11
12
* $COPYRIGHT$
12
13
*
13
14
* Additional copyrights may follow
@@ -133,6 +134,22 @@ static int ompi_osc_rdma_op_mapping[OMPI_OP_NUM_OF_TYPES + 1] = {
133
134
[OMPI_OP_REPLACE ] = MCA_BTL_ATOMIC_SWAP ,
134
135
};
135
136
137
+ /* set the appropriate flags for this atomic */
138
+ static inline int ompi_osc_rdma_set_btl_flags (ompi_osc_rdma_module_t * module , ompi_datatype_t * dt , ptrdiff_t extent ) {
139
+
140
+ int flags = 0 ;
141
+
142
+ if (4 == extent ) {
143
+ flags = MCA_BTL_ATOMIC_FLAG_32BIT ;
144
+ }
145
+
146
+ if (OMPI_DATATYPE_FLAG_DATA_FLOAT & dt -> super .flags ) {
147
+ flags |= MCA_BTL_ATOMIC_FLAG_FLOAT ;
148
+ }
149
+
150
+ return flags ;
151
+ }
152
+
136
153
static int ompi_osc_rdma_fetch_and_op_atomic (ompi_osc_rdma_sync_t * sync , const void * origin_addr , void * result_addr , ompi_datatype_t * dt ,
137
154
ptrdiff_t extent , ompi_osc_rdma_peer_t * peer , uint64_t target_address ,
138
155
mca_btl_base_registration_handle_t * target_handle , ompi_op_t * op , ompi_osc_rdma_request_t * req )
@@ -151,10 +168,7 @@ static int ompi_osc_rdma_fetch_and_op_atomic (ompi_osc_rdma_sync_t *sync, const
151
168
152
169
btl_op = ompi_osc_rdma_op_mapping [op -> op_type ];
153
170
154
- flags = (4 == extent ) ? MCA_BTL_ATOMIC_FLAG_32BIT : 0 ;
155
- if (OMPI_DATATYPE_FLAG_DATA_FLOAT & dt -> super .flags ) {
156
- flags |= MCA_BTL_ATOMIC_FLAG_FLOAT ;
157
- }
171
+ flags = ompi_osc_rdma_set_btl_flags (module , dt , extent );
158
172
159
173
OSC_RDMA_VERBOSE (MCA_BASE_VERBOSE_TRACE , "initiating fetch-and-op using %d-bit btl atomics. origin: 0x%" PRIx64 ,
160
174
(4 == extent ) ? 32 : 64 , * ((int64_t * ) origin_addr ));
@@ -239,10 +253,7 @@ static int ompi_osc_rdma_acc_single_atomic (ompi_osc_rdma_sync_t *sync, const vo
239
253
origin = (8 == extent ) ? ((uint64_t * ) origin_addr )[0 ] : ((uint32_t * ) origin_addr )[0 ];
240
254
241
255
/* set the appropriate flags for this atomic */
242
- flags = (4 == extent ) ? MCA_BTL_ATOMIC_FLAG_32BIT : 0 ;
243
- if (OMPI_DATATYPE_FLAG_DATA_FLOAT & dt -> super .flags ) {
244
- flags |= MCA_BTL_ATOMIC_FLAG_FLOAT ;
245
- }
256
+ flags = ompi_osc_rdma_set_btl_flags (module , dt , extent );
246
257
247
258
btl_op = ompi_osc_rdma_op_mapping [op -> op_type ];
248
259
@@ -659,7 +670,8 @@ static inline int ompi_osc_rdma_cas_atomic (ompi_osc_rdma_sync_t *sync, const vo
659
670
660
671
compare = (8 == size ) ? ((int64_t * ) compare_addr )[0 ] : ((int32_t * ) compare_addr )[0 ];
661
672
source = (8 == size ) ? ((int64_t * ) source_addr )[0 ] : ((int32_t * ) source_addr )[0 ];
662
- flags = (4 == size ) ? MCA_BTL_ATOMIC_FLAG_32BIT : 0 ;
673
+
674
+ flags = ompi_osc_rdma_set_btl_flags (module , datatype , size );
663
675
664
676
OSC_RDMA_VERBOSE (MCA_BASE_VERBOSE_TRACE , "initiating compare-and-swap using %d-bit btl atomics. compare: 0x%"
665
677
PRIx64 ", origin: 0x%" PRIx64 , (int ) size * 8 , * ((int64_t * ) compare_addr ), * ((int64_t * ) source_addr ));
0 commit comments