diff --git a/examples/main.c b/examples/main.c index 57716c48574d5fcfc30b163907b7d7691616b84e..a66c9bb0c072e617b0ea761c6ff68202973baa47 100644 --- a/examples/main.c +++ b/examples/main.c @@ -941,15 +941,8 @@ int main(int argc, char *argv[]) { #endif /* And initialize the engine with the space and policies. */ - if (myrank == 0) clocks_gettime(&tic); engine_config(/*restart=*/1, /*fof=*/0, &e, params, nr_nodes, myrank, nr_threads, nr_pool_threads, with_aff, talking, restart_file); - if (myrank == 0) { - clocks_gettime(&toc); - message("engine_config took %.3f %s.", clocks_diff(&tic, &toc), - clocks_getunit()); - fflush(stdout); - } /* Check if we are already done when given steps on the command-line. */ if (e.step >= nsteps && nsteps > 0) @@ -1416,7 +1409,6 @@ int main(int argc, char *argv[]) { if (with_rt) engine_policies |= engine_policy_rt; /* Initialize the engine with the space and policies. */ - if (myrank == 0) clocks_gettime(&tic); engine_init(&e, &s, params, output_options, N_total[swift_type_gas], N_total[swift_type_count], N_total[swift_type_sink], N_total[swift_type_stars], N_total[swift_type_black_hole], @@ -1431,13 +1423,6 @@ int main(int argc, char *argv[]) { engine_config(/*restart=*/0, /*fof=*/0, &e, params, nr_nodes, myrank, nr_threads, nr_pool_threads, with_aff, talking, restart_file); - if (myrank == 0) { - clocks_gettime(&toc); - message("engine_init took %.3f %s.", clocks_diff(&tic, &toc), - clocks_getunit()); - fflush(stdout); - } - /* Compute some stats for the star formation */ if (with_star_formation) { star_formation_first_init_stats(&starform, &e); diff --git a/examples/main_fof.c b/examples/main_fof.c index c7f40980b6b7d3311b9c24b8f46eb2000645fa2f..a3dcbcc1dea2045bd0b171195412940f4a054c47 100644 --- a/examples/main_fof.c +++ b/examples/main_fof.c @@ -633,7 +633,6 @@ int main(int argc, char *argv[]) { if (with_cosmology) engine_policies |= engine_policy_cosmology; /* Initialize the engine with the space and policies. */ - if (myrank == 0) clocks_gettime(&tic); engine_init( &e, &s, params, output_options, N_total[swift_type_gas], N_total[swift_type_count], N_total[swift_type_sink], @@ -650,13 +649,6 @@ int main(int argc, char *argv[]) { engine_config(/*restart=*/0, /*fof=*/1, &e, params, nr_nodes, myrank, nr_threads, nr_threads, with_aff, talking, NULL); - if (myrank == 0) { - clocks_gettime(&toc); - message("engine_init took %.3f %s.", clocks_diff(&tic, &toc), - clocks_getunit()); - fflush(stdout); - } - /* Get some info to the user. */ if (myrank == 0) { const long long N_DM = N_total[swift_type_dark_matter] + diff --git a/src/engine.c b/src/engine.c index e8331d8654bbd2008de11225cfc5c6d75fbf51cf..d9a88253a921da014ce21703731ebf7d050cceaf 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2795,6 +2795,9 @@ void engine_init( const struct chemistry_global_data *chemistry, struct fof_props *fof_properties, struct los_props *los_properties) { + struct clocks_time tic, toc; + if (engine_rank == 0) clocks_gettime(&tic); + /* Clean-up everything */ bzero(e, sizeof(struct engine)); @@ -2905,13 +2908,6 @@ void engine_init( e->total_nr_cells = 0; e->total_nr_tasks = 0; -#if defined(WITH_CSDS) - if (e->policy & engine_policy_csds) { - e->csds = (struct csds_writer *)malloc(sizeof(struct csds_writer)); - csds_init(e->csds, e, params); - } -#endif - #ifdef SWIFT_GRAVITY_FORCE_CHECKS e->force_checks_only_all_active = parser_get_opt_param_int(params, "ForceChecks:only_when_all_active", 0); @@ -3010,6 +3006,20 @@ void engine_init( } else { e->neutrino_mass_conversion_factor = 0.f; } + + if (engine_rank == 0) { + clocks_gettime(&toc); + message("took %.3f %s.", clocks_diff(&tic, &toc), clocks_getunit()); + fflush(stdout); + } + + /* Initialize the CSDS (already timed, not need to include it) */ +#if defined(WITH_CSDS) + if (e->policy & engine_policy_csds) { + e->csds = (struct csds_writer *)malloc(sizeof(struct csds_writer)); + csds_init(e->csds, e, params); + } +#endif } /** diff --git a/src/engine_config.c b/src/engine_config.c index 951bfc06c9402b71e7b69dc2c03b0a4a46b85686..25c858bb6d70d142833c0f36b86db53bbc064af1 100644 --- a/src/engine_config.c +++ b/src/engine_config.c @@ -147,6 +147,9 @@ void engine_config(int restart, int fof, struct engine *e, int nr_task_threads, int nr_pool_threads, int with_aff, int verbose, const char *restart_file) { + struct clocks_time tic, toc; + if (nodeID == 0) clocks_gettime(&tic); + /* Store the values and initialise global fields. */ e->nodeID = nodeID; e->nr_threads = nr_task_threads; @@ -170,7 +173,6 @@ void engine_config(int restart, int fof, struct engine *e, e->restart_next = 0; e->restart_dt = 0; e->run_fof = 0; - engine_rank = nodeID; if (restart && fof) { error( @@ -921,4 +923,10 @@ void engine_config(int restart, int fof, struct engine *e, /* Wait for the runner threads to be in place. */ swift_barrier_wait(&e->wait_barrier); + + if (e->nodeID == 0) { + clocks_gettime(&toc); + message("took %.3f %s.", clocks_diff(&tic, &toc), clocks_getunit()); + fflush(stdout); + } } diff --git a/tools/timed_functions.py b/tools/timed_functions.py index 5c5740b98e1accf6f9f64e7898bdcc2c94f0867a..dcfb53deca213ab818d3842fd92106d771f9e251 100644 --- a/tools/timed_functions.py +++ b/tools/timed_functions.py @@ -53,7 +53,8 @@ labels = [ ["restart_read:", 0], ["engine_split:", 0], ["space_init", 0], - ["engine_init", 0], + ["engine_init:", 0], + ["engine_config:", 0], ["engine_repartition_trigger:", 0], ["VR Collecting top-level cell info", 3], ["VR Collecting particle info", 3],