From 9eea1c4dbd23ae41e7de06d5788e29d00da235ea Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 6 Jun 2018 05:35:19 -0700 Subject: [PATCH] to be squashed: move wait-for-init loop to ompi_mpi_init() (Note: this commit would have been squashed with the prior commit, but https://github.com/open-mpi/ompi/pull/5092 was accidentally merged before the 2 commits were squashed together) Signed-off-by: Jeff Squyres (cherry picked from commit 9b9cb5fef078cab9a74069f7ae238ff68f2ad167) --- ompi/runtime/ompi_mpi_init.c | 6 +++++- oshmem/runtime/oshmem_shmem_init.c | 7 ------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ompi/runtime/ompi_mpi_init.c b/ompi/runtime/ompi_mpi_init.c index a456f02a8e4..8a45aa52d5f 100644 --- a/ompi/runtime/ompi_mpi_init.c +++ b/ompi/runtime/ompi_mpi_init.c @@ -398,8 +398,12 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided, } else if (expected >= OMPI_MPI_STATE_INIT_STARTED) { // In some cases (e.g., oshmem_shmem_init()), we may call // ompi_mpi_init() multiple times. In such cases, just - // silently return successfully. + // silently return successfully once the initializing + // thread has completed. if (reinit_ok) { + while (ompi_mpi_state < OMPI_MPI_STATE_INIT_COMPLETED) { + usleep(1); + } return MPI_SUCCESS; } diff --git a/oshmem/runtime/oshmem_shmem_init.c b/oshmem/runtime/oshmem_shmem_init.c index 9ecd10f1909..da220aa4843 100644 --- a/oshmem/runtime/oshmem_shmem_init.c +++ b/oshmem/runtime/oshmem_shmem_init.c @@ -146,13 +146,6 @@ int oshmem_shmem_init(int argc, char **argv, int requested, int *provided) if (!oshmem_shmem_initialized) { ret = ompi_mpi_init(argc, argv, requested, provided, true); - // It's posible that another thread is initializing MPI and - // has not completed yet. Keep checking until it is - // completed. - while (ompi_mpi_state < OMPI_MPI_STATE_INIT_COMPLETED) { - usleep(1); - } - if (OSHMEM_SUCCESS != ret) { return ret; }