Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions oshmem/runtime/oshmem_shmem_finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,29 @@
#include "oshmem/shmem/shmem_lock.h"
#include "oshmem/runtime/oshmem_shmem_preconnect.h"

extern int oshmem_shmem_globalexit_status;

static int _shmem_finalize(void);

int oshmem_shmem_finalize(void)
{
int ret = OSHMEM_SUCCESS;
static int32_t finalize_has_already_started = 0;

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

if ((OSHMEM_SUCCESS == ret) && ompi_mpi_initialized
&& !ompi_mpi_finalized) {
PMPI_Comm_free(&oshmem_comm_world);
ret = ompi_mpi_finalize();
}

if (OSHMEM_SUCCESS == ret) {
oshmem_shmem_initialized = false;
}
}

if ((OSHMEM_SUCCESS == ret) && ompi_mpi_initialized
&& !ompi_mpi_finalized && oshmem_shmem_globalexit_status == 0) {
PMPI_Comm_free(&oshmem_comm_world);
ret = ompi_mpi_finalize();
}

return ret;
}

Expand Down
6 changes: 0 additions & 6 deletions oshmem/shmem/c/shmem_finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@
#include "oshmem/shmem/c/profile/defines.h"
#endif

extern int oshmem_shmem_globalexit_status;

void shmem_finalize(void)
{
OPAL_CR_FINALIZE_LIBRARY();
if (oshmem_shmem_globalexit_status != 0)
{
return;
}
oshmem_shmem_finalize();
}