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

Fix performance regression caused by enabling opal thread support #1287

Merged
merged 2 commits into from
Aug 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ompi/mca/osc/sm/osc_sm_active_target.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 Sandia National Laboratories. All rights reserved.
* Copyright (c) 2014-2015 Los Alamos National Security, LLC. All rights
* Copyright (c) 2014-2016 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2014 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
Expand Down Expand Up @@ -133,7 +133,7 @@ ompi_osc_sm_start(struct ompi_group_t *group,

OBJ_RETAIN(group);

if (!OPAL_ATOMIC_CMPSET(&module->start_group, NULL, group)) {
if (!OPAL_ATOMIC_CMPSET_PTR(&module->start_group, NULL, group)) {
OBJ_RELEASE(group);
return OMPI_ERR_RMA_SYNC;
}
Expand Down Expand Up @@ -185,7 +185,7 @@ ompi_osc_sm_complete(struct ompi_win_t *win)
opal_atomic_mb();

group = module->start_group;
if (NULL == group || !OPAL_ATOMIC_CMPSET(&module->start_group, group, NULL)) {
if (NULL == group || !OPAL_ATOMIC_CMPSET_PTR(&module->start_group, group, NULL)) {
return OMPI_ERR_RMA_SYNC;
}

Expand Down
5 changes: 4 additions & 1 deletion ompi/mpi/c/comm_get_errhandler.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -12,6 +13,8 @@
* Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -64,7 +67,7 @@ int MPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler *errhandler)
error_handler became atomic. */
do {
tmp = comm->error_handler;
} while (!OPAL_ATOMIC_CMPSET(&(comm->error_handler), tmp, tmp));
} while (!OPAL_ATOMIC_CMPSET_PTR(&(comm->error_handler), tmp, tmp));

/* Retain the errhandler, corresponding to object refcount decrease
in errhandler_free.c. */
Expand Down
7 changes: 4 additions & 3 deletions ompi/mpi/c/comm_set_errhandler.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -11,6 +12,8 @@
* All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -67,9 +70,7 @@ int MPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler)
/* Ditch the old errhandler, and decrement its refcount. On 64
bits environments we have to make sure the reading of the
error_handler became atomic. */
do {
tmp = comm->error_handler;
} while (!OPAL_ATOMIC_CMPSET(&(comm->error_handler), tmp, errhandler));
tmp = OPAL_ATOMIC_SWAP_PTR(&comm->error_handler, errhandler);
OBJ_RELEASE(tmp);

/* All done */
Expand Down
5 changes: 4 additions & 1 deletion ompi/mpi/c/file_get_errhandler.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -12,6 +13,8 @@
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -63,7 +66,7 @@ int MPI_File_get_errhandler( MPI_File file, MPI_Errhandler *errhandler)
error_handler became atomic. */
do {
tmp = file->error_handler;
} while (!OPAL_ATOMIC_CMPSET(&(file->error_handler), tmp, tmp));
} while (!OPAL_ATOMIC_CMPSET_PTR(&(file->error_handler), tmp, tmp));

/* Retain the errhandler, corresponding to object refcount
decrease in errhandler_free.c. */
Expand Down
7 changes: 4 additions & 3 deletions ompi/mpi/c/file_set_errhandler.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -12,6 +13,8 @@
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -66,9 +69,7 @@ int MPI_File_set_errhandler( MPI_File file, MPI_Errhandler errhandler)
/* Ditch the old errhandler, and decrement its refcount. On 64
bits environments we have to make sure the reading of the
error_handler became atomic. */
do {
tmp = file->error_handler;
} while (!OPAL_ATOMIC_CMPSET(&(file->error_handler), tmp, errhandler));
tmp = OPAL_ATOMIC_SWAP_PTR (&file->error_handler, errhandler);
OBJ_RELEASE(tmp);

/* All done */
Expand Down
5 changes: 4 additions & 1 deletion ompi/mpi/c/win_get_errhandler.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -12,6 +13,8 @@
* Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -56,7 +59,7 @@ int MPI_Win_get_errhandler(MPI_Win win, MPI_Errhandler *errhandler)
error_handler became atomic. */
do {
tmp = win->error_handler;
} while (!OPAL_ATOMIC_CMPSET(&(win->error_handler), tmp, tmp));
} while (!OPAL_ATOMIC_CMPSET_PTR(&(win->error_handler), tmp, tmp));

/* Retain the errhandler, corresponding to object refcount
decrease in errhandler_free.c. */
Expand Down
7 changes: 4 additions & 3 deletions ompi/mpi/c/win_set_errhandler.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -12,6 +13,8 @@
* Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -61,9 +64,7 @@ int MPI_Win_set_errhandler(MPI_Win win, MPI_Errhandler errhandler)
/* Ditch the old errhandler, and decrement its refcount. On 64
bits environments we have to make sure the reading of the
error_handler became atomic. */
do {
tmp = win->error_handler;
} while (!OPAL_ATOMIC_CMPSET(&(win->error_handler), tmp, errhandler));
tmp = OPAL_ATOMIC_SWAP_PTR(&win->error_handler, errhandler);
OBJ_RELEASE(tmp);

/* All done */
Expand Down
9 changes: 7 additions & 2 deletions opal/class/opal_object.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -10,6 +11,10 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -120,7 +125,7 @@
#include <assert.h>
#include <stdlib.h>

#include "opal/sys/atomic.h"
#include "opal/threads/thread_usage.h"

BEGIN_C_DECLS

Expand Down Expand Up @@ -503,7 +508,7 @@ static inline opal_object_t *opal_obj_new(opal_class_t * cls)
static inline int opal_obj_update(opal_object_t *object, int inc) __opal_attribute_always_inline__;
static inline int opal_obj_update(opal_object_t *object, int inc)
{
return opal_atomic_add_32(&(object->obj_reference_count), inc);
return OPAL_THREAD_ADD32(&object->obj_reference_count, inc);
}

END_C_DECLS
Expand Down
3 changes: 2 additions & 1 deletion opal/threads/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ headers += \
threads/mutex_unix.h \
threads/threads.h \
threads/tsd.h \
threads/wait_sync.h
threads/wait_sync.h \
threads/thread_usage.h

lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += \
threads/condition.c \
Expand Down
Loading