commit b86286bc83b43d7dec3430b34ccb6eaa1c95eef9
parent be785897501f6118aec8fe4547881cf1883f40e3
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Sat, 18 Dec 2021 12:30:08 +0100
Minor refactoring of several solve functions
Remove the setup_estimator function
Diffstat:
5 files changed, 42 insertions(+), 59 deletions(-)
diff --git a/src/sdis.c b/src/sdis.c
@@ -542,30 +542,6 @@ error:
}
#endif /* SDIS_ENABLE_MPI */
-res_T
-setup_estimator
- (struct sdis_estimator* estimator,
- const struct ssp_rng_proxy* proxy,
- const struct accum* acc_temp,
- const struct accum* acc_time,
- const size_t nrealisations)
-{
- res_T res = RES_OK;
- ASSERT(estimator && proxy && acc_temp && acc_time);
-
- 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);
-
- res = estimator_save_rng_state(estimator, proxy);
- if(res != RES_OK) goto error;
-
-exit:
- return res;
-error:
- goto exit;
-}
-
#ifndef SDIS_ENABLE_MPI
res_T
gather_green_functions
diff --git a/src/sdis_c.h b/src/sdis_c.h
@@ -96,14 +96,6 @@ gather_accumulators
const struct accum* per_thread_acc,
struct accum* acc);
-extern LOCAL_SYM res_T
-setup_estimator
- (struct sdis_estimator* estimator,
- const struct ssp_rng_proxy* proxy,
- const struct accum* acc_temp,
- const struct accum* acc_time,
- const size_t overall_realisations_count);
-
/* Gather the green functions. With MPI, non master processes store in green
* the gathering of their per thread green functions and sent the result to the
* master process. The master process gathers both per thread green functions
diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h
@@ -464,16 +464,18 @@ XD(solve_boundary)
/* Setup the estimated temperature */
if(out_estimator) {
- struct accum acc_temp, acc_time;
+ struct accum acc_temp;
+ struct accum acc_time;
time_current(&time0);
- res = gather_accumulators
- (scn->dev, MPI_SDIS_MSG_ACCUM_TEMP, per_thread_acc_temp, &acc_temp);
- if(res != RES_OK) goto error;
- res = gather_accumulators
- (scn->dev, MPI_SDIS_MSG_ACCUM_TIME, per_thread_acc_time, &acc_time);
- if(res != RES_OK) goto error;
+ #define GATHER_ACCUMS(Msg, Acc) { \
+ res = gather_accumulators(scn->dev, Msg, per_thread_##Acc, &Acc); \
+ if(res != RES_OK) goto error; \
+ } (void)0
+ GATHER_ACCUMS(MPI_SDIS_MSG_ACCUM_TEMP, acc_temp);
+ GATHER_ACCUMS(MPI_SDIS_MSG_ACCUM_TIME, acc_time);
+ #undef GATHER_ACCUMS
time_sub(&time0, time_current(&time1), &time0);
time_dump(&time0, TIME_ALL, NULL, buf, sizeof(buf));
@@ -481,8 +483,11 @@ XD(solve_boundary)
/* Return an estimator only on master process */
if(is_master_process) {
- res = setup_estimator
- (estimator, rng_proxy, &acc_temp, &acc_time, args->nrealisations);
+ ASSERT(acc_temp.count == acc_time.count);
+ estimator_setup_realisations_count(estimator, args->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);
+ res = estimator_save_rng_state(estimator, rng_proxy);
if(res != RES_OK) goto error;
}
}
diff --git a/src/sdis_solve_probe_Xd.h b/src/sdis_solve_probe_Xd.h
@@ -295,16 +295,18 @@ XD(solve_probe)
/* Setup the estimated values */
if(out_estimator) {
- struct accum acc_temp, acc_time;
+ struct accum acc_temp;
+ struct accum acc_time;
time_current(&time0);
- res = gather_accumulators
- (scn->dev, MPI_SDIS_MSG_ACCUM_TEMP, per_thread_acc_temp, &acc_temp);
- if(res != RES_OK) goto error;
- res = gather_accumulators
- (scn->dev, MPI_SDIS_MSG_ACCUM_TIME, per_thread_acc_time, &acc_time);
- if(res != RES_OK) goto error;
+ #define GATHER_ACCUMS(Msg, Acc) { \
+ res = gather_accumulators(scn->dev, Msg, per_thread_##Acc, &Acc); \
+ if(res != RES_OK) goto error; \
+ } (void)0
+ GATHER_ACCUMS(MPI_SDIS_MSG_ACCUM_TEMP, acc_temp);
+ GATHER_ACCUMS(MPI_SDIS_MSG_ACCUM_TEMP, acc_time);
+ #undef GATHER_ACCUMS
time_sub(&time0, time_current(&time1), &time0);
time_dump(&time0, TIME_ALL, NULL, buf, sizeof(buf));
@@ -312,8 +314,11 @@ XD(solve_probe)
/* Return an estimator only on master process */
if(is_master_process) {
- res = setup_estimator
- (estimator, rng_proxy, &acc_temp, &acc_time, args->nrealisations);
+ ASSERT(acc_temp.count == acc_time.count);
+ estimator_setup_realisations_count(estimator, args->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);
+ res = estimator_save_rng_state(estimator, rng_proxy);
if(res != RES_OK) goto error;
}
}
diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h
@@ -328,16 +328,18 @@ XD(solve_probe_boundary)
/* Setup the estimated temperature and per realisation time */
if(out_estimator) {
- struct accum acc_temp, acc_time;
+ struct accum acc_temp;
+ struct accum acc_time;
time_current(&time0);
- res = gather_accumulators
- (scn->dev, MPI_SDIS_MSG_ACCUM_TEMP, per_thread_acc_temp, &acc_temp);
- if(res != RES_OK) goto error;
- res = gather_accumulators
- (scn->dev, MPI_SDIS_MSG_ACCUM_TIME, per_thread_acc_time, &acc_time);
- if(res != RES_OK) goto error;
+ #define GATHER_ACCUMS(Msg, Acc) { \
+ res = gather_accumulators(scn->dev, Msg, per_thread_##Acc, &Acc); \
+ if(res != RES_OK) goto error; \
+ } (void)0
+ GATHER_ACCUMS(MPI_SDIS_MSG_ACCUM_TEMP, acc_temp);
+ GATHER_ACCUMS(MPI_SDIS_MSG_ACCUM_TIME, acc_time);
+ #undef GATHER_ACCUMS
time_sub(&time0, time_current(&time1), &time0);
time_dump(&time0, TIME_ALL, NULL, buf, sizeof(buf));
@@ -345,8 +347,11 @@ XD(solve_probe_boundary)
/* Return an estimator only on master process */
if(is_master_process) {
- res = setup_estimator
- (estimator, rng_proxy, &acc_temp, &acc_time, args->nrealisations);
+ ASSERT(acc_temp.count == acc_time.count);
+ estimator_setup_realisations_count(estimator, args->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);
+ res = estimator_save_rng_state(estimator, rng_proxy);
if(res != RES_OK) goto error;
}
}