fix communicator's c_lock usage
- initialize c_lock in the ompi_communicator_t constructor - USE_OPAL_THREAD_[UN]LOCK(c_lock) - #ifdef USE_MUTEX_FOR_COMMS protect c_lock access Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
Этот коммит содержится в:
родитель
45db3637af
Коммит
7c3e675479
@ -387,6 +387,9 @@ static void ompi_comm_construct(ompi_communicator_t* comm)
|
||||
#ifdef OMPI_WANT_PERUSE
|
||||
comm->c_peruse_handles = NULL;
|
||||
#endif
|
||||
#ifdef USE_MUTEX_FOR_COMMS
|
||||
OBJ_CONSTRUCT(&comm->c_lock, opal_mutex_t);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ompi_comm_destruct(ompi_communicator_t* comm)
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* Copyright (c) 2015-2017 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* Copyright (c) 2016-2017 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
@ -63,12 +63,16 @@ int MPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler *errhandler)
|
||||
}
|
||||
}
|
||||
|
||||
opal_mutex_lock (&comm->c_lock);
|
||||
#ifdef USE_MUTEX_FOR_COMMS
|
||||
OPAL_THREAD_LOCK(&(comm->c_lock));
|
||||
#endif
|
||||
/* Retain the errhandler, corresponding to object refcount decrease
|
||||
in errhandler_free.c. */
|
||||
OBJ_RETAIN(comm->error_handler);
|
||||
*errhandler = comm->error_handler;
|
||||
opal_mutex_unlock (&comm->c_lock);
|
||||
#ifdef USE_MUTEX_FOR_COMMS
|
||||
OPAL_THREAD_UNLOCK(&(comm->c_lock));
|
||||
#endif
|
||||
|
||||
/* All done */
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* Copyright (c) 2015-2017 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
* Copyright (c) 2016-2017 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
@ -69,12 +69,16 @@ int MPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler)
|
||||
/* Prepare the new error handler */
|
||||
OBJ_RETAIN(errhandler);
|
||||
|
||||
opal_mutex_lock (&comm->c_lock);
|
||||
#ifdef USE_MUTEX_FOR_COMMS
|
||||
OPAL_THREAD_LOCK(&(comm->c_lock));
|
||||
#endif
|
||||
/* Ditch the old errhandler, and decrement its refcount. */
|
||||
tmp = comm->error_handler;
|
||||
comm->error_handler = errhandler;
|
||||
OBJ_RELEASE(tmp);
|
||||
opal_mutex_unlock (&comm->c_lock);
|
||||
#ifdef USE_MUTEX_FOR_COMMS
|
||||
OPAL_THREAD_UNLOCK(&(comm->c_lock));
|
||||
#endif
|
||||
|
||||
/* All done */
|
||||
return MPI_SUCCESS;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user