diff --git a/control/control.c b/control/control.c index 39199bc0636ccd639c64d5021d9b5c89306b1d14..7810c276384c1f00d09139fe5b78cf9429959131 100644 --- a/control/control.c +++ b/control/control.c @@ -122,7 +122,7 @@ int MORSE_InitPar(int nworkers, int ncudas, int nthreads_per_worker) int flag = 0, provided = 0; MPI_Initialized( &flag ); if ( !flag ) { - MPI_Init_thread( NULL, NULL, MPI_THREAD_MULTIPLE, &provided ); + MPI_Init_thread( NULL, NULL, MPI_THREAD_MULTIPLE, &provided ); } } #endif diff --git a/control/descriptor.c b/control/descriptor.c index 174229ea80d1b88e0f8693a8b5a1b40015011ca4..b0ed101444b101c6e82ed8018e6e46bdc17a5e18 100644 --- a/control/descriptor.c +++ b/control/descriptor.c @@ -66,6 +66,7 @@ MORSE_desc_t morse_desc_init(MORSE_enum dtyp, int mb, int nb, int bsiz, desc.id = nbdesc; nbdesc++; desc.occurences = 0; desc.use_mat = 1; + desc.alloc_mat = 1; desc.register_mat = 1; #if defined(CHAMELEON_USE_MPI) @@ -157,6 +158,7 @@ MORSE_desc_t morse_desc_init_user(MORSE_enum dtyp, int mb, int nb, int bsiz, desc.id = nbdesc; nbdesc++; desc.occurences = 0; desc.use_mat = 1; + desc.alloc_mat = 1; desc.register_mat = 1; #if defined(CHAMELEON_USE_MPI) @@ -316,7 +318,9 @@ int morse_desc_mat_free( MORSE_desc_t *desc ) RUNTIME_desc_destroy( desc ); - if (desc->mat != NULL && desc->use_mat == 1) { + if (desc->mat != NULL && + desc->use_mat == 1 && + desc->alloc_mat == 1) { #ifndef CHAMELEON_SIMULATION free(desc->mat); #endif @@ -417,6 +421,8 @@ int MORSE_Desc_Create(MORSE_desc_t **desc, void *mat, MORSE_enum dtyp, int mb, i } else { (**desc).mat = mat; + /* memory of the matrix is handle by users */ + (**desc).alloc_mat = 0; } /* Create scheduler structure like registering data */ @@ -511,6 +517,9 @@ int MORSE_Desc_Create_User(MORSE_desc_t **desc, void *mat, MORSE_enum dtyp, int /* if the user gives a pointer to the overall data (tiles) we can use it */ (**desc).use_mat = (mat == NULL) ? 0 : 1; + /* memory of the matrix is handle by users */ + (**desc).alloc_mat = 0; + /* users data can have multiple forms: let him register tiles */ (**desc).register_mat = 0; diff --git a/include/morse_struct.h b/include/morse_struct.h index 6c2ca7d4cdedf1b99a5f4a382508133194f0d7b2..c84b7f88d0e9f152c7ebcfeccca0b6ecf33f73e5 100644 --- a/include/morse_struct.h +++ b/include/morse_struct.h @@ -102,6 +102,7 @@ struct morse_desc_s { // submatrix desc (occurances>1) to avoid unregistering // GPU data twice int use_mat; // 1 if we have a pointer to the overall data mat - else 0 + int alloc_mat; // 1 if we handle the allocation of mat - else 0 int register_mat; // 1 if we have to register mat - else 0 (handled by the application) int myrank; // MPI rank of the descriptor void *schedopt; // scheduler (QUARK|StarPU) specific structure