From 20f107e92e4c95c5618e59d82d28c0dc07544a43 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Sat, 25 Aug 2018 12:37:47 +0100 Subject: [PATCH] Assign cellID to the top-level cells. Track the send and recvs on step 43. --- src/engine.c | 39 +++++++++++++++++++++++++++++++++++++++ src/space.c | 22 ++++++++++++++++++---- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/engine.c b/src/engine.c index ffe61d2b3f..a3d4a781b7 100644 --- a/src/engine.c +++ b/src/engine.c @@ -94,6 +94,8 @@ FILE* file_dump; FILE* file_tasks; +FILE* file_send; +FILE* file_recv; const char *engine_policy_names[] = {"none", "rand", @@ -3851,6 +3853,35 @@ void engine_print_task_counts(struct engine *e) { if (tasks[k].type == task_type_recv && tasks[k].subtype == task_subtype_tend) ++count_recv_tiend[tasks[k].ci->nodeID]; + + + if (tasks[k].type == task_type_send && + tasks[k].subtype == task_subtype_gpart) { + + int from = engine_rank; + int to = tasks[k].cj->nodeID; + + if((from == 3 && to == 0)) { + fprintf(file_send, "Sending cell ci=%d cj=%d to rank 3 (depth= %d %d)\n", + tasks[k].ci->cellID, tasks[k].cj->cellID, tasks[k].ci->depth, tasks[k].cj->depth); + fflush(file_send); + } + } + + if (tasks[k].type == task_type_recv && + tasks[k].subtype == task_subtype_gpart) { + + int to = engine_rank; + int from = tasks[k].ci->nodeID; + + if(to == 0 && from == 3) { + fprintf(file_recv, "Receiving cell ci=%d from rank 3 (depth= %d)\n", + tasks[k].ci->cellID, tasks[k].ci->depth); + fflush(file_recv); + + } + } + } } message("Total = %d (per cell = %d)", nr_tasks, @@ -4791,6 +4822,8 @@ void engine_step(struct engine *e) { fprintf(file_dump, "#################### Step %d #####################\n\n\n", e->step); fprintf(file_tasks, "#################### Step %d #####################\n\n\n", e->step); + fprintf(file_send, "#################### Step %d #####################\n\n\n", e->step); + fprintf(file_recv, "#################### Step %d #####################\n\n\n", e->step); /* When restarting, move everyone to the current time. */ if (e->restarting) engine_drift_all(e); @@ -5939,6 +5972,12 @@ void engine_config(int restart, struct engine *e, struct swift_params *params, sprintf(buffer, "tasks_%d.txt", engine_rank); file_tasks = fopen(buffer, "w"); + sprintf(buffer, "send_%d.txt", engine_rank); + file_send = fopen(buffer, "w"); + + sprintf(buffer, "recv_%d.txt", engine_rank); + file_recv = fopen(buffer, "w"); + /* Initialise VELOCIraptor. */ if (e->policy & engine_policy_structure_finding) { parser_get_param_string(params, "StructureFinding:basename", diff --git a/src/space.c b/src/space.c index 3c0fc9b006..7e85f5cdc4 100644 --- a/src/space.c +++ b/src/space.c @@ -208,6 +208,9 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements, c->ti_hydro_end_max = -1; c->ti_gravity_end_min = -1; c->ti_gravity_end_max = -1; +#ifdef SWIFT_DEBUG_CHECKS + c->cellID = 0; +#endif if (s->gravity) bzero(c->multipole, sizeof(struct gravity_tensors)); for (int i = 0; i < 13; i++) if (c->sort[i] != NULL) { @@ -338,7 +341,7 @@ void space_regrid(struct space *s, int verbose) { /* Are we about to allocate new top level cells without a regrid? * Can happen when restarting the application. */ - int no_regrid = (s->cells_top == NULL && oldnodeIDs == NULL); + const int no_regrid = (s->cells_top == NULL && oldnodeIDs == NULL); #endif /* Do we need to re-build the upper-level cells? */ @@ -428,8 +431,12 @@ void space_regrid(struct space *s, int verbose) { c->ti_old_part = ti_current; c->ti_old_gpart = ti_current; c->ti_old_multipole = ti_current; - c->cellID = -(last_cell_id++); if (s->gravity) c->multipole = &s->multipoles_top[cid]; + //#ifdef SWIFT_DEBUG_CHECKS + c->cellID = -last_cell_id; + last_cell_id++; + message("cid=%lld cellID=%d", cid, c->cellID); + //#endif } /* Be verbose about the change. */ @@ -921,6 +928,11 @@ void space_rebuild(struct space *s, int verbose) { c->ti_old_part = ti_current; c->ti_old_gpart = ti_current; c->ti_old_multipole = ti_current; + + c->cellID = -last_cell_id; + last_cell_id++; + message("cid=%d cellID=%d", k, c->cellID); + if (c->nodeID == engine_rank) { c->parts = finger; c->xparts = xfinger; @@ -2749,8 +2761,6 @@ void space_init(struct space *s, struct swift_params *params, #endif } - last_cell_id = 1; - /* Are we replicating the space ? */ if (replicate < 1) error("Value of 'InitialConditions:replicate' (%d) is too small", @@ -2904,6 +2914,10 @@ void space_init(struct space *s, struct swift_params *params, /* Init the space lock. */ if (lock_init(&s->lock) != 0) error("Failed to create space spin-lock."); +#ifdef SWIFT_DEBUG_CHECKS + last_cell_id = 1; +#endif + /* Build the cells recursively. */ if (!dry_run) space_regrid(s, verbose); } -- GitLab