88 * Copyright (c) 2019 Triad National Security, LLC. All rights
99 * reserved.
1010 * Copyright (c) 2019-2021 Google, LLC. All rights reserved.
11+ * Copyright (c) 2021 IBM Corporation. All rights reserved.
1112 * $COPYRIGHT$
1213 *
1314 * Additional copyrights may follow
@@ -133,6 +134,22 @@ static int ompi_osc_rdma_op_mapping[OMPI_OP_NUM_OF_TYPES + 1] = {
133134 [OMPI_OP_REPLACE ] = MCA_BTL_ATOMIC_SWAP ,
134135};
135136
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+
136153static 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 ,
137154 ptrdiff_t extent , ompi_osc_rdma_peer_t * peer , uint64_t target_address ,
138155 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
151168
152169 btl_op = ompi_osc_rdma_op_mapping [op -> op_type ];
153170
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 );
158172
159173 OSC_RDMA_VERBOSE (MCA_BASE_VERBOSE_TRACE , "initiating fetch-and-op using %d-bit btl atomics. origin: 0x%" PRIx64 ,
160174 (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
239253 origin = (8 == extent ) ? ((uint64_t * ) origin_addr )[0 ] : ((uint32_t * ) origin_addr )[0 ];
240254
241255 /* 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 );
246257
247258 btl_op = ompi_osc_rdma_op_mapping [op -> op_type ];
248259
@@ -659,7 +670,8 @@ static inline int ompi_osc_rdma_cas_atomic (ompi_osc_rdma_sync_t *sync, const vo
659670
660671 compare = (8 == size ) ? ((int64_t * ) compare_addr )[0 ] : ((int32_t * ) compare_addr )[0 ];
661672 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 );
663675
664676 OSC_RDMA_VERBOSE (MCA_BASE_VERBOSE_TRACE , "initiating compare-and-swap using %d-bit btl atomics. compare: 0x%"
665677 PRIx64 ", origin: 0x%" PRIx64 , (int ) size * 8 , * ((int64_t * ) compare_addr ), * ((int64_t * ) source_addr ));
0 commit comments