1
1

Merge pull request #4550 from ggouaillardet/topic/communicator_c_lock

fix communicator's c_lock usage
Этот коммит содержится в:
Gilles Gouaillardet 2017-11-30 15:58:20 +09:00 коммит произвёл GitHub
родитель 45db3637af f1778d2778
Коммит b310add995
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 24 добавлений и 31 удалений

Просмотреть файл

@ -1315,16 +1315,12 @@ int ompi_comm_compare(ompi_communicator_t *comm1, ompi_communicator_t *comm2, in
int ompi_comm_set_name (ompi_communicator_t *comm, const char *name )
{
#ifdef USE_MUTEX_FOR_COMMS
OPAL_THREAD_LOCK(&(comm->c_lock));
#endif
memset(comm->c_name, 0, MPI_MAX_OBJECT_NAME);
strncpy(comm->c_name, name, MPI_MAX_OBJECT_NAME);
comm->c_name[MPI_MAX_OBJECT_NAME - 1] = 0;
comm->c_flags |= OMPI_COMM_NAMEISSET;
#ifdef USE_MUTEX_FOR_COMMS
OPAL_THREAD_UNLOCK(&(comm->c_lock));
#endif
return OMPI_SUCCESS;
}

Просмотреть файл

@ -387,6 +387,7 @@ static void ompi_comm_construct(ompi_communicator_t* comm)
#ifdef OMPI_WANT_PERUSE
comm->c_peruse_handles = NULL;
#endif
OBJ_CONSTRUCT(&comm->c_lock, opal_mutex_t);
}
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.
@ -50,27 +50,27 @@ int MPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler *errhandler)
OPAL_CR_NOOP_PROGRESS();
/* Error checking */
/* Error checking */
if (MPI_PARAM_CHECK) {
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
FUNC_NAME);
} else if (NULL == errhandler) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
FUNC_NAME);
if (MPI_PARAM_CHECK) {
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
FUNC_NAME);
} else if (NULL == errhandler) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
FUNC_NAME);
}
}
}
opal_mutex_lock (&comm->c_lock);
/* 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);
OPAL_THREAD_LOCK(&(comm->c_lock));
/* Retain the errhandler, corresponding to object refcount decrease
in errhandler_free.c. */
OBJ_RETAIN(comm->error_handler);
*errhandler = comm->error_handler;
OPAL_THREAD_UNLOCK(&(comm->c_lock));
/* All done */
/* All done */
return MPI_SUCCESS;
return MPI_SUCCESS;
}

Просмотреть файл

@ -10,7 +10,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006-2008 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$
*
@ -60,9 +60,7 @@ int MPI_Comm_get_name(MPI_Comm comm, char *name, int *length)
return OMPI_ERRHANDLER_INVOKE ( comm, MPI_ERR_ARG,
FUNC_NAME);
}
#ifdef USE_MUTEX_FOR_COMMS
OPAL_THREAD_LOCK(&(comm->c_lock));
#endif
/* Note that MPI-2.1 requires:
- terminating the string with a \0
- name[*resultlen] == '\0'
@ -80,9 +78,7 @@ int MPI_Comm_get_name(MPI_Comm comm, char *name, int *length)
name[0] = '\0';
*length = 0;
}
#ifdef USE_MUTEX_FOR_COMMS
OPAL_THREAD_UNLOCK(&(comm->c_lock));
#endif
return MPI_SUCCESS;
}

Просмотреть файл

@ -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,12 @@ 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);
OPAL_THREAD_LOCK(&(comm->c_lock));
/* 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);
OPAL_THREAD_UNLOCK(&(comm->c_lock));
/* All done */
return MPI_SUCCESS;