Skip to content

Commit 5cb72aa

Browse files
authored
Merge pull request #4552 from hjelmn/asm_cleanup2
Add atomic fetch-and-op and compare-exchange functions
2 parents 0fcc996 + 7893248 commit 5cb72aa

File tree

110 files changed

+1509
-1441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1509
-1441
lines changed

ompi/datatype/ompi_datatype_args.c

Lines changed: 5 additions & 4 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.
@@ -378,7 +378,7 @@ int32_t ompi_datatype_copy_args( const ompi_datatype_t* source_data,
378378
* a read only memory).
379379
*/
380380
if( NULL != pArgs ) {
381-
OPAL_THREAD_ADD32(&pArgs->ref_count, 1);
381+
OPAL_THREAD_ADD_FETCH32(&pArgs->ref_count, 1);
382382
dest_data->args = pArgs;
383383
}
384384
return OMPI_SUCCESS;
@@ -396,7 +396,7 @@ int32_t ompi_datatype_release_args( ompi_datatype_t* pData )
396396
ompi_datatype_args_t* pArgs = (ompi_datatype_args_t*)pData->args;
397397

398398
assert( 0 < pArgs->ref_count );
399-
OPAL_THREAD_ADD32(&pArgs->ref_count, -1);
399+
OPAL_THREAD_ADD_FETCH32(&pArgs->ref_count, -1);
400400
if( 0 == pArgs->ref_count ) {
401401
/* There are some duplicated datatypes around that have a pointer to this
402402
* args. We will release them only when the last datatype will dissapear.
@@ -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/coll/libnbc/coll_libnbc_component.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ libnbc_module_destruct(ompi_coll_libnbc_module_t *module)
314314
/* if we ever were used for a collective op, do the progress cleanup. */
315315
if (true == module->comm_registered) {
316316
int32_t tmp =
317-
OPAL_THREAD_ADD32(&mca_coll_libnbc_component.active_comms, -1);
317+
OPAL_THREAD_ADD_FETCH32(&mca_coll_libnbc_component.active_comms, -1);
318318
if (0 == tmp) {
319319
opal_progress_unregister(ompi_coll_libnbc_progress);
320320
}

ompi/mca/coll/libnbc/nbc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ int NBC_Init_handle(struct ompi_communicator_t *comm, ompi_coll_libnbc_request_t
618618
/* register progress */
619619
if (need_register) {
620620
int32_t tmp =
621-
OPAL_THREAD_ADD32(&mca_coll_libnbc_component.active_comms, 1);
621+
OPAL_THREAD_ADD_FETCH32(&mca_coll_libnbc_component.active_comms, 1);
622622
if (tmp == 1) {
623623
opal_progress_register(ompi_coll_libnbc_progress);
624624
}

ompi/mca/coll/monitoring/coll_monitoring_component.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static int
120120
mca_coll_monitoring_module_enable(mca_coll_base_module_t*module, struct ompi_communicator_t*comm)
121121
{
122122
mca_coll_monitoring_module_t*monitoring_module = (mca_coll_monitoring_module_t*) module;
123-
if( 1 == opal_atomic_add_32(&monitoring_module->is_initialized, 1) ) {
123+
if( 1 == opal_atomic_add_fetch_32(&monitoring_module->is_initialized, 1) ) {
124124
MONITORING_SAVE_FULL_PREV_COLL_API(monitoring_module, comm);
125125
monitoring_module->data = mca_common_monitoring_coll_new(comm);
126126
OPAL_MONITORING_PRINT_INFO("coll_module_enabled");
@@ -132,7 +132,7 @@ static int
132132
mca_coll_monitoring_module_disable(mca_coll_base_module_t*module, struct ompi_communicator_t*comm)
133133
{
134134
mca_coll_monitoring_module_t*monitoring_module = (mca_coll_monitoring_module_t*) module;
135-
if( 0 == opal_atomic_sub_32(&monitoring_module->is_initialized, 1) ) {
135+
if( 0 == opal_atomic_sub_fetch_32(&monitoring_module->is_initialized, 1) ) {
136136
MONITORING_RELEASE_FULL_PREV_COLL_API(monitoring_module, comm);
137137
mca_common_monitoring_coll_release(monitoring_module->data);
138138
monitoring_module->data = NULL;

ompi/mca/coll/portals4/coll_portals4_allreduce.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ allreduce_kary_tree_top(const void *sendbuf, void *recvbuf, int count,
6868
zero_md_h = mca_coll_portals4_component.zero_md_h;
6969
data_md_h = mca_coll_portals4_component.data_md_h;
7070

71-
internal_count = opal_atomic_add_size_t(&module->coll_count, 1);
71+
internal_count = opal_atomic_add_fetch_size_t(&module->coll_count, 1);
7272

7373
/*
7474
** DATATYPE and SIZES

ompi/mca/coll/portals4/coll_portals4_barrier.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ barrier_hypercube_top(struct ompi_communicator_t *comm,
4444

4545
request->type = OMPI_COLL_PORTALS4_TYPE_BARRIER;
4646

47-
count = opal_atomic_add_size_t(&portals4_module->coll_count, 1);
47+
count = opal_atomic_add_fetch_size_t(&portals4_module->coll_count, 1);
4848

4949
ret = PtlCTAlloc(mca_coll_portals4_component.ni_h,
5050
&request->u.barrier.rtr_ct_h);

ompi/mca/coll/portals4/coll_portals4_bcast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ bcast_kary_tree_top(void *buff, int count,
176176
zero_md_h = mca_coll_portals4_component.zero_md_h;
177177
data_md_h = mca_coll_portals4_component.data_md_h;
178178

179-
internal_count = opal_atomic_add_size_t(&portals4_module->coll_count, 1);
179+
internal_count = opal_atomic_add_fetch_size_t(&portals4_module->coll_count, 1);
180180

181181

182182
/*
@@ -513,7 +513,7 @@ bcast_pipeline_top(void *buff, int count,
513513
zero_md_h = mca_coll_portals4_component.zero_md_h;
514514
data_md_h = mca_coll_portals4_component.data_md_h;
515515

516-
internal_count = opal_atomic_add_size_t(&portals4_module->coll_count, 1);
516+
internal_count = opal_atomic_add_fetch_size_t(&portals4_module->coll_count, 1);
517517

518518
/*
519519
** DATATYPE and SIZES

ompi/mca/coll/portals4/coll_portals4_gather.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ ompi_coll_portals4_gather_intra_binomial_top(const void *sbuf, int scount, struc
582582
/* Setup Common Parameters */
583583
/**********************************/
584584

585-
request->u.gather.coll_count = opal_atomic_add_size_t(&portals4_module->coll_count, 1);
585+
request->u.gather.coll_count = opal_atomic_add_fetch_size_t(&portals4_module->coll_count, 1);
586586

587587
COLL_PORTALS4_UPDATE_IN_ORDER_BMTREE( comm, portals4_module, request->u.gather.root_rank );
588588
bmtree = portals4_module->cached_in_order_bmtree;
@@ -879,7 +879,7 @@ ompi_coll_portals4_gather_intra_linear_top(const void *sbuf, int scount, struct
879879

880880
i_am_root = (request->u.gather.my_rank == request->u.gather.root_rank);
881881

882-
request->u.gather.coll_count = opal_atomic_add_size_t(&portals4_module->coll_count, 1);
882+
request->u.gather.coll_count = opal_atomic_add_fetch_size_t(&portals4_module->coll_count, 1);
883883

884884
ret = setup_gather_buffers_linear(comm, request, portals4_module);
885885
if (MPI_SUCCESS != ret) { line = __LINE__; goto err_hdlr; }

ompi/mca/coll/portals4/coll_portals4_reduce.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ reduce_kary_tree_top(const void *sendbuf, void *recvbuf, int count,
6969
zero_md_h = mca_coll_portals4_component.zero_md_h;
7070
data_md_h = mca_coll_portals4_component.data_md_h;
7171

72-
internal_count = opal_atomic_add_size_t(&module->coll_count, 1);
72+
internal_count = opal_atomic_add_fetch_size_t(&module->coll_count, 1);
7373

7474
/*
7575
** DATATYPE and SIZES

0 commit comments

Comments
 (0)