Skip to content

Commit b310add

Browse files
Merge pull request #4550 from ggouaillardet/topic/communicator_c_lock
fix communicator's c_lock usage
2 parents 45db363 + f1778d2 commit b310add

File tree

5 files changed

+24
-31
lines changed

5 files changed

+24
-31
lines changed

ompi/communicator/comm.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,16 +1315,12 @@ int ompi_comm_compare(ompi_communicator_t *comm1, ompi_communicator_t *comm2, in
13151315
int ompi_comm_set_name (ompi_communicator_t *comm, const char *name )
13161316
{
13171317

1318-
#ifdef USE_MUTEX_FOR_COMMS
13191318
OPAL_THREAD_LOCK(&(comm->c_lock));
1320-
#endif
13211319
memset(comm->c_name, 0, MPI_MAX_OBJECT_NAME);
13221320
strncpy(comm->c_name, name, MPI_MAX_OBJECT_NAME);
13231321
comm->c_name[MPI_MAX_OBJECT_NAME - 1] = 0;
13241322
comm->c_flags |= OMPI_COMM_NAMEISSET;
1325-
#ifdef USE_MUTEX_FOR_COMMS
13261323
OPAL_THREAD_UNLOCK(&(comm->c_lock));
1327-
#endif
13281324

13291325
return OMPI_SUCCESS;
13301326
}

ompi/communicator/comm_init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ static void ompi_comm_construct(ompi_communicator_t* comm)
387387
#ifdef OMPI_WANT_PERUSE
388388
comm->c_peruse_handles = NULL;
389389
#endif
390+
OBJ_CONSTRUCT(&comm->c_lock, opal_mutex_t);
390391
}
391392

392393
static void ompi_comm_destruct(ompi_communicator_t* comm)

ompi/mpi/c/comm_get_errhandler.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved.
14-
* Copyright (c) 2015 Research Organization for Information Science
14+
* Copyright (c) 2015-2017 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
1616
* Copyright (c) 2016-2017 Los Alamos National Security, LLC. All rights
1717
* reserved.
@@ -50,27 +50,27 @@ int MPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler *errhandler)
5050

5151
OPAL_CR_NOOP_PROGRESS();
5252

53-
/* Error checking */
53+
/* Error checking */
5454

55-
if (MPI_PARAM_CHECK) {
56-
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
57-
if (ompi_comm_invalid(comm)) {
58-
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
59-
FUNC_NAME);
60-
} else if (NULL == errhandler) {
61-
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
62-
FUNC_NAME);
55+
if (MPI_PARAM_CHECK) {
56+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
57+
if (ompi_comm_invalid(comm)) {
58+
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
59+
FUNC_NAME);
60+
} else if (NULL == errhandler) {
61+
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
62+
FUNC_NAME);
63+
}
6364
}
64-
}
6565

66-
opal_mutex_lock (&comm->c_lock);
67-
/* Retain the errhandler, corresponding to object refcount decrease
68-
in errhandler_free.c. */
69-
OBJ_RETAIN(comm->error_handler);
70-
*errhandler = comm->error_handler;
71-
opal_mutex_unlock (&comm->c_lock);
66+
OPAL_THREAD_LOCK(&(comm->c_lock));
67+
/* Retain the errhandler, corresponding to object refcount decrease
68+
in errhandler_free.c. */
69+
OBJ_RETAIN(comm->error_handler);
70+
*errhandler = comm->error_handler;
71+
OPAL_THREAD_UNLOCK(&(comm->c_lock));
7272

73-
/* All done */
73+
/* All done */
7474

75-
return MPI_SUCCESS;
75+
return MPI_SUCCESS;
7676
}

ompi/mpi/c/comm_get_name.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2006-2008 Cisco Systems, Inc. All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
13+
* Copyright (c) 2015-2017 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
@@ -60,9 +60,7 @@ int MPI_Comm_get_name(MPI_Comm comm, char *name, int *length)
6060
return OMPI_ERRHANDLER_INVOKE ( comm, MPI_ERR_ARG,
6161
FUNC_NAME);
6262
}
63-
#ifdef USE_MUTEX_FOR_COMMS
6463
OPAL_THREAD_LOCK(&(comm->c_lock));
65-
#endif
6664
/* Note that MPI-2.1 requires:
6765
- terminating the string with a \0
6866
- name[*resultlen] == '\0'
@@ -80,9 +78,7 @@ int MPI_Comm_get_name(MPI_Comm comm, char *name, int *length)
8078
name[0] = '\0';
8179
*length = 0;
8280
}
83-
#ifdef USE_MUTEX_FOR_COMMS
8481
OPAL_THREAD_UNLOCK(&(comm->c_lock));
85-
#endif
8682

8783
return MPI_SUCCESS;
8884
}

ompi/mpi/c/comm_set_errhandler.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
13+
* Copyright (c) 2015-2017 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2016-2017 Los Alamos National Security, LLC. All rights
1616
* reserved.
@@ -69,12 +69,12 @@ int MPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler)
6969
/* Prepare the new error handler */
7070
OBJ_RETAIN(errhandler);
7171

72-
opal_mutex_lock (&comm->c_lock);
72+
OPAL_THREAD_LOCK(&(comm->c_lock));
7373
/* Ditch the old errhandler, and decrement its refcount. */
7474
tmp = comm->error_handler;
7575
comm->error_handler = errhandler;
7676
OBJ_RELEASE(tmp);
77-
opal_mutex_unlock (&comm->c_lock);
77+
OPAL_THREAD_UNLOCK(&(comm->c_lock));
7878

7979
/* All done */
8080
return MPI_SUCCESS;

0 commit comments

Comments
 (0)