Skip to content

Commit ac3a441

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 c02c491 commit ac3a441

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
@@ -397,8 +397,12 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided,
397397
} else if (expected >= OMPI_MPI_STATE_INIT_STARTED) {
398398
// In some cases (e.g., oshmem_shmem_init()), we may call
399399
// ompi_mpi_init() multiple times. In such cases, just
400-
// silently return successfully.
400+
// silently return successfully once the initializing
401+
// thread has completed.
401402
if (reinit_ok) {
403+
while (ompi_mpi_state < OMPI_MPI_STATE_INIT_COMPLETED) {
404+
usleep(1);
405+
}
402406
return MPI_SUCCESS;
403407
}
404408

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)