Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 00e9277

Browse files
authored
Merge pull request #1287 from hjelmn/v2.x_atomic
Fix performance regression caused by enabling opal thread support
2 parents bfca8a1 + 170161e commit 00e9277

File tree

11 files changed

+223
-177
lines changed

11 files changed

+223
-177
lines changed

ompi/mca/osc/sm/osc_sm_active_target.c

Lines changed: 3 additions & 3 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) 2014-2015 Los Alamos National Security, LLC. All rights
4+
* Copyright (c) 2014-2016 Los Alamos National Security, LLC. All rights
55
* reserved.
66
* Copyright (c) 2014 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
@@ -133,7 +133,7 @@ ompi_osc_sm_start(struct ompi_group_t *group,
133133

134134
OBJ_RETAIN(group);
135135

136-
if (!OPAL_ATOMIC_CMPSET(&module->start_group, NULL, group)) {
136+
if (!OPAL_ATOMIC_CMPSET_PTR(&module->start_group, NULL, group)) {
137137
OBJ_RELEASE(group);
138138
return OMPI_ERR_RMA_SYNC;
139139
}
@@ -185,7 +185,7 @@ ompi_osc_sm_complete(struct ompi_win_t *win)
185185
opal_atomic_mb();
186186

187187
group = module->start_group;
188-
if (NULL == group || !OPAL_ATOMIC_CMPSET(&module->start_group, group, NULL)) {
188+
if (NULL == group || !OPAL_ATOMIC_CMPSET_PTR(&module->start_group, group, NULL)) {
189189
return OMPI_ERR_RMA_SYNC;
190190
}
191191

ompi/mpi/c/comm_get_errhandler.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -12,6 +13,8 @@
1213
* Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved.
1314
* Copyright (c) 2015 Research Organization for Information Science
1415
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
17+
* reserved.
1518
* $COPYRIGHT$
1619
*
1720
* Additional copyrights may follow
@@ -64,7 +67,7 @@ int MPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler *errhandler)
6467
error_handler became atomic. */
6568
do {
6669
tmp = comm->error_handler;
67-
} while (!OPAL_ATOMIC_CMPSET(&(comm->error_handler), tmp, tmp));
70+
} while (!OPAL_ATOMIC_CMPSET_PTR(&(comm->error_handler), tmp, tmp));
6871

6972
/* Retain the errhandler, corresponding to object refcount decrease
7073
in errhandler_free.c. */

ompi/mpi/c/comm_set_errhandler.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -11,6 +12,8 @@
1112
* All rights reserved.
1213
* Copyright (c) 2015 Research Organization for Information Science
1314
* and Technology (RIST). All rights reserved.
15+
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
16+
* reserved.
1417
* $COPYRIGHT$
1518
*
1619
* Additional copyrights may follow
@@ -67,9 +70,7 @@ int MPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler)
6770
/* Ditch the old errhandler, and decrement its refcount. On 64
6871
bits environments we have to make sure the reading of the
6972
error_handler became atomic. */
70-
do {
71-
tmp = comm->error_handler;
72-
} while (!OPAL_ATOMIC_CMPSET(&(comm->error_handler), tmp, errhandler));
73+
tmp = OPAL_ATOMIC_SWAP_PTR(&comm->error_handler, errhandler);
7374
OBJ_RELEASE(tmp);
7475

7576
/* All done */

ompi/mpi/c/file_get_errhandler.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -12,6 +13,8 @@
1213
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
1314
* Copyright (c) 2015 Research Organization for Information Science
1415
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
17+
* reserved.
1518
* $COPYRIGHT$
1619
*
1720
* Additional copyrights may follow
@@ -63,7 +66,7 @@ int MPI_File_get_errhandler( MPI_File file, MPI_Errhandler *errhandler)
6366
error_handler became atomic. */
6467
do {
6568
tmp = file->error_handler;
66-
} while (!OPAL_ATOMIC_CMPSET(&(file->error_handler), tmp, tmp));
69+
} while (!OPAL_ATOMIC_CMPSET_PTR(&(file->error_handler), tmp, tmp));
6770

6871
/* Retain the errhandler, corresponding to object refcount
6972
decrease in errhandler_free.c. */

ompi/mpi/c/file_set_errhandler.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -12,6 +13,8 @@
1213
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
1314
* Copyright (c) 2015 Research Organization for Information Science
1415
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
17+
* reserved.
1518
* $COPYRIGHT$
1619
*
1720
* Additional copyrights may follow
@@ -66,9 +69,7 @@ int MPI_File_set_errhandler( MPI_File file, MPI_Errhandler errhandler)
6669
/* Ditch the old errhandler, and decrement its refcount. On 64
6770
bits environments we have to make sure the reading of the
6871
error_handler became atomic. */
69-
do {
70-
tmp = file->error_handler;
71-
} while (!OPAL_ATOMIC_CMPSET(&(file->error_handler), tmp, errhandler));
72+
tmp = OPAL_ATOMIC_SWAP_PTR (&file->error_handler, errhandler);
7273
OBJ_RELEASE(tmp);
7374

7475
/* All done */

ompi/mpi/c/win_get_errhandler.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -12,6 +13,8 @@
1213
* Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved.
1314
* Copyright (c) 2015 Research Organization for Information Science
1415
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
17+
* reserved.
1518
* $COPYRIGHT$
1619
*
1720
* Additional copyrights may follow
@@ -56,7 +59,7 @@ int MPI_Win_get_errhandler(MPI_Win win, MPI_Errhandler *errhandler)
5659
error_handler became atomic. */
5760
do {
5861
tmp = win->error_handler;
59-
} while (!OPAL_ATOMIC_CMPSET(&(win->error_handler), tmp, tmp));
62+
} while (!OPAL_ATOMIC_CMPSET_PTR(&(win->error_handler), tmp, tmp));
6063

6164
/* Retain the errhandler, corresponding to object refcount
6265
decrease in errhandler_free.c. */

ompi/mpi/c/win_set_errhandler.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -12,6 +13,8 @@
1213
* Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved.
1314
* Copyright (c) 2015 Research Organization for Information Science
1415
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
17+
* reserved.
1518
* $COPYRIGHT$
1619
*
1720
* Additional copyrights may follow
@@ -61,9 +64,7 @@ int MPI_Win_set_errhandler(MPI_Win win, MPI_Errhandler errhandler)
6164
/* Ditch the old errhandler, and decrement its refcount. On 64
6265
bits environments we have to make sure the reading of the
6366
error_handler became atomic. */
64-
do {
65-
tmp = win->error_handler;
66-
} while (!OPAL_ATOMIC_CMPSET(&(win->error_handler), tmp, errhandler));
67+
tmp = OPAL_ATOMIC_SWAP_PTR(&win->error_handler, errhandler);
6768
OBJ_RELEASE(tmp);
6869

6970
/* All done */

opal/class/opal_object.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -10,6 +11,10 @@
1011
* Copyright (c) 2004-2005 The Regents of the University of California.
1112
* All rights reserved.
1213
* Copyright (c) 2007-2014 Cisco Systems, Inc. All rights reserved.
14+
* Copyright (c) 2014 Research Organization for Information Science
15+
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
17+
* reserved.
1318
* $COPYRIGHT$
1419
*
1520
* Additional copyrights may follow
@@ -120,7 +125,7 @@
120125
#include <assert.h>
121126
#include <stdlib.h>
122127

123-
#include "opal/sys/atomic.h"
128+
#include "opal/threads/thread_usage.h"
124129

125130
BEGIN_C_DECLS
126131

@@ -503,7 +508,7 @@ static inline opal_object_t *opal_obj_new(opal_class_t * cls)
503508
static inline int opal_obj_update(opal_object_t *object, int inc) __opal_attribute_always_inline__;
504509
static inline int opal_obj_update(opal_object_t *object, int inc)
505510
{
506-
return opal_atomic_add_32(&(object->obj_reference_count), inc);
511+
return OPAL_THREAD_ADD32(&object->obj_reference_count, inc);
507512
}
508513

509514
END_C_DECLS

opal/threads/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ headers += \
2929
threads/mutex_unix.h \
3030
threads/threads.h \
3131
threads/tsd.h \
32-
threads/wait_sync.h
32+
threads/wait_sync.h \
33+
threads/thread_usage.h
3334

3435
lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += \
3536
threads/condition.c \

0 commit comments

Comments
 (0)