diff --git a/control/context.c b/control/context.c index 323e9908caa02d0faa9c09be0b0019d2472c2363..ae3d63b015656a61de36f7d63478d23ccfe1303d 100644 --- a/control/context.c +++ b/control/context.c @@ -105,7 +105,7 @@ int morse_context_destroy(){ RUNTIME_context_destroy(morse_ctxt); free(morse_ctxt); morse_ctxt = NULL; - + return MORSE_SUCCESS; } @@ -163,7 +163,7 @@ int MORSE_Enable(MORSE_enum option) case MORSE_BOUND: break; } - + /* Enable at the lower level if required */ RUNTIME_enable( option ); @@ -221,7 +221,7 @@ int MORSE_Disable(MORSE_enum option) morse_error("MORSE_Disable", "illegal parameter value"); return MORSE_ERR_ILLEGAL_VALUE; } - + /* Disable at the lower level if required */ RUNTIME_disable( option ); diff --git a/control/control.c b/control/control.c index 592a844fac73c43116d0a0fc4fdfda391443781e..480bf89a1600741879cd8a2828be91dca4dc1938 100644 --- a/control/control.c +++ b/control/control.c @@ -192,6 +192,53 @@ int MORSE_My_Mpi_Rank(void) } return MORSE_MPI_RANK; #else - return 0; + return MORSE_SUCCESS; #endif } + +/******************************************************************************* + * + * @ingroup Auxiliary + * + * MORSE_Pause - Suspend MORSE runtime to poll for new tasks. + * + ******************************************************************************* + * + * @return + * \retval MORSE_SUCCESS successful exit + * + ******************************************************************************/ +int MORSE_Pause(void) +{ + MORSE_context_t *morse = morse_context_self(); + if (morse == NULL) { + morse_error("MORSE_Pause()", "MORSE not initialized"); + return MORSE_ERR_NOT_INITIALIZED; + } + RUNTIME_pause(morse); + return MORSE_SUCCESS; +} + +/******************************************************************************* + * + * @ingroup Auxiliary + * + * MORSE_Resume - Symmetrical call to MORSE_Pause, + * used to resume the workers polling for new tasks. + * + ******************************************************************************* + * + * @return + * \retval MORSE_SUCCESS successful exit + * + ******************************************************************************/ +int MORSE_Resume(void) +{ + MORSE_context_t *morse = morse_context_self(); + if (morse == NULL) { + morse_error("MORSE_Resume()", "MORSE not initialized"); + return MORSE_ERR_NOT_INITIALIZED; + } + RUNTIME_resume(morse); + return MORSE_SUCCESS; +} diff --git a/docs/texinfo/chapters/using.texi b/docs/texinfo/chapters/using.texi index 8bd5a99b2fb27cf85a7d3aea444a9dfc0741e32b..db544254ae2f2ff0ad5a8b0efc64f708a5e4f605 100644 --- a/docs/texinfo/chapters/using.texi +++ b/docs/texinfo/chapters/using.texi @@ -742,6 +742,17 @@ Return the MPI rank of the calling process. int MORSE_My_Mpi_Rank (void); @end verbatim +Suspend MORSE runtime to poll for new tasks, to avoid useless CPU consumption when +no tasks have to be executed by MORSE runtime system. +@verbatim +int MORSE_Pause (void); +@end verbatim + +Symmetrical call to MORSE_Pause, used to resume the workers polling for new tasks. +@verbatim +int MORSE_Resume (void); +@end verbatim + Conversion from LAPACK layout to tile layout. @verbatim int MORSE_Lapack_to_Tile (void *Af77, int LDA, MORSE_desc_t *A); @@ -834,7 +845,7 @@ Create a sequence. int MORSE_Sequence_Create (MORSE_sequence_t **sequence); @end verbatim -Destroy a squence. +Destroy a sequence. @verbatim int MORSE_Sequence_Destroy (MORSE_sequence_t *sequence); @end verbatim diff --git a/include/morse.h b/include/morse.h index b15c482f5f92dacbacb0e5f4c911be8f2cb82145..09e4907d99694e5a2c3e2b992faf9039a2f1501d 100644 --- a/include/morse.h +++ b/include/morse.h @@ -77,6 +77,8 @@ int MORSE_Init (int nworkers, int ncudas); int MORSE_InitPar (int nworkers, int ncudas, int nthreads_per_worker); int MORSE_Finalize (void); int MORSE_My_Mpi_Rank (void); +int MORSE_Pause (void); +int MORSE_Resume (void); int MORSE_Lapack_to_Tile (void *Af77, int LDA, MORSE_desc_t *A); int MORSE_Tile_to_Lapack (MORSE_desc_t *A, void *Af77, int LDA); diff --git a/include/runtime.h b/include/runtime.h index 2651ccf6eac3e68d12cb6390c3e2426b252edd27..73de779a271bd7359f2b64427f48e11e25f88a45 100644 --- a/include/runtime.h +++ b/include/runtime.h @@ -52,6 +52,8 @@ int RUNTIME_rank (MORSE_context_t*); int RUNTIME_init_scheduler (MORSE_context_t*, int, int, int); void RUNTIME_finalize_scheduler (MORSE_context_t*); void RUNTIME_barrier (MORSE_context_t*); +void RUNTIME_pause (MORSE_context_t*); +void RUNTIME_resume (MORSE_context_t*); /******************************************************************************* * RUNTIME Descriptor @@ -77,12 +79,6 @@ int RUNTIME_options_ws_free (MORSE_option_t*); /* int RUNTIME_options_ws_gethost (MORSE_option_t*); */ /* int RUNTIME_options_ws_getdevice (MORSE_option_t*); */ -/******************************************************************************* - * RUNTIME Profiling - **/ -void RUNTIME_schedprofile_display (); -void RUNTIME_kernelprofile_display(); - /******************************************************************************* * RUNTIME Locality **/ @@ -110,6 +106,8 @@ void RUNTIME_slocality_onerestore (MORSE_kernel_t); /******************************************************************************* * RUNTIME Profiling **/ +void RUNTIME_schedprofile_display (); +void RUNTIME_kernelprofile_display(); double RUNTIME_get_time(); void RUNTIME_start_profiling(); diff --git a/runtime/quark/control/control.c b/runtime/quark/control/control.c index 93bc317ef50ddeb79c52ad0331de077ed11441c5..1e7722dd26d0486558909fb48620abfe39559a70 100644 --- a/runtime/quark/control/control.c +++ b/runtime/quark/control/control.c @@ -67,3 +67,22 @@ void RUNTIME_finalize_scheduler(MORSE_context_t *morse) QUARK_Delete((Quark*)(morse->schedopt)); return; } + +/******************************************************************************* + * To suspend the processing of new tasks by workers + **/ +void RUNTIME_pause( MORSE_context_t *morse ) +{ + (void)morse; + return; +} + +/******************************************************************************* + * This is the symmetrical call to RUNTIME_pause, + * used to resume the workers polling for new tasks. + **/ +void RUNTIME_resume( MORSE_context_t *morse ) +{ + (void)morse; + return; +} diff --git a/runtime/starpu/control/control.c b/runtime/starpu/control/control.c index 330817db4a58e41f3aaa307549ef3435a1ace780..9208e694275684d1b88494af83b503caf8dba5f6 100644 --- a/runtime/starpu/control/control.c +++ b/runtime/starpu/control/control.c @@ -144,3 +144,24 @@ void RUNTIME_barrier( MORSE_context_t *morse ) starpu_mpi_barrier(MPI_COMM_WORLD); #endif } + +/******************************************************************************* + * To suspend the processing of new tasks by workers + **/ +void RUNTIME_pause( MORSE_context_t *morse ) +{ + (void)morse; + starpu_pause(); + return; +} + +/******************************************************************************* + * This is the symmetrical call to RUNTIME_pause, + * used to resume the workers polling for new tasks. + **/ +void RUNTIME_resume( MORSE_context_t *morse ) +{ + (void)morse; + starpu_resume(); + return; +} diff --git a/timing/time_zpotri_tile.c b/timing/time_zpotri_tile.c index c1c5e6cccbdb0df03630b68a15311e62373c2508..8941c06082a641b0e19dffec1e2870cc68498b35 100644 --- a/timing/time_zpotri_tile.c +++ b/timing/time_zpotri_tile.c @@ -43,7 +43,7 @@ RunTest(int *iparam, double *dparam, morse_time_t *t_) * the function we want to trace */ MORSE_zplghe_Tile( (double)N, descA, 51 ); - + /* MORSE ZPOTRF / ZTRTRI / ZLAUUM */ /* * Example of the different way to combine several asynchonous calls @@ -51,23 +51,23 @@ RunTest(int *iparam, double *dparam, morse_time_t *t_) #if defined(TRACE_BY_SEQUENCE) { MORSE_sequence_t *sequence[3]; - MORSE_request_t request[3] = { MORSE_REQUEST_INITIALIZER, - MORSE_REQUEST_INITIALIZER, - MORSE_REQUEST_INITIALIZER }; - + MORSE_request_t request[3] = { MORSE_REQUEST_INITIALIZER, + MORSE_REQUEST_INITIALIZER, + MORSE_REQUEST_INITIALIZER }; + MORSE_Sequence_Create(&sequence[0]); MORSE_Sequence_Create(&sequence[1]); MORSE_Sequence_Create(&sequence[2]); - + if ( ! iparam[IPARAM_ASYNC] ) { START_TIMING(); MORSE_zpotrf_Tile_Async(uplo, descA, sequence[0], &request[0]); MORSE_Sequence_Wait(sequence[0]); - + MORSE_ztrtri_Tile_Async(uplo, MorseNonUnit, descA, sequence[1], &request[1]); MORSE_Sequence_Wait(sequence[1]); - + MORSE_zlauum_Tile_Async(uplo, descA, sequence[2], &request[2]); MORSE_Sequence_Wait(sequence[2]); MORSE_Desc_Getoncpu( descA ); @@ -86,11 +86,11 @@ RunTest(int *iparam, double *dparam, morse_time_t *t_) MORSE_Desc_Getoncpu( descA ); STOP_TIMING(); } - + MORSE_Sequence_Destroy(sequence[0]); MORSE_Sequence_Destroy(sequence[1]); MORSE_Sequence_Destroy(sequence[2]); - } + } #else { if ( ! iparam[IPARAM_ASYNC] ) { @@ -105,9 +105,9 @@ RunTest(int *iparam, double *dparam, morse_time_t *t_) /* Default: we use Asynchonous call with only one sequence */ MORSE_sequence_t *sequence; - MORSE_request_t request[2] = { MORSE_REQUEST_INITIALIZER, - MORSE_REQUEST_INITIALIZER }; - + MORSE_request_t request[2] = { MORSE_REQUEST_INITIALIZER, + MORSE_REQUEST_INITIALIZER }; + START_TIMING(); MORSE_Sequence_Create(&sequence); MORSE_zpotrf_Tile_Async(uplo, descA, sequence, &request[0]); @@ -115,12 +115,12 @@ RunTest(int *iparam, double *dparam, morse_time_t *t_) MORSE_Sequence_Wait(sequence); MORSE_Desc_Getoncpu( descA ); STOP_TIMING(); - - MORSE_Sequence_Destroy(sequence); + + MORSE_Sequence_Destroy(sequence); } } #endif - + /* Check the solution */ if ( check ) {