diff --git a/src/engine.c b/src/engine.c index 2522d9a8456d36d6ab7b02a9ce425592541be52e..ea375294ffc0665a1aa5901472c93a26dbdbb82f 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 fe0f9db2c5bb427bb6356c5838af2252d6dbca2a..9f544b5b7b87731842a9945adb316ccb48d72542 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,