Skip to content

Commit 1bd9734

Browse files
committed
opal/asm: remove opal_atomic_bool_cmpset functions
This commit eliminates the old opal_atomic_bool_cmpset functions. They have been replaced by the opal_atomic_compare_exchange_strong functions. Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 11bb8b0 commit 1bd9734

23 files changed

+142
-401
lines changed

ompi/datatype/ompi_datatype_args.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Copyright (c) 2004-2006 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
14-
* Copyright (c) 2013-2016 Los Alamos National Security, LLC. All rights
14+
* Copyright (c) 2013-2017 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* Copyright (c) 2015-2017 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
@@ -487,7 +487,8 @@ int ompi_datatype_get_pack_description( ompi_datatype_t* datatype,
487487
void* recursive_buffer;
488488

489489
if (NULL == packed_description) {
490-
if (opal_atomic_bool_cmpset (&datatype->packed_description, NULL, (void *) 1)) {
490+
void *_tmp_ptr = NULL;
491+
if (opal_atomic_compare_exchange_strong_ptr (&datatype->packed_description, (void *) &_tmp_ptr, (void *) 1)) {
491492
if( ompi_datatype_is_predefined(datatype) ) {
492493
packed_description = malloc(2 * sizeof(int));
493494
} else if( NULL == args ) {

ompi/group/group.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Copyright (c) 2007-2017 Cisco Systems, Inc. All rights reserved
1515
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
1616
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
17-
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
17+
* Copyright (c) 2013-2017 Los Alamos National Security, LLC. All rights
1818
* reserved.
1919
* Copyright (c) 2016 Research Organization for Information Science
2020
* and Technology (RIST). All rights reserved.
@@ -356,7 +356,7 @@ static inline struct ompi_proc_t *ompi_group_dense_lookup (ompi_group_t *group,
356356
ompi_proc_t *real_proc =
357357
(ompi_proc_t *) ompi_proc_for_name (ompi_proc_sentinel_to_name ((uintptr_t) proc));
358358

359-
if (opal_atomic_bool_cmpset_ptr (group->grp_proc_pointers + peer_id, proc, real_proc)) {
359+
if (opal_atomic_compare_exchange_strong_ptr (group->grp_proc_pointers + peer_id, &proc, real_proc)) {
360360
OBJ_RETAIN(real_proc);
361361
}
362362

ompi/mca/mtl/portals4/mtl_portals4_flowctl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
33
* Copyright (c) 2012 Sandia National Laboratories. All rights reserved.
4-
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
4+
* Copyright (c) 2015-2017 Los Alamos National Security, LLC. All rights
55
* reserved.
66
* $COPYRIGHT$
77
*
@@ -296,9 +296,10 @@ ompi_mtl_portals4_flowctl_add_procs(size_t me,
296296
int
297297
ompi_mtl_portals4_flowctl_trigger(void)
298298
{
299+
int32_t _tmp_value = 0;
299300
int ret;
300301

301-
if (true == OPAL_ATOMIC_BOOL_CMPSET_32(&ompi_mtl_portals4.flowctl.flowctl_active, false, true)) {
302+
if (true == OPAL_ATOMIC_COMPARE_EXCHANGE_STRONG_32(&ompi_mtl_portals4.flowctl.flowctl_active, &_tmp_value, 1)) {
302303
/* send trigger to root */
303304
ret = PtlPut(ompi_mtl_portals4.zero_md_h,
304305
0,

ompi/mca/osc/pt2pt/osc_pt2pt.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* University of Stuttgart. All rights reserved.
99
* Copyright (c) 2004-2005 The Regents of the University of California.
1010
* All rights reserved.
11-
* Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
11+
* Copyright (c) 2007-2017 Los Alamos National Security, LLC. All rights
1212
* reserved.
1313
* Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2013 Sandia National Laboratories. All rights reserved.
@@ -145,15 +145,11 @@ static inline bool ompi_osc_pt2pt_peer_eager_active (ompi_osc_pt2pt_peer_t *peer
145145

146146
static inline void ompi_osc_pt2pt_peer_set_flag (ompi_osc_pt2pt_peer_t *peer, int32_t flag, bool value)
147147
{
148-
int32_t peer_flags, new_flags;
149-
do {
150-
peer_flags = peer->flags;
151-
if (value) {
152-
new_flags = peer_flags | flag;
153-
} else {
154-
new_flags = peer_flags & ~flag;
155-
}
156-
} while (!OPAL_ATOMIC_BOOL_CMPSET_32 (&peer->flags, peer_flags, new_flags));
148+
if (value) {
149+
OPAL_ATOMIC_OR32 (&peer->flags, flag);
150+
} else {
151+
OPAL_ATOMIC_AND32 (&peer->flags, ~flag);
152+
}
157153
}
158154

159155
static inline void ompi_osc_pt2pt_peer_set_locked (ompi_osc_pt2pt_peer_t *peer, bool value)

ompi/mca/osc/pt2pt/osc_pt2pt_frag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
33
* Copyright (c) 2012-2013 Sandia National Laboratories. All rights reserved.
4-
* Copyright (c) 2014-2015 Los Alamos National Security, LLC. All rights
4+
* Copyright (c) 2014-2017 Los Alamos National Security, LLC. All rights
55
* reserved.
66
* Copyright (c) 2015 Research Organization for Information Science
77
* and Technology (RIST). All rights reserved.
@@ -105,7 +105,7 @@ static int ompi_osc_pt2pt_flush_active_frag (ompi_osc_pt2pt_module_t *module, om
105105
"osc pt2pt: flushing active fragment to target %d. pending: %d",
106106
active_frag->target, active_frag->pending));
107107

108-
if (opal_atomic_bool_cmpset (&peer->active_frag, active_frag, NULL)) {
108+
if (opal_atomic_compare_exchange_strong_ptr (&peer->active_frag, &active_frag, NULL)) {
109109
if (0 != OPAL_THREAD_ADD32(&active_frag->pending, -1)) {
110110
/* communication going on while synchronizing; this is an rma usage bug */
111111
return OMPI_ERR_RMA_SYNC;

ompi/mca/osc/pt2pt/osc_pt2pt_frag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static inline ompi_osc_pt2pt_frag_t *ompi_osc_pt2pt_frag_alloc_non_buffered (omp
6767

6868
/* to ensure ordering flush the buffer on the peer */
6969
curr = peer->active_frag;
70-
if (NULL != curr && opal_atomic_bool_cmpset (&peer->active_frag, curr, NULL)) {
70+
if (NULL != curr && opal_atomic_compare_exchange_strong_ptr (&peer->active_frag, &curr, NULL)) {
7171
/* If there's something pending, the pending finish will
7272
start the buffer. Otherwise, we need to start it now. */
7373
int ret = ompi_osc_pt2pt_frag_finish (module, curr);

ompi/mca/osc/pt2pt/osc_pt2pt_passive_target.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -744,14 +744,13 @@ static bool ompi_osc_pt2pt_lock_try_acquire (ompi_osc_pt2pt_module_t* module, in
744744
break;
745745
}
746746

747-
if (opal_atomic_bool_cmpset_32 (&module->lock_status, lock_status, lock_status + 1)) {
747+
if (opal_atomic_compare_exchange_strong_32 (&module->lock_status, &lock_status, lock_status + 1)) {
748748
break;
749749
}
750-
751-
lock_status = module->lock_status;
752750
} while (1);
753751
} else {
754-
queue = !opal_atomic_bool_cmpset_32 (&module->lock_status, 0, -1);
752+
int32_t _tmp_value = 0;
753+
queue = !opal_atomic_compare_exchange_strong_32 (&module->lock_status, &_tmp_value, -1);
755754
}
756755

757756
if (queue) {

ompi/mca/osc/rdma/osc_rdma_active_target.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* University of Stuttgart. All rights reserved.
99
* Copyright (c) 2004-2005 The Regents of the University of California.
1010
* All rights reserved.
11-
* Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights
11+
* Copyright (c) 2007-2017 Los Alamos National Security, LLC. All rights
1212
* reserved.
1313
* Copyright (c) 2010 IBM Corporation. All rights reserved.
1414
* Copyright (c) 2012-2013 Sandia National Laboratories. All rights reserved.
@@ -285,7 +285,9 @@ int ompi_osc_rdma_post_atomic (ompi_group_t *group, int assert, ompi_win_t *win)
285285
ret = ompi_osc_rdma_lock_btl_cswap (module, peer, target, 0, 1 + (int64_t) my_rank, &result);
286286
assert (OMPI_SUCCESS == ret);
287287
} else {
288-
result = !ompi_osc_rdma_lock_cmpset ((osc_rdma_counter_t *) target, 0, 1 + (osc_rdma_counter_t) my_rank);
288+
ompi_osc_rdma_lock_t _tmp_value = 0;
289+
290+
result = !ompi_osc_rdma_lock_compare_exchange ((osc_rdma_counter_t *) target, &_tmp_value, 1 + (osc_rdma_counter_t) my_rank);
289291
}
290292

291293
if (OPAL_LIKELY(0 == result)) {

ompi/mca/osc/rdma/osc_rdma_lock.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
static inline int ompi_osc_rdma_trylock_local (volatile ompi_osc_rdma_lock_t *lock)
1919
{
20-
return !ompi_osc_rdma_lock_cmpset (lock, 0, OMPI_OSC_RDMA_LOCK_EXCLUSIVE);
20+
ompi_osc_rdma_lock_t _tmp_value = 0;
21+
return !ompi_osc_rdma_lock_compare_exchange (lock, &_tmp_value, OMPI_OSC_RDMA_LOCK_EXCLUSIVE);
2122
}
2223

2324
static inline void ompi_osc_rdma_unlock_local (volatile ompi_osc_rdma_lock_t *lock)

ompi/mca/osc/rdma/osc_rdma_peer.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,13 @@ static inline bool ompi_osc_rdma_peer_test_set_flag (ompi_osc_rdma_peer_t *peer,
201201
int32_t flags;
202202

203203
opal_atomic_mb ();
204+
flags = peer->flags;
204205

205206
do {
206-
flags = peer->flags;
207207
if (flags & flag) {
208208
return false;
209209
}
210-
211-
} while (!OPAL_THREAD_BOOL_CMPSET_32 (&peer->flags, flags, flags | flag));
210+
} while (!OPAL_ATOMIC_COMPARE_EXCHANGE_STRONG_32 (&peer->flags, &flags, flags | flag));
212211

213212
return true;
214213
}

0 commit comments

Comments
 (0)