diff --git a/src/cell.c b/src/cell.c index bfdc2c4f800ebdf827c5734e691d6d38a77ee96d..688d1610e10093d7f0a50766f0443e99aa85d15d 100644 --- a/src/cell.c +++ b/src/cell.c @@ -1678,49 +1678,35 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { struct engine *e = s->space->e; int rebuild = 0; - if(c->count == 14623) - message("Favourite cell"); - /* Un-skip the density tasks involved with this cell. */ for (struct link *l = c->density; l != NULL; l = l->next) { struct task *t = l->t; struct cell *ci = t->ci; struct cell *cj = t->cj; - if(ci->count==5239 && cj && cj->count==14623) { // ci->loc[0]==1.411875e+00 cj->loc[0]==1.411875e+00 - message("found task!"); - } - - if((cell_is_active(ci, e) && ci->nodeID == engine_rank) || - (cj != NULL && cell_is_active(cj, e) && cj->nodeID == engine_rank)) { + if ((cell_is_active(ci, e) && ci->nodeID == engine_rank) || + (cj != NULL && cell_is_active(cj, e) && cj->nodeID == engine_rank)) { scheduler_activate(s, t); - if(ci->count==5239 && cj && cj->count==14623) { // ci->loc[0]==1.411875e+00 cj->loc[0]==1.411875e+00 - message("activated task!"); - } - - - - /* Set the correct sorting flags */ if (t->type == task_type_pair) { - /* Store some values. */ - atomic_or(&ci->requires_sorts, 1 << t->flags); - atomic_or(&cj->requires_sorts, 1 << t->flags); - ci->dx_max_sort_old = ci->dx_max_sort; - cj->dx_max_sort_old = cj->dx_max_sort; - - /* Activate the drift tasks. */ - if (ci->nodeID == engine_rank) cell_activate_drift_part(ci, s); - if (cj->nodeID == engine_rank) cell_activate_drift_part(cj, s); - - /* Check the sorts and activate them if needed. */ - cell_activate_sorts(ci, t->flags, s); - cell_activate_sorts(cj, t->flags, s); + /* Store some values. */ + atomic_or(&ci->requires_sorts, 1 << t->flags); + atomic_or(&cj->requires_sorts, 1 << t->flags); + ci->dx_max_sort_old = ci->dx_max_sort; + cj->dx_max_sort_old = cj->dx_max_sort; + + /* Activate the drift tasks. */ + if (ci->nodeID == engine_rank) cell_activate_drift_part(ci, s); + if (cj->nodeID == engine_rank) cell_activate_drift_part(cj, s); + + /* Check the sorts and activate them if needed. */ + cell_activate_sorts(ci, t->flags, s); + cell_activate_sorts(cj, t->flags, s); } /* Store current values of dx_max and h_max. */ else if (t->type == task_type_sub_pair || t->type == task_type_sub_self) { - cell_activate_subcell_tasks(t->ci, t->cj, s); + cell_activate_subcell_tasks(t->ci, t->cj, s); } } @@ -1734,124 +1720,123 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { #ifdef WITH_MPI /* Activate the send/recv tasks. */ if (ci->nodeID != engine_rank) { - - if(cell_is_active(cj, e)) { - - /* Activate the tasks to recv foreign cell ci's data. */ - scheduler_activate(s, ci->recv_xv); - if (cell_is_active(ci, e)) { - scheduler_activate(s, ci->recv_rho); + + if (cell_is_active(cj, e)) { + + /* Activate the tasks to recv foreign cell ci's data. */ + scheduler_activate(s, ci->recv_xv); + if (cell_is_active(ci, e)) { + scheduler_activate(s, ci->recv_rho); #ifdef EXTRA_HYDRO_LOOP - scheduler_activate(s, ci->recv_gradient); + scheduler_activate(s, ci->recv_gradient); #endif - } - } - if(cell_is_active(ci, e)) - scheduler_activate(s, ci->recv_ti); + } + } + if (cell_is_active(ci, e)) scheduler_activate(s, ci->recv_ti); /* Look for the local cell cj's send tasks. */ - if(cell_is_active(ci, e)) { - struct link *l = NULL; - for (l = cj->send_xv; l != NULL && l->t->cj->nodeID != ci->nodeID; - l = l->next) - ; - if (l == NULL) error("Missing link to send_xv task."); - scheduler_activate(s, l->t); - - /* Drift the cell which will be sent at the level at which it is sent, - i.e. drift the cell specified in the send task (l->t) itself. */ - cell_activate_drift_part(l->t->ci, s); - - if (cell_is_active(cj, e)) { - struct link *l = NULL; - for (l = cj->send_rho; l != NULL && l->t->cj->nodeID != ci->nodeID; - l = l->next) - ; - if (l == NULL) error("Missing link to send_rho task."); - scheduler_activate(s, l->t); - -#ifdef EXTRA_HYDRO_LOOP - for (l = cj->send_gradient; - l != NULL && l->t->cj->nodeID != ci->nodeID; l = l->next) + if (cell_is_active(ci, e)) { + struct link *l = NULL; + for (l = cj->send_xv; l != NULL && l->t->cj->nodeID != ci->nodeID; + l = l->next) ; - if (l == NULL) error("Missing link to send_gradient task."); + if (l == NULL) error("Missing link to send_xv task."); scheduler_activate(s, l->t); + + /* Drift the cell which will be sent at the level at which it is sent, + i.e. drift the cell specified in the send task (l->t) itself. */ + cell_activate_drift_part(l->t->ci, s); + + if (cell_is_active(cj, e)) { + struct link *l = NULL; + for (l = cj->send_rho; l != NULL && l->t->cj->nodeID != ci->nodeID; + l = l->next) + ; + if (l == NULL) error("Missing link to send_rho task."); + scheduler_activate(s, l->t); + +#ifdef EXTRA_HYDRO_LOOP + for (l = cj->send_gradient; + l != NULL && l->t->cj->nodeID != ci->nodeID; l = l->next) + ; + if (l == NULL) error("Missing link to send_gradient task."); + scheduler_activate(s, l->t); #endif - } + } } - /* We always need to send the new end time irrespective of active status */ - if(cell_is_active(cj, e)){ - struct link *l = NULL; + /* We always need to send the new end time irrespective of active status + */ + if (cell_is_active(cj, e)) { + struct link *l = NULL; for (l = cj->send_ti; l != NULL && l->t->cj->nodeID != ci->nodeID; l = l->next) ; if (l == NULL) error("Missing link to send_ti task."); scheduler_activate(s, l->t); - } + } } else if (cj->nodeID != engine_rank) { /* Activate the tasks to recv foreign cell cj's data. */ - if(cell_is_active(ci, e)) { - scheduler_activate(s, cj->recv_xv); - if (cell_is_active(cj, e)) { - scheduler_activate(s, cj->recv_rho); + if (cell_is_active(ci, e)) { + scheduler_activate(s, cj->recv_xv); + if (cell_is_active(cj, e)) { + scheduler_activate(s, cj->recv_rho); #ifdef EXTRA_HYDRO_LOOP - scheduler_activate(s, cj->recv_gradient); + scheduler_activate(s, cj->recv_gradient); #endif - } - } - if(cell_is_active(cj, e)) - scheduler_activate(s, cj->recv_ti); + } + } + if (cell_is_active(cj, e)) scheduler_activate(s, cj->recv_ti); /* Look for the local cell ci's send tasks. */ - if(cell_is_active(cj, e)) { - struct link *l = NULL; - for (l = ci->send_xv; l != NULL && l->t->cj->nodeID != cj->nodeID; - l = l->next) - ; - if (l == NULL) error("Missing link to send_xv task."); - scheduler_activate(s, l->t); - - /* Drift the cell which will be sent at the level at which it is sent, - i.e. drift the cell specified in the send task (l->t) itself. */ - cell_activate_drift_part(l->t->ci, s); - - if (cell_is_active(ci, e)) { - - struct link *l = NULL; - for (l = ci->send_rho; l != NULL && l->t->cj->nodeID != cj->nodeID; + if (cell_is_active(cj, e)) { + struct link *l = NULL; + for (l = ci->send_xv; l != NULL && l->t->cj->nodeID != cj->nodeID; l = l->next) ; - if (l == NULL) error("Missing link to send_rho task."); - scheduler_activate(s, l->t); - + if (l == NULL) error("Missing link to send_xv task."); + scheduler_activate(s, l->t); + + /* Drift the cell which will be sent at the level at which it is sent, + i.e. drift the cell specified in the send task (l->t) itself. */ + cell_activate_drift_part(l->t->ci, s); + + if (cell_is_active(ci, e)) { + + struct link *l = NULL; + for (l = ci->send_rho; l != NULL && l->t->cj->nodeID != cj->nodeID; + l = l->next) + ; + if (l == NULL) error("Missing link to send_rho task."); + scheduler_activate(s, l->t); + #ifdef EXTRA_HYDRO_LOOP - for (l = ci->send_gradient; - l != NULL && l->t->cj->nodeID != cj->nodeID; l = l->next) + for (l = ci->send_gradient; + l != NULL && l->t->cj->nodeID != cj->nodeID; l = l->next) + ; + if (l == NULL) error("Missing link to send_gradient task."); + scheduler_activate(s, l->t); +#endif + } + } + /* We always need to send the new end time irrespective of active status + */ + if (cell_is_active(ci, e)) { + struct link *l = NULL; + for (l = ci->send_ti; l != NULL && l->t->cj->nodeID != cj->nodeID; + l = l->next) ; - if (l == NULL) error("Missing link to send_gradient task."); + if (l == NULL) error("Missing link to send_ti task."); scheduler_activate(s, l->t); -#endif - } - } - /* We always need to send the new end time irrespective of active status */ - if(cell_is_active(ci,e)) { - struct link *l = NULL; - for (l = ci->send_ti; l != NULL && l->t->cj->nodeID != cj->nodeID; - l = l->next) - ; - if (l == NULL) error("Missing link to send_ti task."); - scheduler_activate(s, l->t); - } - + } } #endif } } /* Unskip all the other task types. */ - if( c->nodeID == engine_rank && cell_is_active(c,e) ) { + if (c->nodeID == engine_rank && cell_is_active(c, e)) { for (struct link *l = c->gradient; l != NULL; l = l->next) scheduler_activate(s, l->t); @@ -1875,7 +1860,6 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { if (c->grav_long_range != NULL) scheduler_activate(s, c->grav_long_range); if (c->cooling != NULL) scheduler_activate(s, c->cooling); if (c->sourceterms != NULL) scheduler_activate(s, c->sourceterms); - } return rebuild;