Skip to content

Commit 1888b16

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 ed4e5a2 commit 1888b16

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

ompi/runtime/ompi_mpi_init.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,12 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided,
398398
} else if (expected >= OMPI_MPI_STATE_INIT_STARTED) {
399399
// In some cases (e.g., oshmem_shmem_init()), we may call
400400
// ompi_mpi_init() multiple times. In such cases, just
401-
// silently return successfully.
401+
// silently return successfully once the initializing
402+
// thread has completed.
402403
if (reinit_ok) {
404+
while (ompi_mpi_state < OMPI_MPI_STATE_INIT_COMPLETED) {
405+
usleep(1);
406+
}
403407
return MPI_SUCCESS;
404408
}
405409

oshmem/runtime/oshmem_shmem_init.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,7 @@ int oshmem_shmem_init(int argc, char **argv, int requested, int *provided)
145145

146146
if (!oshmem_shmem_initialized) {
147147
ret = ompi_mpi_init(argc, argv, requested, provided, true);
148-
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-
}
148+
OMPI_TIMING_NEXT("ompi_mpi_init");
155149

156150
if (OSHMEM_SUCCESS != ret) {
157151
return ret;

0 commit comments

Comments
 (0)