Commit 2b01cd1d authored by Alexei Borissov's avatar Alexei Borissov
Browse files

Trying to add subself and subpair tasks

parent 9b772201
......@@ -3052,7 +3052,7 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
struct engine *e = s->space->e;
const int nodeID = e->nodeID;
int rebuild = 0;
/* Un-skip the density tasks involved with this cell. */
for (struct link *l = c->stars.density; l != NULL; l = l->next) {
struct task *t = l->t;
......@@ -3116,7 +3116,7 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
cell_activate_subcell_stars_tasks(t->ci, t->cj, s);
}
}
/* Only interested in pair interactions as of here. */
if (t->type == task_type_pair || t->type == task_type_sub_pair) {
......@@ -3205,6 +3205,27 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
#endif
}
}
/* Un-skip the feedback tasks involved with this cell. */
for (struct link *l = c->stars.feedback; 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_stars(ci, e);
const int cj_active = (cj != NULL) ? cell_is_active_stars(cj, e) : 0;
/* Only activate tasks that involve a local active cell. */
if ((ci_active && ci->nodeID == nodeID) ||
(cj_active && cj->nodeID == nodeID)) {
scheduler_activate(s, t);
}
if (t->type == task_type_pair || t->type == task_type_sub_pair) {
/* Check whether there was too much particle motion, i.e. the
cell neighbour conditions were violated. */
if (cell_need_rebuild_for_pair(ci, cj)) rebuild = 1;
}
}
/* Unskip all the other task types. */
if (c->nodeID == nodeID && cell_is_active_stars(c, e)) {
......
......@@ -505,7 +505,7 @@ struct cell {
/*! Linked list of the tasks computing this cell's star density. */
struct link *density;
// ALEXEI: DOES THIS NEED TO BE HERE?
/*! Linked list of the tasks computing this cell's star feedback. */
struct link *feedback;
/*! Number of #spart updated in this cell. */
......
......@@ -1688,18 +1688,13 @@ void engine_link_stars_tasks_mapper(void *map_data, int num_elements,
else if (t->type == task_type_sub_self &&
t->subtype == task_subtype_stars_feedback) {
/* Make all feedback tasks depend on the drift and sorts. */
//scheduler_addunlock(sched, t->ci->super->hydro.drift, t);
//scheduler_addunlock(sched, t->ci->super->hydro.sorts, t);
//scheduler_addunlock(sched, t->ci->super->grav.drift, t);
//scheduler_addunlock(sched, t->ci->super->stars.sorts, t);
/* Now, build all the dependencies for the stars for the cells */
/* that are local and are not descendant of the same super-cells */
//if (t->ci->nodeID == nodeID) {
// engine_make_stars_loops_dependencies(sched, t, t->ci);
//} else
// error("oo");
/* Make feedback task depend on ghost */
scheduler_addunlock(sched, t->ci->super->stars.ghost_out, t);
/* Make end_force depend on feedback */
if (t->ci == t->ci->super) {
scheduler_addunlock(sched, t, t->ci->super->end_force);
}
}
/* Otherwise, sub-pair interaction? */
......@@ -1738,34 +1733,13 @@ void engine_link_stars_tasks_mapper(void *map_data, int num_elements,
else if (t->type == task_type_sub_pair &&
t->subtype == task_subtype_stars_feedback) {
/* Make all feedback tasks depend on the drift. */
//if (t->cj->nodeID == engine_rank)
// scheduler_addunlock(sched, t->cj->super->hydro.drift, t);
//scheduler_addunlock(sched, t->cj->super->hydro.sorts, t);
//if (t->cj->nodeID == engine_rank)
// scheduler_addunlock(sched, t->cj->super->grav.drift, t);
//scheduler_addunlock(sched, t->ci->super->stars.sorts, t);
//if (t->ci->super != t->cj->super) {
// if (t->ci->nodeID == engine_rank)
// scheduler_addunlock(sched, t->ci->super->hydro.drift, t);
// scheduler_addunlock(sched, t->ci->super->hydro.sorts, t);
// if (t->ci->nodeID == engine_rank)
// scheduler_addunlock(sched, t->ci->super->grav.drift, t);
// scheduler_addunlock(sched, t->cj->super->stars.sorts, t);
//}
/* Now, build all the dependencies for the stars for the cells */
/* that are local and are not descendant of the same super-cells */
//if (t->ci->nodeID == nodeID) {
// engine_make_stars_loops_dependencies(sched, t, t->ci);
//}
//if (t->cj->nodeID == nodeID) {
// if (t->ci->super != t->cj->super)
// engine_make_stars_loops_dependencies(sched, t, t->cj);
//}
/* Make feedback task depend on ghost */
scheduler_addunlock(sched, t->ci->super->stars.ghost_out, t);
/* Make end_force depend on feedback */
if (t->ci == t->ci->super) {
scheduler_addunlock(sched, t, t->ci->super->end_force);
}
}
}
}
......
......@@ -141,6 +141,23 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
}
}
/* Activate the star feedback */
else if (t_type == task_type_self &&
t_subtype == task_subtype_stars_feedback) {
if (cell_is_active_stars(ci, e)) {
scheduler_activate(s, t);
}
}
/* Store current values of dx_max and h_max. */
else if (t_type == task_type_sub_self &&
t_subtype == task_subtype_stars_feedback) {
if (cell_is_active_stars(ci, e)) {
scheduler_activate(s, t);
cell_activate_subcell_stars_tasks(ci, NULL, s);
}
}
/* Activate the gravity drift */
else if (t_type == task_type_self && t_subtype == task_subtype_grav) {
if (cell_is_active_gravity(ci, e)) {
......@@ -279,6 +296,13 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
}
}
if (t_subtype == task_subtype_stars_feedback &&
((ci_active_stars && ci->nodeID == engine_rank) ||
(cj_active_stars && cj->nodeID == engine_rank))) {
scheduler_activate(s, t);
}
/* Gravity */
if ((t_subtype == task_subtype_grav) &&
((ci_active_gravity && ci_nodeID == nodeID) ||
......@@ -403,6 +427,15 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
// LOIC: Need implementing MPI case
}
/* Only interested in stars_feedback tasks as of here. */
if (t->subtype == task_subtype_stars_feedback) {
/* Too much particle movement? */
if (cell_need_rebuild_for_pair(ci, cj)) *rebuild_space = 1;
// LOIC: Need implementing MPI case
}
/* Only interested in gravity tasks as of here. */
if (t_subtype == task_subtype_grav) {
......
......@@ -332,6 +332,48 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
scount, l->t->ci, -1, 1);
}
}
/* Run through this cell's feedback interactions. */
for (struct link *l = finger->stars.feedback; l != NULL; l = l->next) {
#ifdef SWIFT_DEBUG_CHECKS
if (l->t->ti_run < r->e->ti_current)
error("Density task should have been run.");
#endif
/* Self-interaction? */
if (l->t->type == task_type_self)
runner_doself_subset_branch_stars_feedback(r, finger, sparts, sid,
scount);
/* Otherwise, pair interaction? */
else if (l->t->type == task_type_pair) {
/* Left or right? */
if (l->t->ci == finger)
runner_dopair_subset_branch_stars_feedback(
r, finger, sparts, sid, scount, l->t->cj);
else
runner_dopair_subset_branch_stars_feedback(
r, finger, sparts, sid, scount, l->t->ci);
}
/* Otherwise, sub-self interaction? */
else if (l->t->type == task_type_sub_self)
runner_dosub_subset_stars_feedback(r, finger, sparts, sid, scount,
NULL, -1, 1);
/* Otherwise, sub-pair interaction? */
else if (l->t->type == task_type_sub_pair) {
/* Left or right? */
if (l->t->ci == finger)
runner_dosub_subset_stars_feedback(r, finger, sparts, sid,
scount, l->t->cj, -1, 1);
else
runner_dosub_subset_stars_feedback(r, finger, sparts, sid,
scount, l->t->ci, -1, 1);
}
}
}
}
}
......
......@@ -200,6 +200,7 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements,
c->stars.ghost_out = NULL;
c->stars.ghost = NULL;
c->stars.density = NULL;
c->stars.feedback = NULL;
c->kick1 = NULL;
c->kick2 = NULL;
c->timestep = NULL;
......
......@@ -166,6 +166,7 @@ __attribute__((always_inline)) INLINE static enum task_actions task_acts_on(
break;
case task_subtype_stars_density:
case task_subtype_stars_feedback:
return task_action_all;
break;
......@@ -356,6 +357,8 @@ void task_unlock(struct task *t) {
cell_munlocktree(ci);
} else if (subtype == task_subtype_stars_density) {
cell_sunlocktree(ci);
} else if (subtype == task_subtype_stars_feedback) {
cell_sunlocktree(ci);
} else {
cell_unlocktree(ci);
}
......@@ -371,6 +374,9 @@ void task_unlock(struct task *t) {
} else if (subtype == task_subtype_stars_density) {
cell_sunlocktree(ci);
cell_sunlocktree(cj);
} else if (subtype == task_subtype_stars_feedback) {
cell_sunlocktree(ci);
cell_sunlocktree(cj);
} else {
cell_unlocktree(ci);
cell_unlocktree(cj);
......@@ -477,6 +483,9 @@ int task_lock(struct task *t) {
} else if (subtype == task_subtype_stars_density) {
if (ci->stars.hold) return 0;
if (cell_slocktree(ci) != 0) return 0;
} else if (subtype == task_subtype_stars_feedback) {
if (ci->stars.hold) return 0;
if (cell_slocktree(ci) != 0) return 0;
} else {
if (ci->hydro.hold) return 0;
if (cell_locktree(ci) != 0) return 0;
......@@ -509,6 +518,13 @@ int task_lock(struct task *t) {
cell_sunlocktree(ci);
return 0;
}
} else if (subtype == task_subtype_stars_feedback) {
if (ci->stars.hold || cj->stars.hold) return 0;
if (cell_slocktree(ci) != 0) return 0;
if (cell_slocktree(cj) != 0) {
cell_sunlocktree(ci);
return 0;
}
} else {
/* Lock the parts in both cells */
if (ci->hydro.hold || cj->hydro.hold) return 0;
......
Supports Markdown
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