Skip to content

Commit 19df286

Browse files
committed
ompi/oshmem: fix bug in shmem_finalize.
cherry picked from commit e87cb25 Signed-off-by: Xin Zhao <[email protected]>
1 parent 2631789 commit 19df286

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

oshmem/runtime/oshmem_shmem_finalize.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,29 @@
5858
#include "oshmem/shmem/shmem_lock.h"
5959
#include "oshmem/runtime/oshmem_shmem_preconnect.h"
6060

61+
extern int oshmem_shmem_globalexit_status;
62+
6163
static int _shmem_finalize(void);
6264

6365
int oshmem_shmem_finalize(void)
6466
{
6567
int ret = OSHMEM_SUCCESS;
66-
static int32_t finalize_has_already_started = 0;
6768

68-
if (opal_atomic_cmpset_32(&finalize_has_already_started, 0, 1)
69-
&& oshmem_shmem_initialized && !oshmem_shmem_aborted) {
69+
if (oshmem_shmem_initialized && !oshmem_shmem_aborted) {
7070
/* Should be called first because ompi_mpi_finalize makes orte and opal finalization */
7171
ret = _shmem_finalize();
7272

73-
if ((OSHMEM_SUCCESS == ret) && ompi_mpi_initialized
74-
&& !ompi_mpi_finalized) {
75-
PMPI_Comm_free(&oshmem_comm_world);
76-
ret = ompi_mpi_finalize();
77-
}
78-
7973
if (OSHMEM_SUCCESS == ret) {
8074
oshmem_shmem_initialized = false;
8175
}
8276
}
8377

78+
if ((OSHMEM_SUCCESS == ret) && ompi_mpi_initialized
79+
&& !ompi_mpi_finalized && oshmem_shmem_globalexit_status == 0) {
80+
PMPI_Comm_free(&oshmem_comm_world);
81+
ret = ompi_mpi_finalize();
82+
}
83+
8484
return ret;
8585
}
8686

oshmem/shmem/c/shmem_finalize.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,9 @@
2222
#include "oshmem/shmem/c/profile/defines.h"
2323
#endif
2424

25-
extern int oshmem_shmem_globalexit_status;
26-
2725
void shmem_finalize(void)
2826
{
2927
OPAL_CR_FINALIZE_LIBRARY();
30-
if (oshmem_shmem_globalexit_status != 0)
31-
{
32-
return;
33-
}
3428
oshmem_shmem_finalize();
3529
}
3630

0 commit comments

Comments
 (0)