Skip to content

Commit 3cc727f

Browse files
committed
to be squashed: move wait-for-init loop to ompi_mpi_init()
(Note: this commit would have been squashed with the prior commit, but #5092 was accidentally merged before the 2 commits were squashed together) Signed-off-by: Jeff Squyres <[email protected]> (cherry picked from commit 9b9cb5f)
1 parent 8b662b6 commit 3cc727f

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

ompi/runtime/ompi_mpi_init.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,12 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided,
403403
} else if (expected >= OMPI_MPI_STATE_INIT_STARTED) {
404404
// In some cases (e.g., oshmem_shmem_init()), we may call
405405
// ompi_mpi_init() multiple times. In such cases, just
406-
// silently return successfully.
406+
// silently return successfully once the initializing
407+
// thread has completed.
407408
if (reinit_ok) {
409+
while (ompi_mpi_state < OMPI_MPI_STATE_INIT_COMPLETED) {
410+
usleep(1);
411+
}
408412
return MPI_SUCCESS;
409413
}
410414

oshmem/runtime/oshmem_shmem_init.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,6 @@ int oshmem_shmem_init(int argc, char **argv, int requested, int *provided)
146146
if (!oshmem_shmem_initialized) {
147147
ret = ompi_mpi_init(argc, argv, requested, provided, true);
148148

149-
// It's posible that another thread is initializing MPI and
150-
// has not completed yet. Keep checking until it is
151-
// completed.
152-
while (ompi_mpi_state < OMPI_MPI_STATE_INIT_COMPLETED) {
153-
usleep(1);
154-
}
155-
156149
if (OSHMEM_SUCCESS != ret) {
157150
return ret;
158151
}

0 commit comments

Comments
 (0)