Commit e1b61cbe authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Rephrased the logic in engine_step() in terms of task-unskipping and cell-drifting

parent 24e1ff73
......@@ -2229,6 +2229,9 @@ void engine_prepare(struct engine *e, int nodrift) {
TIMER_TIC;
/* Unskip active tasks and check for rebuild */
engine_unskip(e);
/* Run through the tasks and mark as skip or not. */
int rebuild = e->forcerebuild;
......@@ -2246,11 +2249,11 @@ void engine_prepare(struct engine *e, int nodrift) {
/* Drift all particles to the current time if needed. */
if (!nodrift) {
e->drift_all = 1;
engine_drift(e);
// e->drift_all = 1;
engine_drift_all(e);
/* Restore the default drifting policy */
e->drift_all = (e->policy & engine_policy_drift_all);
// e->drift_all = (e->policy & engine_policy_drift_all);
}
#ifdef SWIFT_DEBUG_CHECKS
......@@ -2603,10 +2606,10 @@ void engine_step(struct engine *e) {
/* Drift everybody to the snapshot position */
e->drift_all = 1;
engine_drift(e);
engine_drift_all(e);
/* Restore the default drifting policy */
e->drift_all = (e->policy & engine_policy_drift_all);
// e->drift_all = (e->policy & engine_policy_drift_all);
/* Dump... */
engine_dump_snapshot(e);
......@@ -2638,17 +2641,17 @@ void engine_step(struct engine *e) {
/* Drift only the necessary particles, that means all particles
* if we are about to repartition. */
const int repart = (e->forcerepart != REPART_NONE);
e->drift_all = repart || e->drift_all;
engine_drift(e);
// e->drift_all = repart || e->drift_all;
if (repart) engine_drift_all(e);
/* Re-distribute the particles amongst the nodes? */
if (repart) engine_repartition(e);
/* Prepare the space. */
engine_prepare(e, e->drift_all);
engine_prepare(e, (e->drift_all || repart));
/* Restore the default drifting policy */
e->drift_all = (e->policy & engine_policy_drift_all);
// e->drift_all = (e->policy & engine_policy_drift_all);
if (e->verbose) engine_print_task_counts(e);
......@@ -2683,15 +2686,30 @@ int engine_is_done(struct engine *e) {
*
* @param e The #engine.
*/
void engine_drift(struct engine *e) {
void engine_unskip(struct engine *e) {
const ticks tic = getticks();
threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top,
threadpool_map(&e->threadpool, runner_do_unskip_mapper, e->s->cells_top,
e->s->nr_cells, sizeof(struct cell), 1, e);
if (e->verbose)
message("took %.3f %s (including task unskipping).",
clocks_from_ticks(getticks() - tic), clocks_getunit());
message("took %.3f %s.", clocks_from_ticks(getticks() - tic),
clocks_getunit());
}
void engine_drift_all(struct engine *e) {
e->drift_all = 1;
const ticks tic = getticks();
threadpool_map(&e->threadpool, runner_do_unskip_mapper, e->s->cells_top,
e->s->nr_cells, sizeof(struct cell), 1, e);
e->drift_all = e->policy & engine_policy_drift_all;
if (e->verbose)
message("took %.3f %s.", clocks_from_ticks(getticks() - tic),
clocks_getunit());
}
/**
......
......@@ -218,7 +218,8 @@ 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_unskip(struct engine *e);
void engine_drift_all(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,
......
......@@ -877,8 +877,8 @@ static void runner_do_unskip(struct cell *c, struct engine *e, int drift) {
* @param extra_data Pointer to an #engine.
*/
void runner_do_drift_mapper(void *map_data, int num_elements,
void *extra_data) {
void runner_do_unskip_mapper(void *map_data, int num_elements,
void *extra_data) {
struct engine *e = (struct engine *)extra_data;
struct cell *cells = (struct cell *)map_data;
......
......@@ -56,6 +56,7 @@ void runner_do_init(struct runner *r, struct cell *c, int timer);
void runner_do_cooling(struct runner *r, struct cell *c, int timer);
void runner_do_grav_external(struct runner *r, struct cell *c, int timer);
void *runner_main(void *data);
void runner_do_drift_mapper(void *map_data, int num_elements, void *extra_data);
void runner_do_unskip_mapper(void *map_data, int num_elements,
void *extra_data);
#endif /* SWIFT_RUNNER_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment