diff --git a/src/collectgroup.c b/src/collectgroup.c index 5e1ae781850be305a3e9a48850c79a49bddafc9b..c745528a827c2327db203091c4ec78b60b227683 100644 --- a/src/collectgroup.c +++ b/src/collectgroup.c @@ -55,6 +55,9 @@ struct mpicollectgroup1 { float tasks_per_cell_max; struct star_formation_history sfh; float runtime; +#ifdef WITH_CSDS + float csds_file_size_gb; +#endif }; /* Forward declarations. */ @@ -188,6 +191,7 @@ void collectgroup1_apply(const struct collectgroup1 *grp1, struct engine *e) { * @param tasks_per_cell the used number of tasks per cell. * @param sfh The star formation history logger * @param runtime The runtime of rank in hours. + * @param csds_file_size_gb The current size of the CSDS. */ void collectgroup1_init( struct collectgroup1 *grp1, size_t updated, size_t g_updated, @@ -200,7 +204,8 @@ void collectgroup1_init( integertime_t ti_sinks_beg_max, integertime_t ti_black_holes_end_min, integertime_t ti_black_holes_beg_max, int forcerebuild, long long total_nr_cells, long long total_nr_tasks, float tasks_per_cell, - const struct star_formation_history sfh, float runtime) { + const struct star_formation_history sfh, float runtime, + float csds_file_size_gb) { grp1->updated = updated; grp1->g_updated = g_updated; @@ -228,6 +233,9 @@ void collectgroup1_init( grp1->tasks_per_cell_max = tasks_per_cell; grp1->sfh = sfh; grp1->runtime = runtime; +#ifdef WITH_CSDS + grp1->csds_file_size_gb = csds_file_size_gb; +#endif } /** @@ -270,6 +278,9 @@ void collectgroup1_reduce(struct collectgroup1 *grp1) { mpigrp11.tasks_per_cell_max = grp1->tasks_per_cell_max; mpigrp11.sfh = grp1->sfh; mpigrp11.runtime = grp1->runtime; +#ifdef WITH_CSDS + mpigrp11.csds_file_size_gb = grp1->csds_file_size_gb; +#endif struct mpicollectgroup1 mpigrp12; if (MPI_Allreduce(&mpigrp11, &mpigrp12, 1, mpicollectgroup1_type, @@ -303,6 +314,9 @@ void collectgroup1_reduce(struct collectgroup1 *grp1) { grp1->tasks_per_cell_max = mpigrp12.tasks_per_cell_max; grp1->sfh = mpigrp12.sfh; grp1->runtime = mpigrp12.runtime; +#ifdef WITH_CSDS + grp1->csds_file_size_gb = mpigrp12.csds_file_size_gb; +#endif #endif } @@ -373,6 +387,10 @@ static void doreduce1(struct mpicollectgroup1 *mpigrp11, /* Use the maximum runtime as the global runtime. */ mpigrp11->runtime = max(mpigrp11->runtime, mpigrp12->runtime); + +#ifdef WITH_CSDS + mpigrp11->csds_file_size_gb += mpigrp12->csds_file_size_gb; +#endif } /** diff --git a/src/collectgroup.h b/src/collectgroup.h index c08b092799802bdcffa669cd888b2a59d8212482..3baa192649a115ca6f08d4ca9a907a9c2b44b672 100644 --- a/src/collectgroup.h +++ b/src/collectgroup.h @@ -63,6 +63,11 @@ struct collectgroup1 { /* Global runtime of application in hours. */ float runtime; + +#ifdef WITH_CSDS + /* Filesize used by the CSDS (does not correspond to the allocated one) */ + float csds_file_size_gb; +#endif }; void collectgroup_init(void); @@ -78,7 +83,8 @@ void collectgroup1_init( integertime_t ti_sinks_beg_max, integertime_t ti_black_holes_end_min, integertime_t ti_black_holes_beg_max, int forcerebuild, long long total_nr_cells, long long total_nr_tasks, float tasks_per_cell, - const struct star_formation_history sfh, float runtime); + const struct star_formation_history sfh, float runtime, + float csds_file_size_gb); void collectgroup1_reduce(struct collectgroup1 *grp1); #ifdef WITH_MPI void mpicollect_free_MPI_type(void); diff --git a/src/csds.c b/src/csds.c index 6cbe48c707b1f128c2fe5668c760d78cbdd2bb3c..908dfe590d115f33546779411cba3320d3f8cb3c 100644 --- a/src/csds.c +++ b/src/csds.c @@ -80,6 +80,18 @@ char csds_file_format[csds_format_size] = "SWIFT_CSDS"; /* Index of the timestamp in the list of masks */ #define csds_index_timestamp 1 +/** + * @brief Print the current size used by the logger in GB (not the allocated + * one). + * + * @param log The #csds_writer. + * @param e The #engine. + */ +float csds_get_current_filesize_used_gb(const struct csds_writer *log, + const struct engine *e) { + return log->dump.count / (1024.f * 1024.f * 1024.f); +} + /** * @brief Write the header of a record (offset + mask). * diff --git a/src/csds.h b/src/csds.h index 311a031b165bad34f2c98f43011c903ce3f762b6..b539c308d89c9882785f21a68dd515d18dab7733 100644 --- a/src/csds.h +++ b/src/csds.h @@ -172,6 +172,8 @@ struct csds_part_data { }; /* Function prototypes. */ +float csds_get_current_filesize_used_gb(const struct csds_writer *log, + const struct engine *e); void csds_log_all_particles(struct csds_writer *log, const struct engine *e, int first_log); void csds_log_part(struct csds_writer *log, const struct part *p, diff --git a/src/engine.c b/src/engine.c index 194bf9c4769b786706ce210e806535c3780eee89..e8331d8654bbd2008de11225cfc5c6d75fbf51cf 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2412,6 +2412,12 @@ void engine_step(struct engine *e) { error("Obtained a time-step of size 0"); #endif +#ifdef WITH_CSDS + if (e->policy & engine_policy_csds && e->verbose) + message("The CSDS currently uses %f GB of storage", + e->collect_group1.csds_file_size_gb); +#endif + /********************************************************/ /* OK, we are done with the regular stuff. Time for i/o */ /********************************************************/ diff --git a/src/engine_collect_end_of_step.c b/src/engine_collect_end_of_step.c index e8fb785981c2c7dac2493cf032d093b7edb8c0d8..4364c328bf2d410468e4a68aa25b149369ef741b 100644 --- a/src/engine_collect_end_of_step.c +++ b/src/engine_collect_end_of_step.c @@ -45,6 +45,7 @@ struct end_of_step_data { struct engine *e; struct star_formation_history sfh; float runtime; + float csds_file_size_gb; }; /** @@ -495,7 +496,13 @@ void engine_collect_end_of_step(struct engine *e, int apply) { data.ti_stars_end_min = max_nr_timesteps, data.ti_stars_beg_max = 0; data.ti_sinks_end_min = max_nr_timesteps, data.ti_sinks_beg_max = 0; data.ti_black_holes_end_min = max_nr_timesteps, - data.ti_black_holes_beg_max = 0, data.e = e; + data.ti_black_holes_beg_max = 0, data.e = e, data.csds_file_size_gb = 0; + +#ifdef WITH_CSDS + /* Get the file size from the CSDS. */ + if (e->policy & engine_policy_csds) + data.csds_file_size_gb = csds_get_current_filesize_used_gb(e->csds, e); +#endif /* Need to use a consistent check of the hours since we started. */ data.runtime = clocks_get_hours_since_start(); @@ -526,7 +533,7 @@ void engine_collect_end_of_step(struct engine *e, int apply) { data.ti_sinks_end_min, data.ti_sinks_beg_max, data.ti_black_holes_end_min, data.ti_black_holes_beg_max, e->forcerebuild, e->s->tot_cells, e->sched.nr_tasks, (float)e->sched.nr_tasks / (float)e->s->tot_cells, - data.sfh, data.runtime); + data.sfh, data.runtime, data.csds_file_size_gb); /* Aggregate collective data from the different nodes for this step. */ #ifdef WITH_MPI