From 0f6ff35e3a5c585201989be2ac11085d85149d27 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Sat, 18 Aug 2018 19:04:09 +0200 Subject: [PATCH] Put the checks for i/o dumps into a separate function. Call that function after the 0th step as well. --- examples/main.c | 3 +++ src/engine.c | 28 ++++++++++++++++------------ src/engine.h | 1 + 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/examples/main.c b/examples/main.c index 773accc461..257ffb9c82 100644 --- a/examples/main.c +++ b/examples/main.c @@ -943,6 +943,9 @@ int main(int argc, char *argv[]) { engine_dump_snapshot(&e); engine_print_stats(&e); + /* Is there a dump before the end of the first time-step? */ + engine_check_for_dumps(&e); + #ifdef HAVE_VELOCIRAPTOR /* Call VELOCIraptor for the first time after the first snapshot dump. */ // if (e.policy & engine_policy_structure_finding) { diff --git a/src/engine.c b/src/engine.c index 9d5ae94f04..65fcc2751c 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2746,8 +2746,7 @@ void engine_link_gravity_tasks(struct engine *e) { /* Get a pointer to the task. */ struct task *t = &sched->tasks[k]; - if(t->type == task_type_none) - continue; + if (t->type == task_type_none) continue; /* Get the cells we act on */ struct cell *ci = t->ci; @@ -4844,6 +4843,21 @@ void engine_step(struct engine *e) { /* Create a restart file if needed. */ engine_dump_restarts(e, 0, e->restart_onexit && engine_is_done(e)); + engine_check_for_dumps(e); + + TIMER_TOC2(timer_step); + + clocks_gettime(&time2); + e->wallclock_time = (float)clocks_diff(&time1, &time2); + +#ifdef SWIFT_DEBUG_TASKS + /* Time in ticks at the end of this step. */ + e->toc_step = getticks(); +#endif +} + +void engine_check_for_dumps(struct engine *e) { + /* Save some statistics ? */ int save_stats = 0; if (e->ti_end_min > e->ti_next_stats && e->ti_next_stats > 0) save_stats = 1; @@ -4997,16 +5011,6 @@ void engine_step(struct engine *e) { e->ti_current = ti_current; e->max_active_bin = max_active_bin; e->time = time; - - TIMER_TOC2(timer_step); - - clocks_gettime(&time2); - e->wallclock_time = (float)clocks_diff(&time1, &time2); - -#ifdef SWIFT_DEBUG_TASKS - /* Time in ticks at the end of this step. */ - e->toc_step = getticks(); -#endif } /** diff --git a/src/engine.h b/src/engine.h index cfd656712b..65cb7f22a7 100644 --- a/src/engine.h +++ b/src/engine.h @@ -382,6 +382,7 @@ void engine_drift_all(struct engine *e); void engine_drift_top_multipoles(struct engine *e); void engine_reconstruct_multipoles(struct engine *e); void engine_print_stats(struct engine *e); +void engine_check_for_dumps(struct engine *e); void engine_dump_snapshot(struct engine *e); void engine_init_output_lists(struct engine *e, struct swift_params *params); void engine_init(struct engine *e, struct space *s, struct swift_params *params, -- GitLab