commit b72f32473374c7d6d6679a3e863f0bd6e3445860
parent 2c93c4e75ff10e1382283b4beb42d60c0800f933
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 16 Jun 2020 16:58:42 +0200
Log a progress message in the solve functions
Diffstat:
7 files changed, 141 insertions(+), 2 deletions(-)
diff --git a/src/sdis_device.c b/src/sdis_device.c
@@ -93,7 +93,7 @@ sdis_device_create
} else {
setup_log_default(dev);
}
- log_info(dev, "use %lu %s.\n", (unsigned long)dev->nthreads,
+ log_info(dev, "Use %lu %s.\n", (unsigned long)dev->nthreads,
dev->nthreads == 1 ? "thread" : "threads");
res = s2d_device_create(log, allocator, 0, &dev->s2d_dev);
diff --git a/src/sdis_solve.c b/src/sdis_solve.c
@@ -427,6 +427,8 @@ sdis_solve_camera
size_t nsuccesses;
size_t ix, iy;
size_t i;
+ int progress = 0;
+ ATOMIC nsolved_tiles = 0;
ATOMIC res = RES_OK;
if(!scn || !cam || fp_to_meter <= 0 || Tref < 0 || !width || !height || !spp
@@ -491,6 +493,8 @@ sdis_solve_camera
size_t tile_sz[2] = {0, 0};
const int ithread = omp_get_thread_num();
struct ssp_rng* rng = rngs[ithread];
+ size_t n;
+ int pcent;
res_T res_local = RES_OK;
if(ATOMIC_GET(&res) != RES_OK) continue;
@@ -513,7 +517,24 @@ sdis_solve_camera
ATOMIC_SET(&res, res_local);
continue;
}
+
+ /* Update progress */
+ n = (size_t)ATOMIC_INCR(&nsolved_tiles);
+ pcent = (int)((double)n*100.0 / (double)(ntiles_x*ntiles_y) + 0.5/*round*/);
+ #pragma omp critical
+ if(pcent > progress) {
+ progress = pcent;
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Infrared rendering: %3d%%",
+ progress);
+ }
}
+ if(res != RES_OK) goto error;
+
+ /* Add a new line after the progress status */
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Infrared rendering: %3d%%\n",
+ progress);
/* Setup the accumulators of the whole estimator buffer */
acc_temp = ACCUM_NULL;
diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h
@@ -103,6 +103,8 @@ XD(solve_boundary)
size_t i;
size_t view_nprims;
int64_t irealisation;
+ int progress = 0;
+ ATOMIC nsolved_realisations = 0;
ATOMIC res = RES_OK;
if(!scn || !nrealisations || nrealisations > INT64_MAX || !primitives
@@ -230,6 +232,8 @@ XD(solve_boundary)
double uv[DIM-1];
float st[DIM-1];
double time;
+ size_t n;
+ int pcent;
res_T res_local = RES_OK;
res_T res_simul = RES_OK;
@@ -311,7 +315,24 @@ XD(solve_boundary)
acc_temp->sum += w; acc_temp->sum2 += w*w; ++acc_temp->count;
acc_time->sum += usec; acc_time->sum2 += usec*usec; ++acc_time->count;
}
+
+ /* Update progress */
+ n = (size_t)ATOMIC_INCR(&nsolved_realisations);
+ pcent = (int)((double)n * 100.0 / (double)nrealisations + 0.5/*round*/);
+ #pragma omp critical
+ if(pcent > progress) {
+ progress = pcent;
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Solving boundary temperature: %3d%%",
+ progress);
+ }
}
+ if(res != RES_OK) goto error;
+
+ /* Add a new line after the progress status */
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Solving boundary temperature: %3d%%\n",
+ progress);
/* Setup the estimated temperature */
if(out_estimator) {
@@ -405,6 +426,8 @@ XD(solve_boundary_flux)
size_t i;
size_t view_nprims;
int64_t irealisation;
+ int progress = 0;
+ ATOMIC nsolved_realisations = 0;
ATOMIC res = RES_OK;
if(!scn || !nrealisations || nrealisations > INT64_MAX || !primitives
@@ -521,6 +544,8 @@ XD(solve_boundary_flux)
float st[DIM - 1];
double time;
int flux_mask = 0;
+ size_t n;
+ int pcent;
res_T res_local = RES_OK;
res_T res_simul = RES_OK;
@@ -621,9 +646,23 @@ XD(solve_boundary_flux)
acc_frad->sum2 += w_rad*w_rad;
++acc_frad->count;
}
+
+ /* Update progress */
+ n = (size_t)ATOMIC_INCR(&nsolved_realisations);
+ pcent = (int)((double)n * 100.0 / (double)nrealisations + 0.5/*round*/);
+ #pragma omp critical
+ if(pcent > progress) {
+ progress = pcent;
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Solving boundary flux: %3d%%", progress);
+ }
}
if(res != RES_OK) goto error;
+ /* Add a new line after the progress status */
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Solving boundary flux: %3d%%\n", progress);
+
/* Redux the per thread accumulators */
sum_accums(acc_tp, scn->dev->nthreads, &acc_tp[0]);
sum_accums(acc_ti, scn->dev->nthreads, &acc_ti[0]);
diff --git a/src/sdis_solve_medium_Xd.h b/src/sdis_solve_medium_Xd.h
@@ -221,6 +221,8 @@ XD(solve_medium)
int64_t irealisation;
int cumul_is_init = 0;
size_t i;
+ int progress = 0;
+ ATOMIC nsolved_realisations = 0;
ATOMIC res = RES_OK;
if(!scn || !mdm || !nrealisations || nrealisations > INT64_MAX
@@ -305,6 +307,8 @@ XD(solve_medium)
double weight;
double time;
double pos[DIM];
+ size_t n;
+ int pcent;
res_T res_local = RES_OK;
res_T res_simul = RES_OK;
@@ -374,9 +378,25 @@ XD(solve_medium)
acc_temp->sum += weight; acc_temp->sum2 += weight*weight; ++acc_temp->count;
acc_time->sum += usec; acc_time->sum2 += usec*usec; ++acc_time->count;
}
+
+ /* Update progress */
+ n = (size_t)ATOMIC_INCR(&nsolved_realisations);
+ pcent = (int)((double)n * 100.0 / (double)nrealisations + 0.5/*round*/);
+ #pragma omp critical
+ if(pcent > progress) {
+ progress = pcent;
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Solving medium temperature: %3d%%",
+ progress);
+ }
}
if(res != RES_OK) goto error;
+ /* Add a new line after the progress status */
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Solving medium temperature: %3d%%\n",
+ progress);
+
/* Setup the estimated temperature */
if(out_estimator) {
struct accum acc_temp;
diff --git a/src/sdis_solve_probe_Xd.h b/src/sdis_solve_probe_Xd.h
@@ -15,6 +15,7 @@
#include "sdis_device_c.h"
#include "sdis_estimator_c.h"
+#include "sdis_log.h"
#include "sdis_green.h"
#include "sdis_misc.h"
#include "sdis_realisation.h"
@@ -52,6 +53,8 @@ XD(solve_probe)
struct accum* acc_times = NULL;
int64_t irealisation = 0;
size_t i;
+ int progress = 0;
+ ATOMIC nsolved_realisations = 0;
ATOMIC res = RES_OK;
if(!scn || !nrealisations || nrealisations > INT64_MAX || !position
@@ -133,6 +136,8 @@ XD(solve_probe)
struct sdis_heat_path heat_path;
double w = NaN;
double time;
+ size_t n;
+ int pcent;
res_T res_local = RES_OK;
res_T res_simul = RES_OK;
@@ -189,9 +194,23 @@ XD(solve_probe)
acc_temp->sum += w; acc_temp->sum2 += w*w; ++acc_temp->count;
acc_time->sum += usec; acc_time->sum2 += usec*usec; ++acc_time->count;
}
+
+ /* Update progress */
+ n = (size_t)ATOMIC_INCR(&nsolved_realisations);
+ pcent = (int)((double)n * 100.0 / (double)nrealisations + 0.5/*round*/);
+ #pragma omp critical
+ if(pcent > progress) {
+ progress = pcent;
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Solving probe temperature: %3d%%", progress);
+ }
}
if(res != RES_OK) goto error;
+ /* Add a new line after the progress status */
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Solving probe temperature: %3d%%\n", progress);
+
/* Setup the estimated temperature and per realisation time */
if(out_estimator) {
struct accum acc_temp;
diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h
@@ -54,6 +54,8 @@ XD(solve_probe_boundary)
struct accum* acc_times = NULL;
int64_t irealisation = 0;
size_t i;
+ int progress = 0;
+ ATOMIC nsolved_realisations = 0;
ATOMIC res = RES_OK;
if(!scn || !nrealisations || nrealisations > INT64_MAX || !uv
@@ -172,6 +174,8 @@ XD(solve_probe_boundary)
struct sdis_heat_path heat_path;
double w = NaN;
double time;
+ size_t n;
+ int pcent;
res_T res_local = RES_OK;
res_T res_simul = RES_OK;
@@ -227,9 +231,25 @@ XD(solve_probe_boundary)
acc_temp->sum += w; acc_temp->sum2 += w*w; ++acc_temp->count;
acc_time->sum += usec; acc_time->sum2 += usec*usec; ++acc_time->count;
}
+
+ /* Update progress */
+ n = (size_t)ATOMIC_INCR(&nsolved_realisations);
+ pcent = (int)((double)n * 100.0 / (double)nrealisations + 0.5/*round*/);
+ #pragma omp critical
+ if(pcent > progress) {
+ progress = pcent;
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Solving probe boundary temperature: %3d%%",
+ progress);
+ }
}
if(res != RES_OK) goto error;
+ /* Add a new line after the progress status */
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Solving probe boundary temperature: %3d%%\n",
+ progress);
+
/* Setup the estimated temperature and per realisation time */
if(out_estimator) {
struct accum acc_temp;
@@ -316,6 +336,8 @@ XD(solve_probe_boundary_flux)
struct accum* acc_fr = NULL; /* Per thread radiative flux accumulator */
int64_t irealisation = 0;
size_t i;
+ int progress = 0;
+ ATOMIC nsolved_realisations = 0;
ATOMIC res = RES_OK;
if(!scn || !nrealisations || nrealisations > INT64_MAX || !uv
@@ -431,6 +453,8 @@ XD(solve_probe_boundary_flux)
double time, epsilon, hc, hr;
int flux_mask = 0;
double T_brf[3] = { 0, 0, 0 };
+ size_t n;
+ int pcent;
res_T res_simul = RES_OK;
if(ATOMIC_GET(&res) != RES_OK) continue; /* An error occurred */
@@ -488,9 +512,25 @@ XD(solve_probe_boundary_flux)
acc_frad->sum2 += w_rad*w_rad;
++acc_frad->count;
}
+
+ /* Update progress */
+ n = (size_t)ATOMIC_INCR(&nsolved_realisations);
+ pcent = (int)((double)n * 100.0 / (double)nrealisations + 0.5/*round*/);
+ #pragma omp critical
+ if(pcent > progress) {
+ progress = pcent;
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Solving probe boundary flux: %3d%%",
+ progress);
+ }
}
if(res != RES_OK) goto error;
+ /* Add a new line after the progress status */
+ log_info(scn->dev,
+ "\033[2K\r"MSG_INFO_PREFIX"Solving probe boundary flux: %3d%%\n",
+ progress);
+
/* Redux the per thread accumulators */
sum_accums(acc_tp, scn->dev->nthreads, &acc_tp[0]);
sum_accums(acc_ti, scn->dev->nthreads, &acc_ti[0]);
diff --git a/src/test_sdis_solve_boundary.c b/src/test_sdis_solve_boundary.c
@@ -204,7 +204,7 @@ main(int argc, char** argv)
(void)argc, (void)argv;
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(sdis_device_create(NULL, &allocator, SDIS_NTHREADS_DEFAULT, 0, &dev));
+ OK(sdis_device_create(NULL, &allocator, SDIS_NTHREADS_DEFAULT, 1, &dev));
/* Temporary file used to dump heat paths */
CHK((fp = tmpfile()) != NULL);