From c8155acff7a62184c34e66a661152c7e2ca6cbbc Mon Sep 17 00:00:00 2001 From: Pedro Gonnet <gonnet@google.com> Date: Thu, 1 Nov 2018 10:48:01 +0100 Subject: [PATCH] fix comments, turns out calling mpi_waitany on the same array concurrently is illegal. --- src/proxy.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/proxy.c b/src/proxy.c index ed42717d1c..d28f3d3b33 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -328,6 +328,11 @@ void proxy_cells_wait_and_unpack_mapper(void *unused_map_data, int num_elements, int pid = MPI_UNDEFINED; MPI_Status status; int res; + + /* We need a lock to prevent concurrent calls to MPI_Waitany on + the same array of requests since this is not supported in the MPI + standard (v3.1). This is not really a problem since the threads + would block inside MPI_Waitany anyway. */ lock_lock(&data->lock); if ((res = MPI_Waitany(data->num_proxies, data->reqs_in, &pid, &status)) != MPI_SUCCESS || @@ -336,6 +341,7 @@ void proxy_cells_wait_and_unpack_mapper(void *unused_map_data, int num_elements, if (lock_unlock(&data->lock) != 0) { error("Failed to release lock."); } + // message( "cell data from proxy %i has arrived." , pid ); for (int count = 0, j = 0; j < data->proxies[pid].nr_cells_in; j++) count += cell_unpack(&data->proxies[pid].pcells_in[count], @@ -435,9 +441,6 @@ void proxy_cells_exchange(struct proxy *proxies, int num_proxies, tic2 = getticks(); /* Wait for each pcell array to come in from the proxies. */ - /* TODO(pedro): This struct currently contains a lock to avoid calling - MPI_Waitany in parallel (https://github.com/open-mpi/ompi/issues/6004). - This should be removed once this works corectly in OpenMPI and IntelMPI. */ struct wait_and_unpack_mapper_data wait_and_unpack_data = { s, num_proxies, reqs_in, proxies, with_gravity, lock_static_initializer}; threadpool_map(&s->e->threadpool, proxy_cells_wait_and_unpack_mapper, -- GitLab