Commit c4228263 authored by Mladen Ivkovic's avatar Mladen Ivkovic

added sub tasks and unskipping of sub tasks properly

parent 9410282c
......@@ -3848,7 +3848,88 @@ void cell_activate_subcell_external_grav_tasks(struct cell *ci,
*/
void cell_activate_subcell_rt_tasks(struct cell *ci, struct cell *cj,
struct scheduler *s) {
/* TODO: everything */
const struct engine *e = s->space->e;
/* Self interaction? */
if (cj == NULL) {
/* Do anything? */
if (ci->hydro.count == 0 || !cell_is_active_hydro(ci, e)) return;
/* Recurse? */
if (cell_can_recurse_in_self_hydro_task(ci)) {
/* Loop over all progenies and pairs of progenies */
for (int j = 0; j < 8; j++) {
if (ci->progeny[j] != NULL) {
cell_activate_subcell_rt_tasks(ci->progeny[j], NULL, s);
for (int k = j + 1; k < 8; k++)
if (ci->progeny[k] != NULL)
cell_activate_subcell_rt_tasks(ci->progeny[j], ci->progeny[k], s);
}
}
} else {
/* We have reached the bottom of the tree: activate tasks */
for (struct link *l = ci->hydro.rt_inject; l != NULL; l = l->next) {
struct task *t = l->t;
const int ci_active = cell_is_active_hydro(ci, e);
#ifdef WITH_MPI
const int ci_nodeID = ci->nodeID;
#else
const int ci_nodeID = e->nodeID;
#endif
/* Only activate tasks that involve a local active cell. */
if (ci_active && ci_nodeID == e->nodeID){
scheduler_activate(s, t);
}
}
}
}
/* Otherwise, pair interaction */
else {
/* Should we even bother? */
if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) return;
if (ci->hydro.count == 0 || cj->hydro.count == 0) return;
/* Get the orientation of the pair. */
double shift[3];
const int sid = space_getsid(s->space, &ci, &cj, shift);
/* recurse? */
if (cell_can_recurse_in_pair_hydro_task(ci) &&
cell_can_recurse_in_pair_hydro_task(cj)) {
const struct cell_split_pair *csp = &cell_split_pairs[sid];
for (int k = 0; k < csp->count; k++) {
const int pid = csp->pairs[k].pid;
const int pjd = csp->pairs[k].pjd;
if (ci->progeny[pid] != NULL && cj->progeny[pjd] != NULL)
cell_activate_subcell_rt_tasks(ci->progeny[pid], cj->progeny[pjd], s);
}
}
/* Otherwise, activate the RT tasks. */
else if (cell_is_active_hydro(ci, e) || cell_is_active_hydro(cj, e)) {
/* Activate the drifts if the cells are local. */
for (struct link *l = ci->hydro.rt_inject; l != NULL; l = l->next) {
struct task *t = l->t;
const int ci_active = cell_is_active_hydro(ci, e);
const int cj_active = (cj != NULL) ? cell_is_active_hydro(cj, e) : 0;
#ifdef WITH_MPI
const int ci_nodeID = ci->nodeID;
const int cj_nodeID = (cj != NULL) ? cj->nodeID : -1;
#else
const int ci_nodeID = e->nodeID;
const int cj_nodeID = e->nodeID;
#endif
/* Only activate tasks that involve a local active cell. */
if ((ci_active && ci_nodeID == e->nodeID) ||
(cj_active && cj_nodeID == e->nodeID)) {
scheduler_activate(s, t);
}
}
}
}
}
......@@ -4871,12 +4952,10 @@ int cell_unskip_rt_tasks(struct cell *c, struct scheduler *s) {
scheduler_activate(s, t);
if (t->type == task_type_sub_self) {
printf("=========================================trying to access subcell self rt tasks activation\n");
cell_activate_subcell_rt_tasks(ci, NULL, s);
}
else if (t->type == task_type_sub_pair) {
printf("=========================================trying to access subcell pair rt tasks activation\n");
cell_activate_subcell_rt_tasks(ci, cj, s);
}
}
......
......@@ -2462,7 +2462,7 @@ void engine_make_extra_hydroloop_tasks_mapper(void *map_data, int num_elements,
if (with_rt) {
t_rt_inject = scheduler_addtask(
sched, task_type_self, task_subtype_rt_inject, flags, 0, ci, NULL);
sched, task_type_sub_self, task_subtype_rt_inject, flags, 0, ci, NULL);
}
/* Add the link between the new loop and the cell */
......@@ -2647,7 +2647,7 @@ void engine_make_extra_hydroloop_tasks_mapper(void *map_data, int num_elements,
if (with_rt) {
t_rt_inject = scheduler_addtask(
sched, task_type_pair, task_subtype_rt_inject, flags, 0, ci, cj);
sched, task_type_sub_pair, task_subtype_rt_inject, flags, 0, ci, cj);
}
engine_addlink(e, &ci->hydro.force, t_force);
......
......@@ -1401,9 +1401,10 @@ void scheduler_reweight(struct scheduler *s, int verbose) {
t->subtype == task_subtype_force ||
t->subtype == task_subtype_limiter)
cost = 1.f * (wscale * count_i) * count_i;
else if (t->subtype == task_subtype_rt_inject)
else if (t->subtype == task_subtype_rt_inject){
/* TODO: does this make sense? */
cost = 1.f * wscale * scount_i * count_i;
else
} else
error("Untreated sub-type for selfs: %s",
subtaskID_names[t->subtype]);
break;
......@@ -1452,8 +1453,8 @@ void scheduler_reweight(struct scheduler *s, int verbose) {
cost = 2.f * (wscale * count_i) * count_j * sid_scale[t->flags];
} else if (t->subtype == task_subtype_rt_inject) {
/* TODO: discuss this in detail */
cost = 2.f * wscale * scount_i * count_i;
/* TODO: does this make sense? */
cost = 1.f * wscale * scount_i * count_i;
} else {
error("Untreated sub-type for pairs: %s",
subtaskID_names[t->subtype]);
......@@ -1502,7 +1503,9 @@ void scheduler_reweight(struct scheduler *s, int verbose) {
} else {
cost = 2.f * (wscale * count_i) * count_j * sid_scale[t->flags];
}
} else if (t->subtype == task_subtype_rt_inject){
/* TODO: does this make sense? */
cost = 1.f * wscale * scount_i * count_i;
} else {
error("Untreated sub-type for sub-pairs: %s",
subtaskID_names[t->subtype]);
......@@ -1526,6 +1529,9 @@ void scheduler_reweight(struct scheduler *s, int verbose) {
t->subtype == task_subtype_force ||
t->subtype == task_subtype_limiter) {
cost = 1.f * (wscale * count_i) * count_i;
} else if (t->subtype == task_subtype_rt_inject) {
/* TODO: does this make sense? */
cost = 1.f * wscale * scount_i * count_i;
} else {
error("Untreated sub-type for sub-selfs: %s",
subtaskID_names[t->subtype]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment