diff --git a/src/engine_maketasks.c b/src/engine_maketasks.c index 77a8bd71dc33bf52bdcbb9c913f57b7f651e9c12..c831b31ed6bcf3c237f945b1f65aa4100a6f2eaa 100644 --- a/src/engine_maketasks.c +++ b/src/engine_maketasks.c @@ -877,6 +877,48 @@ void engine_make_self_gravity_tasks_mapper(void *map_data, int num_elements, scheduler_addtask(sched, task_type_pair, task_subtype_grav, 0, 0, ci, cj); +#ifdef WITH_MPI + + /* Let's cross-check that we had a proxy for that cell */ + if (ci->nodeID == nodeID && cj->nodeID != engine_rank) { + + /* Find the proxy for this node */ + const int proxy_id = e->proxy_ind[cj->nodeID]; + if (proxy_id < 0) + error("No proxy exists for that foreign node %d!", cj->nodeID); + + const struct proxy *p = &e->proxies[proxy_id]; + + /* Check whether the cell exists in the proxy */ + int n = 0; + for (n = 0; n < p->nr_cells_in; n++) + if(p->cells_in[n] == cj) + break; + if(n == p->nr_cells_in) + error("Cell %d not found in the proxy but trying to construct grav task!", + cjd); + } + else if(cj->nodeID == nodeID && ci->nodeID != engine_rank) { + + /* Find the proxy for this node */ + const int proxy_id = e->proxy_ind[ci->nodeID]; + if (proxy_id < 0) + error("No proxy exists for that foreign node %d!", ci->nodeID); + + const struct proxy *p = &e->proxies[proxy_id]; + + /* Check whether the cell exists in the proxy */ + int n = 0; + for (n = 0; n < p->nr_cells_in; n++) + if(p->cells_in[n] == ci) + break; + if(n == p->nr_cells_in) + error("Cell %d not found in the proxy but trying to construct grav task!", + cid); + } +#endif + + if(ci->nodeID == nodeID && cj->nodeID != engine_rank) atomic_inc(&ci->num_foreign_pair_grav); if(cj->nodeID == nodeID && ci->nodeID != engine_rank) @@ -1796,6 +1838,47 @@ void engine_make_hydroloop_tasks_mapper(void *map_data, int num_elements, const int sid = sortlistID[(kk + 1) + 3 * ((jj + 1) + 3 * (ii + 1))]; scheduler_addtask(sched, task_type_pair, task_subtype_density, sid, 0, ci, cj); + +#ifdef WITH_MPI + + /* Let's cross-check that we had a proxy for that cell */ + if (ci->nodeID == nodeID && cj->nodeID != engine_rank) { + + /* Find the proxy for this node */ + const int proxy_id = e->proxy_ind[cj->nodeID]; + if (proxy_id < 0) + error("No proxy exists for that foreign node %d!", cj->nodeID); + + const struct proxy *p = &e->proxies[proxy_id]; + + /* Check whether the cell exists in the proxy */ + int n = 0; + for (n = 0; n < p->nr_cells_in; n++) + if(p->cells_in[n] == cj) + break; + if(n == p->nr_cells_in) + error("Cell %d not found in the proxy but trying to construct hydro task!", + cjd); + } + else if(cj->nodeID == nodeID && ci->nodeID != engine_rank) { + + /* Find the proxy for this node */ + const int proxy_id = e->proxy_ind[ci->nodeID]; + if (proxy_id < 0) + error("No proxy exists for that foreign node %d!", ci->nodeID); + + const struct proxy *p = &e->proxies[proxy_id]; + + /* Check whether the cell exists in the proxy */ + int n = 0; + for (n = 0; n < p->nr_cells_in; n++) + if(p->cells_in[n] == ci) + break; + if(n == p->nr_cells_in) + error("Cell %d not found in the proxy but trying to construct hydro task!", + cid); + } +#endif if(ci->nodeID == nodeID && cj->nodeID != engine_rank) atomic_inc(&ci->num_foreign_pair_hydro);