From 92a3c4a100ff73485a94387231e4bb342b9c622b Mon Sep 17 00:00:00 2001 From: Guillaume Sylvand <guillaume.sylvand@airbus.com> Date: Tue, 20 Sep 2016 17:39:38 +0000 Subject: [PATCH] Add a 'progress indicator' feature, that displays a percentage of completion IT is OFF by default It is activated with MORSE_Enable(MORSE_PROGRESS) In the timing routines, it is activated with --progress No progress is printed for tasks faster than 10 seconds --- control/context.c | 21 +++++++--- include/morse_constants.h | 2 +- include/morse_struct.h | 1 + runtime/starpu/control/runtime_async.c | 57 ++++++++++++++++++++++++++ timing/timing.c | 9 ++++ timing/timing.h | 2 + 6 files changed, 85 insertions(+), 7 deletions(-) diff --git a/control/context.c b/control/context.c index 1861bf6a4..38d892036 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 5c6b73a85..39e3c4605 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 e2e671c22..2958ce3d0 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 cad933d39..2216d7e2b 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 7d5bfa66d..796441d6b 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 3a6d9a9c7..4f8771bb6 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, -- GitLab