From bd14a5806f273479341c48a3c7172a528312e641 Mon Sep 17 00:00:00 2001 From: Andreas Gattringer <gattringera@a772-cvl-ws23.biodiv.univie.ac.at> Date: Wed, 28 Jun 2023 15:40:21 +0200 Subject: [PATCH] debug generation update --- src/modules/butterflies/butterflies_actions.c | 10 ++++++++++ src/modules/butterflies/butterflies_generations.c | 8 ++++++-- src/modules/butterflies/butterflies_stats.c | 5 +++++ src/modules/butterflies/butterflies_stats.h | 2 ++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/modules/butterflies/butterflies_actions.c b/src/modules/butterflies/butterflies_actions.c index cd3b954..2dc79f5 100644 --- a/src/modules/butterflies/butterflies_actions.c +++ b/src/modules/butterflies/butterflies_actions.c @@ -328,6 +328,10 @@ enum action_status bf_action_generation_update(struct cats_grid *grid, struct ca int module_id = CATS_MODULE_ID; struct grid_data_butterflies *data = grid->grid_modules[module_id].module_data; struct conf_data_butterflies *module_conf = CATS_MODULE_DATA; + const int64_t egg_cells_id = module_conf->stat_ids[BF_CELLS_WITH_EGGS]; + const int64_t egg_cells_removed_id = module_conf->stat_ids[BF_CELLS_WITH_EGGS]; + grid->stats.custom_stats[egg_cells_id] = 0; + grid->stats.custom_stats[egg_cells_removed_id] = 0; data->generation_current = module_conf->generations_max; log_message(LOG_IMPORTANT, "resetting generation to %d", module_conf->generations_max); @@ -338,6 +342,12 @@ enum action_status bf_action_generation_update(struct cats_grid *grid, struct ca } threaded_action(&bf_area_generation_update, grid, conf, TS_DEFAULT); + + int64_t cells_with_eggs = grid->stats.custom_stats[egg_cells_id]; + int64_t cells_with_eggs_removed = grid->stats.custom_stats[egg_cells_removed_id]; + log_message(LOG_INFO, "%ld cells with eggs left, %ld cells with eggs removed", cells_with_eggs, cells_with_eggs_removed); + grid->stats.custom_stats[egg_cells_id] = 0; + grid->stats.custom_stats[egg_cells_removed_id] = 0; return ACTION_RUN; } diff --git a/src/modules/butterflies/butterflies_generations.c b/src/modules/butterflies/butterflies_generations.c index f234318..b046bce 100644 --- a/src/modules/butterflies/butterflies_generations.c +++ b/src/modules/butterflies/butterflies_generations.c @@ -21,9 +21,11 @@ void bf_area_generation_update(struct cats_grid *grid, struct cats_thread_info * const cats_dt_coord start_col = ts->area.start_col; const cats_dt_coord end_col = ts->area.end_col; + struct statistics *stats = &ts->stats[grid->id]; const cats_dt_rates ot = grid->param.OT; - + const int64_t egg_cells_id = module_conf->stat_ids[BF_CELLS_WITH_EGGS]; + const int64_t egg_cells_removed_id = module_conf->stat_ids[BF_CELLS_WITH_EGGS]; int64_t cells_with_eggs = 0; int64_t cells_with_eggs_removed = 0; @@ -64,5 +66,7 @@ void bf_area_generation_update(struct cats_grid *grid, struct cats_thread_info * } } - log_message(LOG_INFO, "thread %d: %ld cells with eggs removed, %ld cells with eggs left", ts->id, cells_with_eggs_removed, cells_with_eggs); + stats->custom_stats[egg_cells_id] += cells_with_eggs; + stats->custom_stats[egg_cells_removed_id] += cells_with_eggs_removed; + } \ No newline at end of file diff --git a/src/modules/butterflies/butterflies_stats.c b/src/modules/butterflies/butterflies_stats.c index 030633f..ce77d1b 100644 --- a/src/modules/butterflies/butterflies_stats.c +++ b/src/modules/butterflies/butterflies_stats.c @@ -40,6 +40,11 @@ const char *bf_get_stats_field_name(enum butterfly_stats which) case BF_STAT_MAX: break; + case BF_CELLS_WITH_EGGS: + return "cells with eggs"; + case BF_CELLS_WITH_EGGS_REMOVED: + return "removed cells with eggs"; + } log_message(LOG_ERROR, "unknown butterfly stats name with id %d", which); diff --git a/src/modules/butterflies/butterflies_stats.h b/src/modules/butterflies/butterflies_stats.h index 2a19841..0922349 100644 --- a/src/modules/butterflies/butterflies_stats.h +++ b/src/modules/butterflies/butterflies_stats.h @@ -18,6 +18,8 @@ enum butterfly_stats { BF_POPULATED_AT_DISPERSAL, BF_RANDOM_WALK_COUNT, BF_RANDOM_WALK_STEP_COUNT, + BF_CELLS_WITH_EGGS, + BF_CELLS_WITH_EGGS_REMOVED, BF_STAT_MAX }; -- GitLab