From 4a935df359f61133a8c01c8b6bb56c773fec15f1 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Wed, 8 Nov 2017 10:13:28 +0000 Subject: [PATCH] Add information to stdout and timestep.txt about what happened in the step (rebuild, repartition, snapshot, ...) --- examples/main.c | 4 ++-- src/engine.c | 36 ++++++++++++++++++++++++++++++------ src/engine.h | 27 +++++++++++++++++++++++---- 3 files changed, 55 insertions(+), 12 deletions(-) diff --git a/examples/main.c b/examples/main.c index b09eefdbce..ea43c35b5f 100644 --- a/examples/main.c +++ b/examples/main.c @@ -690,9 +690,9 @@ int main(int argc, char *argv[]) { /* Legend */ if (myrank == 0) - printf("# %6s %14s %14s %10s %10s %10s %16s [%s]\n", "Step", "Time", + printf("# %6s %14s %14s %12s %12s %12s %16s [%s] %6s\n", "Step", "Time", "Time-step", "Updates", "g-Updates", "s-Updates", "Wall-clock time", - clocks_getunit()); + clocks_getunit(), "Props"); /* File for the timers */ if (with_verbose_timers) timers_open_file(myrank); diff --git a/src/engine.c b/src/engine.c index 35efcb1daf..53ade0ed33 100644 --- a/src/engine.c +++ b/src/engine.c @@ -880,6 +880,9 @@ void engine_redistribute(struct engine *e) { nodeID, nr_parts, nr_sparts, nr_gparts, my_cells); } + /* Flag that a redistribute has taken place */ + e->step_props |= engine_step_prop_redistribute; + if (e->verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit()); @@ -945,6 +948,9 @@ void engine_repartition(struct engine *e) { /* Tell the engine it should re-build whenever possible */ e->forcerebuild = 1; + /* Flag that a repartition has taken place */ + e->step_props |= engine_step_prop_repartition; + if (e->verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit()); @@ -3098,6 +3104,9 @@ void engine_rebuild(struct engine *e, int clean_h_values) { /* Print the status of the system */ // if (e->verbose) engine_print_task_counts(e); + /* Flag that a rebuild has taken place */ + e->step_props |= engine_step_prop_rebuild; + if (e->verbose) message("took %.3f %s.", clocks_from_ticks(getticks() - tic), clocks_getunit()); @@ -3697,14 +3706,14 @@ void engine_step(struct engine *e) { if (e->nodeID == 0) { /* Print some information to the screen */ - printf(" %6d %14e %14e %10zu %10zu %10zu %21.3f\n", e->step, e->time, + printf(" %6d %14e %14e %12zu %12zu %12zu %21.3f %6d\n", e->step, e->time, e->timeStep, e->updates, e->g_updates, e->s_updates, - e->wallclock_time); + e->wallclock_time, e->step_props); fflush(stdout); - fprintf(e->file_timesteps, " %6d %14e %14e %10zu %10zu %10zu %21.3f\n", + fprintf(e->file_timesteps, " %6d %14e %14e %12zu %12zu %12zu %21.3f %6d\n", e->step, e->time, e->timeStep, e->updates, e->g_updates, - e->s_updates, e->wallclock_time); + e->s_updates, e->wallclock_time, e->step_props); fflush(e->file_timesteps); } @@ -3716,6 +3725,7 @@ void engine_step(struct engine *e) { e->time = e->ti_current * e->timeBase + e->timeBegin; e->timeOld = e->ti_old * e->timeBase + e->timeBegin; e->timeStep = (e->ti_current - e->ti_old) * e->timeBase; + e->step_props = engine_step_prop_none; /* Prepare the tasks to be launched, rebuild or repartition if needed. */ engine_prepare(e); @@ -3805,6 +3815,9 @@ void engine_step(struct engine *e) { /* ... and find the next output time */ engine_compute_next_snapshot_time(e); + + /* Flag that we dumped a snapshot */ + e->step_props |= engine_step_prop_snapshot; } /* Save some statistics */ @@ -3815,6 +3828,9 @@ void engine_step(struct engine *e) { /* and move on */ e->timeLastStatistics += e->deltaTimeStatistics; + + /* Flag that we dumped some statistics */ + e->step_props |= engine_step_prop_statistics; } /* Now apply all the collected time step updates and particle counts. */ @@ -4353,6 +4369,7 @@ void engine_init(struct engine *e, struct space *s, e->reparttype = reparttype; e->dump_snapshot = 0; e->save_stats = 0; + e->step_props = engine_step_prop_none; e->links = NULL; e->nr_links = 0; e->timeBegin = parser_get_param_double(params, "TimeIntegration:time_begin"); @@ -4576,9 +4593,16 @@ void engine_init(struct engine *e, struct space *s, e->hydro_properties->delta_neighbours, e->hydro_properties->eta_neighbours); - fprintf(e->file_timesteps, "# %6s %14s %14s %10s %10s %10s %16s [%s]\n", + fprintf(e->file_timesteps, + "# Step Properties: Rebuild=%d, Redistribute=%d, Repartition=%d, " + "Statistics=%d, Snapshot=%d\n", + engine_step_prop_rebuild, engine_step_prop_redistribute, + engine_step_prop_repartition, engine_step_prop_statistics, + engine_step_prop_snapshot); + + fprintf(e->file_timesteps, "# %6s %14s %14s %12s %12s %12s %16s [%s] %6s\n", "Step", "Time", "Time-step", "Updates", "g-Updates", "s-Updates", - "Wall-clock time", clocks_getunit()); + "Wall-clock time", clocks_getunit(), "Props"); fflush(e->file_timesteps); } diff --git a/src/engine.h b/src/engine.h index 2b5a4eee7c..b5ad53290d 100644 --- a/src/engine.h +++ b/src/engine.h @@ -51,7 +51,9 @@ #include "task.h" #include "units.h" -/* Some constants. */ +/** + * @brief The different policies the #engine can follow. + */ enum engine_policy { engine_policy_none = 0, engine_policy_rand = (1 << 0), @@ -74,7 +76,19 @@ enum engine_policy { #define engine_maxpolicy 15 extern const char *engine_policy_names[]; -#define engine_queue_scale 1.2 +/** + * @brief The different unusual events that can take place in a time-step. + */ +enum engine_step_properties { + engine_step_prop_none = 0, + engine_step_prop_rebuild = (1 << 0), + engine_step_prop_redistribute = (1 << 1), + engine_step_prop_repartition = (1 << 2), + engine_step_prop_statistics = (1 << 3), + engine_step_prop_snapshot = (1 << 4) +}; + +/* Some constants */ #define engine_maxproxies 64 #define engine_tasksreweight 1 #define engine_parts_size_grow 1.05 @@ -83,7 +97,9 @@ extern const char *engine_policy_names[]; #define engine_default_timesteps_file_name "timesteps" #define engine_max_parts_per_ghost 1000 -/* The rank of the engine as a global variable (for messages). */ +/** + * @brief The rank of the engine as a global variable (for messages). + */ extern int engine_rank; /* Data structure for the engine. */ @@ -143,9 +159,12 @@ struct engine { /* Maximal ti_beg for the next time-step */ integertime_t ti_beg_max; - /* Number of particles updated */ + /* Number of particles updated in the previous step */ size_t updates, g_updates, s_updates; + /* Properties of the previous step */ + enum engine_step_properties step_props; + /* Total numbers of particles in the system. */ size_t total_nr_parts, total_nr_gparts; -- GitLab