commit a0021b1099341b36dc18bdad09e59daefc436412
parent 31a84236384ca9172274c734f706a04df967a12c
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 29 Nov 2021 14:25:46 +0100
Update the setup_estimator function
It does not gather the accumulators anymore.
Diffstat:
2 files changed, 27 insertions(+), 30 deletions(-)
diff --git a/src/sdis.c b/src/sdis.c
@@ -278,6 +278,8 @@ gather_accumulators
struct accum* acc_temp,
struct accum* acc_time)
{
+ char buf[128];
+ struct time t0, t1;
struct accum* per_proc_acc_temp = NULL;
struct accum* per_proc_acc_time = NULL;
size_t nprocs = 0;
@@ -285,6 +287,8 @@ gather_accumulators
ASSERT(dev && per_thread_acc_temp && per_thread_acc_time);
ASSERT(acc_temp && acc_time);
+ time_current(&t0);
+
if(!dev->use_mpi) {
/* Gather thread accumulators */
sum_accums(per_thread_acc_temp, dev->nthreads, acc_temp);
@@ -345,6 +349,11 @@ gather_accumulators
}
exit:
+ if(res == RES_OK) {
+ time_sub(&t0, time_current(&t1), &t0);
+ time_dump(&t0, TIME_ALL, NULL, buf, sizeof(buf));
+ log_info(dev, "Accumulators gathered in %s.\n", buf);
+ }
if(per_proc_acc_temp) MEM_RM(dev->allocator, per_proc_acc_temp);
if(per_proc_acc_time) MEM_RM(dev->allocator, per_proc_acc_time);
return res;
@@ -357,36 +366,16 @@ res_T
setup_estimator
(struct sdis_estimator* estimator,
const struct ssp_rng_proxy* proxy,
- const struct accum* per_thread_acc_temp,
- const struct accum* per_thread_acc_time,
+ const struct accum* acc_temp,
+ const struct accum* acc_time,
const size_t nrealisations)
{
- char buf[128];
- struct time t0, t1;
- struct accum acc_temp = ACCUM_NULL;
- struct accum acc_time = ACCUM_NULL;
res_T res = RES_OK;
+ ASSERT(estimator && proxy && acc_temp && acc_time);
- ASSERT(estimator && proxy && per_thread_acc_temp && per_thread_acc_time);
-
- time_current(&t0);
-
- /* Gather the accumulators from concurrent threads & processes */
- gather_accumulators
- (estimator->dev,
- per_thread_acc_temp,
- per_thread_acc_time,
- &acc_temp,
- &acc_time);
- ASSERT(acc_temp.count == acc_time.count);
-
- time_sub(&t0, time_current(&t1), &t0);
- time_dump(&t0, TIME_ALL, NULL, buf, sizeof(buf));
- log_info(estimator->dev, "Accumulators gathered in %s.\n", buf);
-
- estimator_setup_realisations_count(estimator, nrealisations, acc_temp.count);
- estimator_setup_temperature(estimator, acc_temp.sum, acc_temp.sum2);
- estimator_setup_realisation_time(estimator, acc_time.sum, acc_time.sum2);
+ estimator_setup_realisations_count(estimator, nrealisations, acc_temp->count);
+ estimator_setup_temperature(estimator, acc_temp->sum, acc_temp->sum2);
+ estimator_setup_realisation_time(estimator, acc_time->sum, acc_time->sum2);
/* TODO correctly handle RNG state with MPI. Currently, we only store the RNG
* proxy state of the master process, but non-master processes can rely on
@@ -399,7 +388,7 @@ setup_estimator
#ifdef SDIS_ENABLE_MPI
if(estimator->dev->use_mpi) {
log_warn(estimator->dev,
- "The estimator RNG state is not well defined when MPI is used.");
+ "The estimator RNG state is not well defined when MPI is used.\n");
}
#endif
diff --git a/src/sdis_solve_probe_Xd.h b/src/sdis_solve_probe_Xd.h
@@ -285,9 +285,17 @@ XD(solve_probe)
/* Setup the estimated values */
if(out_estimator) {
- res = setup_estimator(estimator, rng_proxy, per_thread_acc_temp,
- per_thread_acc_time, args->nrealisations);
- if(res != RES_OK) goto error;
+ struct accum acc_temp, acc_time;
+
+ res = gather_accumulators
+ (scn->dev, per_thread_acc_temp, per_thread_acc_time, &acc_temp, &acc_time);
+ if(res != RES_OK) goto exit;
+
+ if(is_master_process) {
+ res = setup_estimator
+ (estimator, rng_proxy, &acc_temp, &acc_time, args->nrealisations);
+ if(res != RES_OK) goto error;
+ }
}
/* TODO handle for MPI */