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

Drift before dumping statistics.

parent a1f2133c
...@@ -2827,6 +2827,8 @@ void engine_print_stats(struct engine *e) { ...@@ -2827,6 +2827,8 @@ void engine_print_stats(struct engine *e) {
const ticks tic = getticks(); const ticks tic = getticks();
e->save_stats = 0;
struct statistics stats; struct statistics stats;
stats_init(&stats); stats_init(&stats);
...@@ -3065,12 +3067,6 @@ void engine_step(struct engine *e) { ...@@ -3065,12 +3067,6 @@ void engine_step(struct engine *e) {
/* Print the number of active tasks ? */ /* Print the number of active tasks ? */
if (e->verbose) engine_print_task_counts(e); if (e->verbose) engine_print_task_counts(e);
/* Save some statistics ? */
if (e->time - e->timeLastStatistics >= e->deltaTimeStatistics) {
engine_print_stats(e);
e->timeLastStatistics += e->deltaTimeStatistics;
}
/* Start all the tasks. */ /* Start all the tasks. */
TIMER_TIC; TIMER_TIC;
engine_launch(e, e->nr_threads); engine_launch(e, e->nr_threads);
...@@ -3085,13 +3081,18 @@ void engine_step(struct engine *e) { ...@@ -3085,13 +3081,18 @@ void engine_step(struct engine *e) {
e->forcerebuild = buff; e->forcerebuild = buff;
#endif #endif
/* Save some statistics ? */
if (e->time - e->timeLastStatistics >= e->deltaTimeStatistics) {
e->save_stats = 1;
}
/* Do we want a snapshot? */ /* Do we want a snapshot? */
if (e->ti_end_min >= e->ti_nextSnapshot && e->ti_nextSnapshot > 0) if (e->ti_end_min >= e->ti_nextSnapshot && e->ti_nextSnapshot > 0)
e->dump_snapshot = 1; e->dump_snapshot = 1;
/* Drift everybody (i.e. what has not yet been drifted) */ /* Drift everybody (i.e. what has not yet been drifted) */
/* to the current time */ /* to the current time */
if (e->dump_snapshot || e->forcerebuild || e->forcerepart) if (e->dump_snapshot || e->forcerebuild || e->forcerepart || e->save_stats)
engine_drift_all(e); engine_drift_all(e);
/* Write a snapshot ? */ /* Write a snapshot ? */
...@@ -3104,6 +3105,16 @@ void engine_step(struct engine *e) { ...@@ -3104,6 +3105,16 @@ void engine_step(struct engine *e) {
engine_compute_next_snapshot_time(e); engine_compute_next_snapshot_time(e);
} }
/* Save some statistics */
if (e->save_stats) {
/* Dump */
engine_print_stats(e);
/* and move on */
e->timeLastStatistics += e->deltaTimeStatistics;
}
/* Recover the (integer) end of the next time-step */ /* Recover the (integer) end of the next time-step */
engine_collect_timestep(e); engine_collect_timestep(e);
...@@ -3530,6 +3541,7 @@ void engine_init(struct engine *e, struct space *s, ...@@ -3530,6 +3541,7 @@ void engine_init(struct engine *e, struct space *s,
e->forcerepart = 0; e->forcerepart = 0;
e->reparttype = reparttype; e->reparttype = reparttype;
e->dump_snapshot = 0; e->dump_snapshot = 0;
e->save_stats = 0;
e->links = NULL; e->links = NULL;
e->nr_links = 0; e->nr_links = 0;
e->timeBegin = parser_get_param_double(params, "TimeIntegration:time_begin"); e->timeBegin = parser_get_param_double(params, "TimeIntegration:time_begin");
......
...@@ -191,6 +191,9 @@ struct engine { ...@@ -191,6 +191,9 @@ struct engine {
int forcerepart; int forcerepart;
enum repartition_type reparttype; enum repartition_type reparttype;
/* Need to dump some statistics ? */
int save_stats;
/* Need to dump a snapshot ? */ /* Need to dump a snapshot ? */
int dump_snapshot; int dump_snapshot;
......
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