diff --git a/control/control.c b/control/control.c index 7810c276384c1f00d09139fe5b78cf9429959131..592a844fac73c43116d0a0fc4fdfda391443781e 100644 --- a/control/control.c +++ b/control/control.c @@ -110,7 +110,7 @@ int MORSE_InitPar(int nworkers, int ncudas, int nthreads_per_worker) return MORSE_ERR_NOT_FOUND; } nworkers = morse->world_size; - + /* Get the size of each NUMA node */ morse->group_size = morse_get_numthreads_numa(); while ( ((morse->world_size)%(morse->group_size)) != 0 ) @@ -121,6 +121,7 @@ int MORSE_InitPar(int nworkers, int ncudas, int nthreads_per_worker) { int flag = 0, provided = 0; MPI_Initialized( &flag ); + morse->mpi_outer_init = flag; if ( !flag ) { MPI_Init_thread( NULL, NULL, MPI_THREAD_MULTIPLE, &provided ); } @@ -160,7 +161,8 @@ int MORSE_Finalize(void) morse_context_destroy(); #if defined(CHAMELEON_USE_MPI) MPI_Barrier(MPI_COMM_WORLD); - MPI_Finalize(); + if (!morse->mpi_outer_init) + MPI_Finalize(); #endif return MORSE_SUCCESS; diff --git a/include/morse_struct.h b/include/morse_struct.h index c84b7f88d0e9f152c7ebcfeccca0b6ecf33f73e5..75c686a04ecbcad86eb90ccb8eca128256d3171b 100644 --- a/include/morse_struct.h +++ b/include/morse_struct.h @@ -139,7 +139,8 @@ typedef struct morse_context_s { int nbnbsize; // tile size in elements (possibly padded) int ibnbsize; // T or L tile size in elements (---''---) int rhblock; // block size for tree-based (reduction) Householder - void *schedopt; + void *schedopt; // structure for runtimes + int mpi_outer_init; // MPI has been initialized outside our functions } MORSE_context_t;