diff --git a/src/csds_hashmap.h b/src/csds_hashmap.h index 1baa6df567cc928d35a6e2d29dafa2c53d35d504..fb0dc27ee2bb6cdfdeb6411a9bb0941840793b26 100644 --- a/src/csds_hashmap.h +++ b/src/csds_hashmap.h @@ -172,9 +172,8 @@ static uint64_t SIP64(const id_type *key) { SIPROUND; v0 ^= m; } - const int left = inlen & 7; uint64_t b = ((uint64_t)inlen) << 56; - switch (left) { + switch (inlen & 7) { case 7: b |= ((uint64_t)in[6]) << 48; break; diff --git a/src/csds_loader_io.h b/src/csds_loader_io.h index 3022de93f4c450d4e29902b1973e8ff61002f84d..55ec7ea984d8538232573d2e0b6ffcdbac27ed5a 100644 --- a/src/csds_loader_io.h +++ b/src/csds_loader_io.h @@ -29,6 +29,8 @@ #include <stdio.h> #include <stdlib.h> +#define CSDS_VERBOSE_TIMERS -1 + /* Structure for mapping a file. */ struct mapped_file { /* Mapped data. */ diff --git a/src/csds_reader.c b/src/csds_reader.c index fa41e0953fa3c990fc6bd1f319df451515123606..cf5efab39ab7aca6c822c14e4519fbc8b562fd17 100644 --- a/src/csds_reader.c +++ b/src/csds_reader.c @@ -830,6 +830,7 @@ void csds_reader_read_all_particles(struct csds_reader *reader, double time, const enum field_enum *fields_wanted, const int n_fields_wanted, void **output, const uint64_t *n_part) { + const ticks tic = getticks(); /* Read the gas */ if (n_part[swift_type_gas] != 0) { @@ -862,6 +863,11 @@ void csds_reader_read_all_particles(struct csds_reader *reader, double time, reader, time, interp_type, fields_wanted, n_fields_wanted, output, n_part, swift_type_stars); } + + /* Print the time */ + if (reader->verbose > 0 || reader->verbose == CSDS_VERBOSE_TIMERS) + message("took %.3f %s", clocks_from_ticks(getticks() - tic), + clocks_getunit()); } /** @@ -964,6 +970,8 @@ void csds_reader_read_particles_from_ids( const enum field_enum *fields_wanted, const int n_fields_wanted, void **output, uint64_t *n_part, long long **ids) { + const ticks tic = getticks(); + /* Read the gas */ if (n_part[swift_type_gas] != 0) { csds_reader_read_particles_from_ids_single_type( @@ -990,6 +998,11 @@ void csds_reader_read_particles_from_ids( reader, time, interp_type, fields_wanted, n_fields_wanted, output, n_part, swift_type_stars, ids[swift_type_stars]); } + + /* Print the time */ + if (reader->verbose > 0 || reader->verbose == CSDS_VERBOSE_TIMERS) + message("took %.3f %s", clocks_from_ticks(getticks() - tic), + clocks_getunit()); } /** diff --git a/src/csds_reader_generate_index.c b/src/csds_reader_generate_index.c index f12c8dafe81d14ea7ee91d79aac04ff32b34f7e8..854ad91cdaf80279445d5469c4e8cd9536d4a45c 100644 --- a/src/csds_reader_generate_index.c +++ b/src/csds_reader_generate_index.c @@ -295,6 +295,7 @@ void csds_reader_write_index(const struct csds_reader *reader, size_t csds_reader_get_initial_state(const struct csds_reader *reader, struct csds_hashmap **current_state, struct time_record *time_record) { + const ticks tic = getticks(); /* Get a few variables. */ const struct csds_logfile *log = &reader->log; @@ -364,6 +365,11 @@ size_t csds_reader_get_initial_state(const struct csds_reader *reader, offset += record_size + size_record_header; } + /* Print the time */ + if (reader->verbose > 0 || reader->verbose == CSDS_VERBOSE_TIMERS) + message("took %.3f %s", clocks_from_ticks(getticks() - tic), + clocks_getunit()); + return offset_max; } @@ -474,7 +480,7 @@ void csds_reader_update_particles_to_next_index_mapper(void *map_data, index_data->offset = last_full_offset; } - if (reader->verbose) { + if (reader->verbose > 0) { /* Update the counter */ atomic_add_f(&data->percentage, num_elements / (float)data->number_particles); @@ -525,16 +531,15 @@ size_t csds_reader_update_state_to_next_index( /* Look for all the created / removed particles */ size_t offset = init_offset; int step = 0; - if (reader->verbose) printf("\n"); + if (reader->verbose > 0) printf("\n"); /* Record the initial time */ - const int init_time = - clocks_diff_ticks(getticks(), clocks_start_ticks) / 1000.0; + const ticks tic = getticks(); while (offset < time_record.offset) { /* Print status */ - if (reader->verbose) { + if (reader->verbose > 0) { step += 1; if (step % 100 == 0) { step = 0; @@ -547,6 +552,9 @@ size_t csds_reader_update_state_to_next_index( /* Get the remaining time */ const int current_time = clocks_diff_ticks(getticks(), clocks_start_ticks) / 1000.0; + const int init_time = + clocks_diff_ticks(tic, clocks_start_ticks) / 1000.0; + const int remaining_time = (current_time - init_time) * (100. - percent) / percent; @@ -615,10 +623,15 @@ size_t csds_reader_update_state_to_next_index( } /* Cleanup output */ - if (reader->verbose) { + if (reader->verbose > 0) { printf("\n"); } + /* Print the time */ + if (reader->verbose > 0 || reader->verbose == CSDS_VERBOSE_TIMERS) + message("Finding new/removed particles took %.3f %s", + clocks_from_ticks(getticks() - tic), clocks_getunit()); + /* Create the threadpool */ struct threadpool tp; threadpool_init(&tp, reader->params.number_threads); @@ -641,6 +654,9 @@ size_t csds_reader_update_state_to_next_index( csds_hashmap_get_number_buckets(current_state[type]); } + /* Record the time */ + const ticks tic2 = getticks(); + /* Update the offsets of current_state * No need to update the others as they contain * data about when particles are removed/created*/ @@ -653,7 +669,12 @@ size_t csds_reader_update_state_to_next_index( } /* Cleanup the output */ - if (reader->verbose) printf("\n"); + if (reader->verbose > 0) printf("\n"); + + /* Print the time */ + if (reader->verbose > 0 || reader->verbose == CSDS_VERBOSE_TIMERS) + message("Updating particles took %.3f %s", + clocks_from_ticks(getticks() - tic2), clocks_getunit()); /* Free the memory */ threadpool_clean(&tp);