diff --git a/control/context.c b/control/context.c index 1861bf6a499e2b55efa60ab7fcb27a59ad76824e..38d8920367593e569a6ed79ab4ca010447f4da1b 100644 --- a/control/context.c +++ b/control/context.c @@ -77,11 +77,12 @@ MORSE_context_t *morse_context_create() morse->ncudas = 0; morse->nthreads_per_worker= 1; - morse->errors_enabled = MORSE_FALSE; - morse->warnings_enabled = MORSE_FALSE; - morse->autotuning_enabled = MORSE_TRUE; - morse->parallel_enabled = MORSE_FALSE; - morse->profiling_enabled = MORSE_FALSE; + morse->errors_enabled = MORSE_FALSE; + morse->warnings_enabled = MORSE_FALSE; + morse->autotuning_enabled = MORSE_TRUE; + morse->parallel_enabled = MORSE_FALSE; + morse->profiling_enabled = MORSE_FALSE; + morse->progress_enabled = MORSE_FALSE; morse->householder = MORSE_FLAT_HOUSEHOLDER; morse->translation = MORSE_OUTOFPLACE; @@ -130,6 +131,7 @@ int morse_context_destroy(){ * @arg MORSE_ERRORS printing of error messages, * @arg MORSE_AUTOTUNING autotuning for tile size and inner block size. * @arg MORSE_PROFILING_MODE activate profiling of kernels + * @arg MORSE_PROGRESS activate progress indicator * ******************************************************************************* * @@ -161,6 +163,9 @@ int MORSE_Enable(MORSE_enum option) case MORSE_PROFILING_MODE: morse->profiling_enabled = MORSE_TRUE; break; + case MORSE_PROGRESS: + morse->progress_enabled = MORSE_TRUE; + break; /* case MORSE_PARALLEL: */ /* morse->parallel_enabled = MORSE_TRUE; */ /* break; */ @@ -190,7 +195,8 @@ int MORSE_Enable(MORSE_enum option) * @arg MORSE_WARNINGS printing of warning messages, * @arg MORSE_ERRORS printing of error messages, * @arg MORSE_AUTOTUNING autotuning for tile size and inner block size. - * @arg MORSE_PROFILING_MODE activate profiling of kernels + * @arg MORSE_PROFILING_MODE deactivate profiling of kernels + * @arg MORSE_PROGRESS deactivate progress indicator * ******************************************************************************* * @@ -221,6 +227,9 @@ int MORSE_Disable(MORSE_enum option) case MORSE_PROFILING_MODE: morse->profiling_enabled = MORSE_FALSE; break; + case MORSE_PROGRESS: + morse->progress_enabled = MORSE_FALSE; + break; case MORSE_PARALLEL_MODE: morse->parallel_enabled = MORSE_FALSE; break; diff --git a/include/morse_constants.h b/include/morse_constants.h index 5c6b73a8503c107d67b8ba07bda7a4cc9144cefe..39e3c460535c3a6a8a5fab2b9020b181cc9e9ea8 100644 --- a/include/morse_constants.h +++ b/include/morse_constants.h @@ -130,7 +130,7 @@ #define MORSE_PROFILING_MODE 5 #define MORSE_PARALLEL_MODE 6 #define MORSE_BOUND 7 - +#define MORSE_PROGRESS 8 /** **************************************************************************** * MORSE constants - configuration parameters diff --git a/include/morse_struct.h b/include/morse_struct.h index e2e671c227e246a763fac69034f6bf101919b420..2958ce3d021bc68e2b5a91195b1b8dd7580a43b0 100644 --- a/include/morse_struct.h +++ b/include/morse_struct.h @@ -131,6 +131,7 @@ typedef struct morse_context_s { MORSE_bool autotuning_enabled; MORSE_bool parallel_enabled; MORSE_bool profiling_enabled; + MORSE_bool progress_enabled; MORSE_enum householder; // "domino" (flat) or tree-based (reduction) Householder MORSE_enum translation; // In place or Out of place layout conversion diff --git a/runtime/starpu/control/runtime_async.c b/runtime/starpu/control/runtime_async.c index cad933d391c065a3b5ba8a45997d1ecc410a2de2..2216d7e2bbc90667e83a28344ab8ccb10bd7e516 100644 --- a/runtime/starpu/control/runtime_async.c +++ b/runtime/starpu/control/runtime_async.c @@ -23,6 +23,7 @@ * **/ #include <stdlib.h> +#include <limits.h> #include "runtime/starpu/include/morse_starpu.h" /******************************************************************************* @@ -45,6 +46,60 @@ int RUNTIME_sequence_destroy( MORSE_context_t *morse, MORSE_sequence_t *sequence return MORSE_SUCCESS; } +void update_progress(int currentValue, int maximumValue) { + div_t res ; + static int progress = -1; /* varie de 0 a 100 au cours du calcul concerne */ + + if (maximumValue==0) + res.quot=100 ; + else { + if (currentValue<INT_MAX/100) + res=div(currentValue*100, maximumValue) ; + /* Calcule le quotient de la division */ + else + res.quot=(int)( (long long) currentValue*100/maximumValue) ; + } + // Print the percentage + if (res.quot > progress) + printf("%3d%%\b\b\b\b", res.quot) ; + progress=res.quot ; + + if (currentValue>=maximumValue) { + progress=-1 ; + } + + fflush(stdout); +} + +#define PROGRESS_MINIMUM_DURATION 10 + +/******************************************************************************* + * Display a progress information when executing the tasks + **/ +int RUNTIME_progress( MORSE_context_t *morse) +{ +#if defined(CHAMELEON_USE_MPI) + if (morse->my_mpi_rank!=0) + return MORSE_SUCCESS; +#endif + int tasksLeft, current, timer=0; + int max = starpu_task_nsubmitted(); + if (max==0) + return MORSE_SUCCESS; + // update_progress(0, max); + while ((tasksLeft = starpu_task_nsubmitted()) > 0) { + current = max - tasksLeft; + if (timer > PROGRESS_MINIMUM_DURATION) // no progress indicator for algorithms faster than 'PROGRESS_MINIMUM_DURATION' seconds + update_progress(current, max); + sleep(1); + timer++; + } + if (timer > PROGRESS_MINIMUM_DURATION) + update_progress(max, max); + + return MORSE_SUCCESS; +} + /******************************************************************************* * Wait for the completion of a sequence **/ @@ -52,6 +107,8 @@ int RUNTIME_sequence_wait( MORSE_context_t *morse, MORSE_sequence_t *sequence ) { (void)morse; (void)sequence; + if (morse->progress_enabled) + RUNTIME_progress(morse); starpu_task_wait_for_all(); #if defined(CHAMELEON_USE_MPI) starpu_mpi_barrier(MPI_COMM_WORLD); diff --git a/timing/timing.c b/timing/timing.c index 7d5bfa66dc8dbe7719839aae1b6ff491e6eea3f5..796441d6bf9adfcedb0f5500a7c891f7df186c5b 100644 --- a/timing/timing.c +++ b/timing/timing.c @@ -348,6 +348,7 @@ show_help(char *prog_name) { "\n" " --[a]sync Enable/Disable synchronous calls in wrapper function such as POTRI. (default: async)\n" " --[no]check Check result (default: nocheck)\n" + " --[no]progress Display progress indicator (default: noprogress)\n" " --[no]inv Check on inverse (default: noinv)\n" " --[no]warmup Perform a warmup run to pre-load libraries (default: warmup)\n" " --[no]trace Enable/Disable trace generation (default: notrace)\n" @@ -486,6 +487,7 @@ main(int argc, char *argv[]) { iparam[IPARAM_NMPI ] = 1; iparam[IPARAM_P ] = 1; iparam[IPARAM_Q ] = 1; + iparam[IPARAM_PROGRESS ] = 0; iparam[IPARAM_PROFILE ] = 0; iparam[IPARAM_PRINT_ERRORS ] = 0; iparam[IPARAM_PEAK ] = 0; @@ -524,6 +526,10 @@ main(int argc, char *argv[]) { iparam[IPARAM_TRACE] = 1; } else if (startswith( argv[i], "--notrace" )) { iparam[IPARAM_TRACE] = 0; + } else if (startswith( argv[i], "--progress" )) { + iparam[IPARAM_PROGRESS] = 1; + } else if (startswith( argv[i], "--noprogress" )) { + iparam[IPARAM_PROGRESS] = 0; } else if (startswith( argv[i], "--dag" )) { iparam[IPARAM_DAG] = 1; } else if (startswith( argv[i], "--nodag" )) { @@ -628,6 +634,9 @@ main(int argc, char *argv[]) { if (iparam[IPARAM_PRINT_ERRORS] == 1) MORSE_Enable(MORSE_ERRORS); + if (iparam[IPARAM_PROGRESS] == 1) + MORSE_Enable(MORSE_PROGRESS); + #if defined(CHAMELEON_USE_MPI) MORSE_Comm_size( &nbnode ); iparam[IPARAM_NMPI] = nbnode; diff --git a/timing/timing.h b/timing/timing.h index 3a6d9a9c74d9dbed86d0d4a06e1feaee8fd24b12..4f8771bb6be45316752cf6649eeb989fb508c380 100644 --- a/timing/timing.h +++ b/timing/timing.h @@ -46,6 +46,8 @@ enum iparam_timing { IPARAM_NMPI, IPARAM_P, /* Parameter for 2D cyclic distribution */ IPARAM_Q, /* Parameter for 2D cyclic distribution */ + + IPARAM_PROGRESS, /* Use a progress indicator during computations */ /* Added for StarPU version */ IPARAM_PROFILE, IPARAM_PRINT_ERRORS,