diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index 65384be73c02dcdde36cd63e87577e946693b8f9..e45fe6b2d6f5a6f7fa8e6135c445692c87e4e1f2 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -90,8 +90,12 @@ Snapshots: UnitTemp_in_cgs: 1 # (Optional) Unit system for the outputs (Kelvin) output_list_on: 0 # (Optional) Enable the output list output_list: snaplist.txt # (Optional) File containing the output times (see documentation in "Parameter File" section) - logger_max_steps: 10 # (Optional) Number of particle steps between two chunk writing if using logger - logger_size: 10. # buffer size of the logger file in MB + +# Parameters governing the logger snapshot system +Logger: + max_steps: 10 # (Optional) Update the particle log every this many updates + mmaped_buffer_size: .01 # buffer size in GB + basename: indice # Common part of the filenames # Parameters governing the conserved quantities statistics Statistics: diff --git a/src/dump.c b/src/dump.c index 5a31af64837fda56da56c9592accc0fbdaf712ee..bc57e7783287d792e32ade6d667df0568bae5d6c 100644 --- a/src/dump.c +++ b/src/dump.c @@ -50,7 +50,7 @@ void *dump_get(struct dump *d, size_t count, size_t *offset) { size_t local_offset = atomic_add(&d->count, count); #ifdef SWIFT_DEBUG_CHECKS if (d->count > d->size) - error("A new dump file should be created"); + error("A new dump file should have been created."); #endif *offset = local_offset + d->file_offset; return (char *)d->data + local_offset; diff --git a/src/engine.c b/src/engine.c index 2a05248cc42721335c31fbb6bc15ba9568335a11..87f34ac765cfb09e5f34ac3e9d203285670cff23 100644 --- a/src/engine.c +++ b/src/engine.c @@ -5216,7 +5216,7 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs, #ifdef WITH_LOGGER logger_log_timestamp(e->ti_old, &e->logger_time_offset, e->logger_dump); - logger_ensure_size(e->total_nr_parts, e->logger_size); + logger_ensure_size(e->total_nr_parts, e->logger_buffer_size); #endif /* Now, launch the calculation */ @@ -5468,11 +5468,12 @@ void engine_step(struct engine *e) { ((double)e->total_nr_gparts) * e->gravity_properties->rebuild_frequency)) e->forcerebuild = 1; - #ifdef WITH_LOGGER + +#ifdef WITH_LOGGER logger_log_timestamp(e->ti_current, &e->logger_time_offset, e->logger_dump); - logger_ensure_size(e->total_nr_parts, e->logger_size); - dump_ensure(e->logger_dump, e->logger_size); + logger_ensure_size(e->total_nr_parts, e->logger_buffer_size); + dump_ensure(e->logger_dump, e->logger_buffer_size); #endif /* Are we drifting everything (a la Gadget/GIZMO) ? */ @@ -6524,8 +6525,7 @@ void engine_dump_index(struct engine *e) { #endif /* Dump... */ - /* Should use snapshotBaseName for the index name */ - write_index_single(e, e->snapshotBaseName, e->internal_units, + write_index_single(e, e->loggerBaseName, e->internal_units, e->snapshotUnits); e->dump_snapshot = 0; @@ -7334,7 +7334,7 @@ void engine_config(int restart, struct engine *e, struct swift_params *params, if (e->nodeID == 0) message("Expected output of over 9000\n Should write a real message..."); logger_write_file_header(e->logger_dump, e); - dump_ensure(e->logger_dump, e->logger_size); + dump_ensure(e->logger_dump, e->logger_buffer_size); e->logger_time_offset = 0; #endif diff --git a/src/engine.h b/src/engine.h index a253746b070f3af8f75ef38f9b64842ea30e69c6..7dc3860097f3daaad3a2541fca9097eccf7b276a 100644 --- a/src/engine.h +++ b/src/engine.h @@ -316,6 +316,9 @@ struct engine { /* Number of particle steps between dumping a chunk of data */ short int logger_max_steps; + /* Logger basename */ + char loggerBaseName[PARSER_MAX_LINE_SIZE]; + /* File name of the dump file */ struct dump *logger_dump; diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h index ad72d40ec0eb0e0c614c55f32fdf803041c33430..eda9015389b509e47141e972851408a076c53145 100644 --- a/src/hydro/Gadget2/hydro_part.h +++ b/src/hydro/Gadget2/hydro_part.h @@ -56,7 +56,7 @@ struct xpart { struct cooling_xpart_data cooling_data; #ifdef WITH_LOGGER - /* Number of time step since last output */ + /* Number of particle updates since last output */ short int last_output; #endif @@ -96,7 +96,7 @@ struct part { float entropy_dt; #ifdef WITH_LOGGER - /* offset at last writing */ + /* offset of last particle log entry */ size_t last_offset; #endif diff --git a/src/logger.c b/src/logger.c index 4f0f51b94cd2885249f51f684bf5c2fc3915ad1c..d1e79ad3d479c2dd00058ecb9becfefd731c3a45 100644 --- a/src/logger.c +++ b/src/logger.c @@ -208,7 +208,7 @@ void logger_log_part(const struct part *p, const unsigned int mask, size_t *offs error("You should not log particles as timestamps."); /* Start by computing the size of the message. */ - const int size = logger_size(mask); + const int size = logger_buffer_size(mask); /* Allocate a chunk of memory in the dump of the right size. */ size_t offset_new; @@ -289,7 +289,7 @@ void logger_log_gpart(const struct gpart *p, const unsigned int mask, size_t *of error("Can't log SPH quantities for gparts."); /* Start by computing the size of the message. */ - const int size = logger_size(mask); + const int size = logger_buffer_size(mask); /* Allocate a chunk of memory in the dump of the right size. */ size_t offset_new; @@ -338,7 +338,7 @@ void logger_log_gpart(const struct gpart *p, const unsigned int mask, size_t *of void logger_log_timestamp(integertime_t timestamp, size_t *offset, struct dump *dump) { /* Start by computing the size of the message. */ - const int size = logger_size(logger_mask_timestamp); + const int size = logger_buffer_size(logger_mask_timestamp); /* Allocate a chunk of memory in the dump of the right size. */ size_t offset_new; @@ -360,9 +360,9 @@ void logger_log_timestamp(integertime_t timestamp, size_t *offset, * @brief ensure that the input parameter logger size is large enough * * @param total_nr_nparts total number of particle - * @param logger_size requested file size upate + * @param logger_buffer_size requested file size upate */ -void logger_ensure_size(size_t total_nr_parts, size_t logger_size) { +void logger_ensure_size(size_t total_nr_parts, size_t logger_buffer_size) { size_t limit, i; struct logger_const log_const; logger_const_init(&log_const); @@ -377,7 +377,7 @@ void logger_ensure_size(size_t total_nr_parts, size_t logger_size) { limit *= total_nr_parts; - if (logger_size < limit) error("Need a larger logger size"); + if (logger_buffer_size < limit) error("Need a larger logger size"); logger_const_free(&log_const); }