diff --git a/examples/main.c b/examples/main.c index eaeb597a12c4430f912f6789a51e8876c5ac28f9..7a45dc1d94cafb91ee09d253d83881f4fddc0e98 100644 --- a/examples/main.c +++ b/examples/main.c @@ -893,7 +893,7 @@ int main(int argc, char *argv[]) { "from t=%.3e until t=%.3e with %d ranks, %d threads / rank and %d " "task queues / rank (dt_min=%.3e, dt_max=%.3e)...", e.time_begin, e.time_end, nr_nodes, e.nr_threads, e.sched.nr_queues, - e.dt_min, e.dt_max); + e.dt_min, e.dt_max); fflush(stdout); } } diff --git a/src/cell.c b/src/cell.c index d36cbbb500acef4282800b2cce8a72b58de0b807..e8038db1da43bd6e2f7d562f7a8b6d62f9286a04 100644 --- a/src/cell.c +++ b/src/cell.c @@ -1095,6 +1095,7 @@ void cell_clean_links(struct cell *c, void *data) { c->gradient = NULL; c->force = NULL; c->grav = NULL; + c->grav_mm = NULL; } /** @@ -2271,7 +2272,7 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) { } else if (t->type == task_type_pair) { cell_activate_subcell_grav_tasks(ci, cj, s); } else if (t->type == task_type_grav_mm) { - cell_activate_grav_mm_task(ci, cj, s); + error("Incorrectyl linked M-M task!"); } } @@ -2325,28 +2326,29 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) { } #endif } + } - if (t->type == task_type_grav_mm) { + for (struct link *l = c->grav_mm; l != NULL; l = l->next) { + struct task *t = l->t; + struct cell *ci = t->ci; + struct cell *cj = t->cj; + const int ci_active = cell_is_active_gravity(ci, e); + const int cj_active = (cj != NULL) ? cell_is_active_gravity(cj, e) : 0; #ifdef WITH_MPI - /* Activate the send/recv tasks. */ - if (ci_nodeID != nodeID) { - - /* If the foreign cell is active, we want its ti_end values. */ - if (ci_active) scheduler_activate(s, ci->recv_ti); - - /* If the local cell is active, send its ti_end values. */ - if (cj_active) scheduler_activate_send(s, cj->send_ti, ci_nodeID); - - } else if (cj_nodeID != nodeID) { + const int ci_nodeID = ci->nodeID; + const int cj_nodeID = (cj != NULL) ? cj->nodeID : -1; +#else + const int ci_nodeID = nodeID; + const int cj_nodeID = nodeID; +#endif - /* If the foreign cell is active, we want its ti_end values. */ - if (cj_active) scheduler_activate(s, cj->recv_ti); + if (t->type != task_type_grav_mm) error("Incorrectly linked gravity task!"); - /* If the local cell is active, send its ti_end values. */ - if (ci_active) scheduler_activate_send(s, ci->send_ti, cj_nodeID); - } -#endif + /* Only activate tasks that involve a local active cell. */ + if ((ci_active && ci_nodeID == nodeID) || + (cj_active && cj_nodeID == nodeID)) { + cell_activate_grav_mm_task(ci, cj, s); } } @@ -2420,7 +2422,8 @@ void cell_set_super_hydro(struct cell *c, struct cell *super_hydro) { void cell_set_super_gravity(struct cell *c, struct cell *super_gravity) { /* Are we in a cell with some kind of self/pair task ? */ - if (super_gravity == NULL && c->grav != NULL) super_gravity = c; + if (super_gravity == NULL && (c->grav != NULL || c->grav_mm != NULL)) + super_gravity = c; /* Set the super-cell */ c->super_gravity = super_gravity; diff --git a/src/cell.h b/src/cell.h index 31d525b02b49463563b21bf5aa904a8b4301f989..534f9d704dc28901044860bda8a0ae97cff5d945 100644 --- a/src/cell.h +++ b/src/cell.h @@ -216,6 +216,9 @@ struct cell { /*! Linked list of the tasks computing this cell's gravity forces. */ struct link *grav; + /*! Linked list of the tasks computing this cell's gravity M-M forces. */ + struct link *grav_mm; + /*! The task computing this cell's sorts. */ struct task *sorts; diff --git a/src/engine.c b/src/engine.c index 265571b464a9878fd28b400c8a1a6082970a874c..04694b2c9c52f01fccd191e21460c8c38f111e04 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1582,8 +1582,7 @@ void engine_addtasks_recv_gravity(struct engine *e, struct cell *c, c->recv_grav = t_grav; for (struct link *l = c->grav; l != NULL; l = l->next) - if (l->t->type != task_type_grav_mm) - scheduler_addunlock(s, t_grav, l->t); + scheduler_addunlock(s, t_grav, l->t); /* Recurse? */ if (c->split) @@ -3823,7 +3822,7 @@ void engine_print_task_counts(struct engine *e) { int count_recv_gpart = 0; int count_send_tiend = 0; int count_recv_tiend = 0; - + /* Count and print the number of each task type. */ int counts[task_type_count + 1]; for (int k = 0; k <= task_type_count; k++) counts[k] = 0; @@ -3833,14 +3832,18 @@ void engine_print_task_counts(struct engine *e) { else { counts[(int)tasks[k].type] += 1; - if(tasks[k].type == task_type_send && tasks[k].subtype == task_subtype_gpart) - ++count_send_gpart; - if(tasks[k].type == task_type_send && tasks[k].subtype == task_subtype_tend) - ++count_send_tiend; - if(tasks[k].type == task_type_recv && tasks[k].subtype == task_subtype_gpart) - ++count_recv_gpart; - if(tasks[k].type == task_type_recv && tasks[k].subtype == task_subtype_tend) - ++count_recv_tiend; + if (tasks[k].type == task_type_send && + tasks[k].subtype == task_subtype_gpart) + ++count_send_gpart; + if (tasks[k].type == task_type_send && + tasks[k].subtype == task_subtype_tend) + ++count_send_tiend; + if (tasks[k].type == task_type_recv && + tasks[k].subtype == task_subtype_gpart) + ++count_recv_gpart; + if (tasks[k].type == task_type_recv && + tasks[k].subtype == task_subtype_tend) + ++count_recv_tiend; } } message("Total = %d (per cell = %d)", nr_tasks, @@ -3860,7 +3863,7 @@ void engine_print_task_counts(struct engine *e) { message("send_tiend = %d", count_send_tiend); message("recv_gpart = %d", count_recv_gpart); message("recv_tiend = %d", count_recv_tiend); - + message("nr_parts = %zu.", e->s->nr_parts); message("nr_gparts = %zu.", e->s->nr_gparts); message("nr_sparts = %zu.", e->s->nr_sparts); diff --git a/src/runner.c b/src/runner.c index f6f769d2f485fbeebcb080ca706aaa0205a67e54..187e601315555fa44f686cd212365694a2e505ff 100644 --- a/src/runner.c +++ b/src/runner.c @@ -2001,8 +2001,8 @@ void runner_do_recv_spart(struct runner *r, struct cell *c, int timer) { #endif /* ... and store. */ - //c->ti_gravity_end_min = ti_gravity_end_min; - //c->ti_gravity_end_max = ti_gravity_end_max; + // c->ti_gravity_end_min = ti_gravity_end_min; + // c->ti_gravity_end_max = ti_gravity_end_max; c->ti_old_gpart = ti_current; if (timer) TIMER_TOC(timer_dorecv_spart); diff --git a/src/scheduler.c b/src/scheduler.c index 3b52cb57040ac3f685a1f55237d141a05d749a8d..8204351c2b5d06101b609f5977834e241459a94c 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -897,8 +897,8 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) { /* Since this task will not be split, we can already link it */ atomic_inc(&ci->nr_tasks); atomic_inc(&cj->nr_tasks); - engine_addlink(e, &ci->grav, t); - engine_addlink(e, &cj->grav, t); + engine_addlink(e, &ci->grav_mm, t); + engine_addlink(e, &cj->grav_mm, t); break; } diff --git a/src/space.c b/src/space.c index 6f98e788e9625c1cc872f59c58a8bf87b7b2cfa8..caf7795536df7994dbb360025e10826893b9a2e1 100644 --- a/src/space.c +++ b/src/space.c @@ -168,6 +168,7 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements, c->gradient = NULL; c->force = NULL; c->grav = NULL; + c->grav_mm = NULL; c->dx_max_part = 0.0f; c->dx_max_sort = 0.0f; c->sorted = 0;