File tree Expand file tree Collapse file tree 2 files changed +9
-16
lines changed Expand file tree Collapse file tree 2 files changed +9
-16
lines changed Original file line number Diff line number Diff line change 5858#include "oshmem/shmem/shmem_lock.h"
5959#include "oshmem/runtime/oshmem_shmem_preconnect.h"
6060
61+ extern int oshmem_shmem_globalexit_status ;
62+
6163static int _shmem_finalize (void );
6264
6365int oshmem_shmem_finalize (void )
6466{
6567 int ret = OSHMEM_SUCCESS ;
66- static int32_t finalize_has_already_started = 0 ;
67- int32_t _tmp = 0 ;
6868
69- if (opal_atomic_compare_exchange_strong_32 (& finalize_has_already_started , & _tmp , 1 )
70- && oshmem_shmem_initialized && !oshmem_shmem_aborted ) {
69+ if (oshmem_shmem_initialized && !oshmem_shmem_aborted ) {
7170 /* Should be called first because ompi_mpi_finalize makes orte and opal finalization */
7271 ret = _shmem_finalize ();
7372
74- if ((OSHMEM_SUCCESS == ret ) && ompi_mpi_initialized
75- && !ompi_mpi_finalized ) {
76- PMPI_Comm_free (& oshmem_comm_world );
77- ret = ompi_mpi_finalize ();
78- }
79-
8073 if (OSHMEM_SUCCESS == ret ) {
8174 oshmem_shmem_initialized = false;
8275 }
8376 }
8477
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+
8584 return ret ;
8685}
8786
Original file line number Diff line number Diff line change 2222#include "oshmem/shmem/c/profile/defines.h"
2323#endif
2424
25- extern int oshmem_shmem_globalexit_status ;
26-
2725void 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
You can’t perform that action at this time.
0 commit comments