commit da100ddb217651ac2c8ea8a2c0ae71c5a7587385
parent f07471f34fe496d7a9044d4fc2f0eb32dfff02b9
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 2 Mar 2023 16:32:03 +0100
Support for plain text messages in all solve functions
The 'no_escape_sequences' device option is now supported everywhere.
When enabled, all resolution functions (probe [_flux], limit [_flux],
medium, and camera) print their progress every 10%, one line per
progress message. Additionally, they rely on the
'print_progress_completion' function to finalize their progress message
depending on whether escape sequences are allowed or not, and whether
MPI is enabled or not.
Diffstat:
4 files changed, 48 insertions(+), 20 deletions(-)
diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h
@@ -195,6 +195,7 @@ XD(solve_boundary)
int64_t irealisation = 0;
size_t i;
int32_t* progress = NULL; /* Per process progress bar */
+ int pcent_progress = 1; /* Percentage requiring progress update */
int register_paths = SDIS_HEAT_PATH_NONE;
int is_master_process = 1;
ATOMIC nsolved_realisations = 0;
@@ -237,6 +238,11 @@ XD(solve_boundary)
is_master_process = !scn->dev->use_mpi || scn->dev->mpi_rank == 0;
#endif
+ /* Update the progress bar every percent if escape sequences are allowed in
+ * log messages or only every 10 percent when only plain text is allowed.
+ * This reduces the number of lines of plain text printed */
+ pcent_progress = scn->dev->no_escape_sequence ? 10 : 1;
+
/* Create the Star-XD shape of the boundary */
#if SDIS_XD_DIMENSION == 2
res = s2d_shape_create_line_segments(scn->dev->sXd(dev), &shape);
@@ -443,7 +449,7 @@ XD(solve_boundary)
n = (size_t)ATOMIC_INCR(&nsolved_realisations);
pcent = (int)((double)n * 100.0 / (double)nrealisations + 0.5/*round*/);
#pragma omp critical
- if(pcent > progress[0]) {
+ if(pcent/pcent_progress > progress[0]/pcent_progress) {
progress[0] = pcent;
print_progress_update(scn->dev, progress, PROGRESS_MSG);
}
@@ -459,8 +465,7 @@ XD(solve_boundary)
res = gather_res_T(scn->dev, (res_T)res);
if(res != RES_OK) goto error;
- print_progress_update(scn->dev, progress, PROGRESS_MSG);
- log_info(scn->dev, "\n");
+ print_progress_completion(scn->dev, progress, PROGRESS_MSG);
#undef PROGRESS_MSG
/* Report computation time */
@@ -587,6 +592,7 @@ XD(solve_boundary_flux)
int64_t irealisation;
size_t i;
int32_t* progress = NULL; /* Per process progress bar */
+ int pcent_progress = 1; /* Percentage requiring progress update */
int is_master_process = 1;
ATOMIC nsolved_realisations = 0;
ATOMIC res = RES_OK;
@@ -642,6 +648,11 @@ XD(solve_boundary_flux)
is_master_process = !scn->dev->use_mpi || scn->dev->mpi_rank == 0;
#endif
+ /* Update the progress bar every percent if escape sequences are allowed in
+ * log messages or only every 10 percent when only plain text is allowed.
+ * This reduces the number of lines of plain text printed */
+ pcent_progress = scn->dev->no_escape_sequence ? 10 : 1;
+
/* Create the per thread RNGs */
res = create_per_thread_rng
(scn->dev, args->rng_state, args->rng_type, &rng_proxy, &per_thread_rng);
@@ -840,7 +851,7 @@ XD(solve_boundary_flux)
n = (size_t)ATOMIC_INCR(&nsolved_realisations);
pcent = (int)((double)n * 100.0 / (double)nrealisations + 0.5/*round*/);
#pragma omp critical
- if(pcent > progress[0]) {
+ if(pcent/pcent_progress > progress[0]/pcent_progress) {
progress[0] = pcent;
print_progress_update(scn->dev, progress, PROGRESS_MSG);
}
@@ -851,8 +862,7 @@ XD(solve_boundary_flux)
res = gather_res_T(scn->dev, (res_T)res);
if(res != RES_OK) goto error;
- print_progress_update(scn->dev, progress, PROGRESS_MSG);
- log_info(scn->dev, "\n");
+ print_progress_completion(scn->dev, progress, PROGRESS_MSG);
#undef PROGRESS_MSG
/* Report computation time */
diff --git a/src/sdis_solve_camera.c b/src/sdis_solve_camera.c
@@ -510,6 +510,7 @@ sdis_solve_camera
int64_t mcode_1st; /* morton code of the 1st tile computed by the process */
int64_t mcode_incr; /* Increment toward the next morton code */
int32_t* progress = NULL; /* Per process progress bar */
+ int pcent_progress = 1; /* Percentage requiring progress update */
int register_paths = SDIS_HEAT_PATH_NONE;
int is_master_process = 1;
ATOMIC nsolved_tiles = 0;
@@ -574,6 +575,11 @@ sdis_solve_camera
ntiles_proc = ntiles;
}
+ /* Update the progress bar every percent if escape sequences are allowed in
+ * log messages or only every 10 percent when only plain text is allowed.
+ * This reduces the number of lines of plain text printed */
+ pcent_progress = scn->dev->no_escape_sequence ? 10 : 1;
+
/* Compute the normalized pixel size */
pix_sz[0] = 1.0 / (double)args->image_definition[0];
pix_sz[1] = 1.0 / (double)args->image_definition[1];
@@ -654,7 +660,7 @@ sdis_solve_camera
n = (size_t)ATOMIC_INCR(&nsolved_tiles);
pcent = (int)((double)n*100.0 / (double)ntiles_proc + 0.5/*round*/);
#pragma omp critical
- if(pcent > progress[0]) {
+ if(pcent/pcent_progress > progress[0]/pcent_progress) {
progress[0] = pcent;
print_progress_update(scn->dev, progress, PROGRESS_MSG);
}
@@ -666,8 +672,7 @@ sdis_solve_camera
res = gather_res_T(scn->dev, (res_T)res);
if(res != RES_OK) goto error;
- print_progress_update(scn->dev, progress, PROGRESS_MSG);
- log_info(scn->dev, "\n");
+ print_progress_completion(scn->dev, progress, PROGRESS_MSG);
#undef PROGRESS_MSG
/* Report computation time */
@@ -706,5 +711,3 @@ error:
if(buf) { SDIS(estimator_buffer_ref_put(buf)); buf = NULL; }
goto exit;
}
-
-
diff --git a/src/sdis_solve_medium_Xd.h b/src/sdis_solve_medium_Xd.h
@@ -298,6 +298,7 @@ XD(solve_medium)
size_t nrealisations = 0;
int64_t irealisation;
int32_t* progress = NULL; /* Per process progress bar */
+ int pcent_progress = 1; /* Percentage requiring progress update */
int is_master_process = 1;
int cumul_is_init = 0;
int register_paths = SDIS_HEAT_PATH_NONE;
@@ -327,6 +328,11 @@ XD(solve_medium)
nthreads = scn->dev->nthreads;
allocator = scn->dev->allocator;
+ /* Update the progress bar every percent if escape sequences are allowed in
+ * log messages or only every 10 percent when only plain text is allowed.
+ * This reduces the number of lines of plain text printed */
+ pcent_progress = scn->dev->no_escape_sequence ? 10 : 1;
+
/* Create the per thread RNGs */
res = create_per_thread_rng
(scn->dev, args->rng_state, args->rng_type, &rng_proxy, &per_thread_rng);
@@ -470,7 +476,7 @@ XD(solve_medium)
n = (size_t)ATOMIC_INCR(&nsolved_realisations);
pcent = (int)((double)n * 100.0 / (double)nrealisations + 0.5/*round*/);
#pragma omp critical
- if(pcent > progress[0]) {
+ if(pcent/pcent_progress > progress[0]/pcent_progress) {
progress[0] = pcent;
print_progress_update(scn->dev, progress, PROGRESS_MSG);
}
@@ -486,8 +492,7 @@ XD(solve_medium)
res = gather_res_T(scn->dev, (res_T)res);
if(res != RES_OK) goto error;
- print_progress_update(scn->dev, progress, PROGRESS_MSG);
- log_info(scn->dev, "\n");
+ print_progress_completion(scn->dev, progress, PROGRESS_MSG);
#undef PROGRESS_MSG
/* Report computation time */
diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h
@@ -142,6 +142,7 @@ XD(solve_probe_boundary)
size_t nrealisations = 0;
int64_t irealisation = 0;
int32_t* progress = NULL; /* Per process progress bar */
+ int pcent_progress = 1; /* Percentage requiring progress update */
int register_paths = SDIS_HEAT_PATH_NONE;
int is_master_process = 1;
ATOMIC nsolved_realisations = 0;
@@ -174,6 +175,11 @@ XD(solve_probe_boundary)
nthreads = scn->dev->nthreads;
allocator = scn->dev->allocator;
+ /* Update the progress bar every percent if escape sequences are allowed in
+ * log messages or only every 10 percent when only plain text is allowed.
+ * This reduces the number of lines of plain text printed */
+ pcent_progress = scn->dev->no_escape_sequence ? 10 : 1;
+
/* Create the per thread RNGs */
res = create_per_thread_rng
(scn->dev, args->rng_state, args->rng_type, &rng_proxy, &per_thread_rng);
@@ -307,7 +313,7 @@ XD(solve_probe_boundary)
n = (size_t)ATOMIC_INCR(&nsolved_realisations);
pcent = (int)((double)n * 100.0 / (double)nrealisations + 0.5/*round*/);
#pragma omp critical
- if(pcent > progress[0]) {
+ if(pcent/pcent_progress > progress[0]/pcent_progress) {
progress[0] = pcent;
print_progress_update(scn->dev, progress, PROGRESS_MSG);
}
@@ -324,8 +330,7 @@ XD(solve_probe_boundary)
res = gather_res_T(scn->dev, (res_T)res);
if(res != RES_OK) goto error;
- print_progress_update(scn->dev, progress, PROGRESS_MSG);
- log_info(scn->dev, "\n");
+ print_progress_completion(scn->dev, progress, PROGRESS_MSG);
#undef PROGRESS_MSG
/* Report computation time */
@@ -446,6 +451,7 @@ XD(solve_probe_boundary_flux)
size_t nrealisations = 0;
int64_t irealisation = 0;
int32_t* progress = NULL; /* Per process progress bar */
+ int pcent_progress = 1; /* Percentage requiring progress update */
int is_master_process = 1;
ATOMIC nsolved_realisations = 0;
ATOMIC res = RES_OK;
@@ -481,6 +487,11 @@ XD(solve_probe_boundary_flux)
is_master_process = !scn->dev->use_mpi || scn->dev->mpi_rank == 0;
#endif
+ /* Update the progress bar every percent if escape sequences are allowed in
+ * log messages or only every 10 percent when only plain text is allowed.
+ * This reduces the number of lines of plain text printed */
+ pcent_progress = scn->dev->no_escape_sequence ? 10 : 1;
+
/* Create the per thread RNGs */
res = create_per_thread_rng
(scn->dev, args->rng_state, args->rng_type, &rng_proxy, &per_thread_rng);
@@ -634,7 +645,7 @@ XD(solve_probe_boundary_flux)
n = (size_t)ATOMIC_INCR(&nsolved_realisations);
pcent = (int)((double)n * 100.0 / (double)nrealisations + 0.5/*round*/);
#pragma omp critical
- if(pcent > progress[0]) {
+ if(pcent/pcent_progress > progress[0]/pcent_progress) {
progress[0] = pcent;
print_progress_update(scn->dev, progress, PROGRESS_MSG);
}
@@ -645,8 +656,7 @@ XD(solve_probe_boundary_flux)
res = gather_res_T(scn->dev, (res_T)res);
if(res != RES_OK) goto error;
- print_progress_update(scn->dev, progress, PROGRESS_MSG);
- log_info(scn->dev, "\n");
+ print_progress_completion(scn->dev, progress, PROGRESS_MSG);
#undef PROGRESS_MSG
/* Report computation time */