From 4d965cd16799ce74a65704a13cea3150f78b4db5 Mon Sep 17 00:00:00 2001 From: "Peter W. Draper" <p.w.draper@durham.ac.uk> Date: Tue, 6 Sep 2016 11:58:42 +0100 Subject: [PATCH] Add engine_drift() function so that we can time drifts --- src/engine.c | 24 ++++++++++++++++++------ src/engine.h | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/engine.c b/src/engine.c index 2522d9a845..ea375294ff 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2282,8 +2282,7 @@ void engine_prepare(struct engine *e, int nodrift) { /* Drift all particles to the current time if needed. */ if (!nodrift) { e->drift_all = 1; - threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top, - e->s->nr_cells, sizeof(struct cell), 1, e); + engine_drift(e); /* Restore the default drifting policy */ e->drift_all = (e->policy & engine_policy_drift_all); @@ -2670,8 +2669,7 @@ void engine_step(struct engine *e) { /* Drift everybody to the snapshot position */ e->drift_all = 1; - threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top, - e->s->nr_cells, sizeof(struct cell), 1, e); + engine_drift(e); /* Restore the default drifting policy */ e->drift_all = (e->policy & engine_policy_drift_all); @@ -2713,8 +2711,7 @@ void engine_step(struct engine *e) { * if we are about to repartition. */ int repart = (e->forcerepart != REPART_NONE); e->drift_all = repart || e->drift_all; - threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top, - e->s->nr_cells, sizeof(struct cell), 1, e); + engine_drift(e); /* Re-distribute the particles amongst the nodes? */ if (repart) engine_repartition(e); @@ -2805,6 +2802,21 @@ int engine_is_done(struct engine *e) { return !(e->ti_current < max_nr_timesteps); } +/** + * @brief Drift particles using the current engine drift policy. + * + * @param e The #engine. + */ +void engine_drift(struct engine *e) { + + ticks tic = getticks(); + threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top, + e->s->nr_cells, sizeof(struct cell), 1, e); + if (e->verbose) + message("took %.3f %s.", clocks_from_ticks(getticks() - tic), + clocks_getunit()); +} + /** * @brief Create and fill the proxies. * diff --git a/src/engine.h b/src/engine.h index fe0f9db2c5..9f544b5b7b 100644 --- a/src/engine.h +++ b/src/engine.h @@ -209,6 +209,7 @@ struct engine { /* Function prototypes. */ void engine_barrier(struct engine *e, int tid); void engine_compute_next_snapshot_time(struct engine *e); +void engine_drift(struct engine *e); void engine_dump_snapshot(struct engine *e); void engine_init(struct engine *e, struct space *s, const struct swift_params *params, int nr_nodes, int nodeID, -- GitLab