Commit fb757174 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Restored the task logic for long-range gravity and M-M calculations

parent 2781ef21
...@@ -1321,6 +1321,8 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { ...@@ -1321,6 +1321,8 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
if (c->kick2 != NULL) scheduler_activate(s, c->kick2); if (c->kick2 != NULL) scheduler_activate(s, c->kick2);
if (c->timestep != NULL) scheduler_activate(s, c->timestep); if (c->timestep != NULL) scheduler_activate(s, c->timestep);
if (c->grav_down != NULL) scheduler_activate(s, c->grav_down); if (c->grav_down != NULL) scheduler_activate(s, c->grav_down);
if (c->grav_long_range != NULL) scheduler_activate(s, c->grav_long_range);
if (c->grav_top_level != NULL) scheduler_activate(s, c->grav_top_level);
if (c->cooling != NULL) scheduler_activate(s, c->cooling); if (c->cooling != NULL) scheduler_activate(s, c->cooling);
if (c->sourceterms != NULL) scheduler_activate(s, c->sourceterms); if (c->sourceterms != NULL) scheduler_activate(s, c->sourceterms);
......
...@@ -170,7 +170,10 @@ struct cell { ...@@ -170,7 +170,10 @@ struct cell {
struct task *timestep; struct task *timestep;
/*! Task constructing the multipole from the particles */ /*! Task constructing the multipole from the particles */
struct task *grav_up; struct task *grav_top_level;
/*! Task constructing the multipole from the particles */
struct task *grav_long_range;
/*! Task propagating the multipole to the particles */ /*! Task propagating the multipole to the particles */
struct task *grav_down; struct task *grav_down;
......
...@@ -132,6 +132,7 @@ void engine_make_hierarchical_tasks(struct engine *e, struct cell *c) { ...@@ -132,6 +132,7 @@ void engine_make_hierarchical_tasks(struct engine *e, struct cell *c) {
struct scheduler *s = &e->sched; struct scheduler *s = &e->sched;
const int is_hydro = (e->policy & engine_policy_hydro); const int is_hydro = (e->policy & engine_policy_hydro);
const int is_self_gravity = (e->policy & engine_policy_self_gravity);
const int is_with_cooling = (e->policy & engine_policy_cooling); const int is_with_cooling = (e->policy & engine_policy_cooling);
const int is_with_sourceterms = (e->policy & engine_policy_sourceterms); const int is_with_sourceterms = (e->policy & engine_policy_sourceterms);
...@@ -165,6 +166,19 @@ void engine_make_hierarchical_tasks(struct engine *e, struct cell *c) { ...@@ -165,6 +166,19 @@ void engine_make_hierarchical_tasks(struct engine *e, struct cell *c) {
scheduler_addunlock(s, c->drift, c->init); scheduler_addunlock(s, c->drift, c->init);
if (is_self_gravity) {
/* Gravity non-neighbouring pm calculations */
c->grav_long_range = scheduler_addtask(
s, task_type_grav_long_range, task_subtype_none, 0, 0, c, NULL, 0);
/* Gravity top-level periodic calculation */
c->grav_top_level = scheduler_addtask(
s, task_type_grav_top_level, task_subtype_none, 0, 0, c, NULL, 0);
scheduler_addunlock(s, c->init, c->grav_long_range);
scheduler_addunlock(s, c->init, c->grav_top_level);
}
/* Generate the ghost task. */ /* Generate the ghost task. */
if (is_hydro) if (is_hydro)
c->ghost = scheduler_addtask(s, task_type_ghost, task_subtype_none, 0, c->ghost = scheduler_addtask(s, task_type_ghost, task_subtype_none, 0,
...@@ -871,7 +885,7 @@ void engine_addtasks_grav(struct engine *e, struct cell *c, struct task *up, ...@@ -871,7 +885,7 @@ void engine_addtasks_grav(struct engine *e, struct cell *c, struct task *up,
struct task *down) { struct task *down) {
/* Link the tasks to this cell. */ /* Link the tasks to this cell. */
c->grav_up = up; // c->grav_up = up;
c->grav_down = down; c->grav_down = down;
/* Recurse? */ /* Recurse? */
...@@ -1572,11 +1586,6 @@ void engine_make_self_gravity_tasks(struct engine *e) { ...@@ -1572,11 +1586,6 @@ void engine_make_self_gravity_tasks(struct engine *e) {
scheduler_addtask(sched, task_type_self, task_subtype_grav, 0, 0, ci, NULL, scheduler_addtask(sched, task_type_self, task_subtype_grav, 0, 0, ci, NULL,
0); 0);
/* Let's also build a task for all the non-neighbouring pm calculations */
/* scheduler_addtask(sched, task_type_grav_long_range, task_subtype_none, 0,
* 0, */
/* ci, NULL, 0); */
for (int cjd = cid + 1; cjd < nr_cells; ++cjd) { for (int cjd = cid + 1; cjd < nr_cells; ++cjd) {
struct cell *cj = &cells[cjd]; struct cell *cj = &cells[cjd];
...@@ -2447,7 +2456,9 @@ void engine_marktasks_mapper(void *map_data, int num_elements, ...@@ -2447,7 +2456,9 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
} }
/* Gravity ? */ /* Gravity ? */
else if (t->type == task_type_grav_down) { else if (t->type == task_type_grav_down ||
t->type == task_type_grav_long_range ||
t->type == task_type_grav_top_level) {
if (cell_is_active(t->ci, e)) scheduler_activate(s, t); if (cell_is_active(t->ci, e)) scheduler_activate(s, t);
} }
......
...@@ -1802,11 +1802,12 @@ void *runner_main(void *data) { ...@@ -1802,11 +1802,12 @@ void *runner_main(void *data) {
case task_type_grav_down: case task_type_grav_down:
// runner_do_grav_down(r, t->ci); // runner_do_grav_down(r, t->ci);
break; break;
/* case task_type_grav_gather_m: */ case task_type_grav_top_level:
/* break; */ // runner_do_grav_top_level(r);
/* case task_type_grav_fft: */ break;
/* runner_do_grav_fft(r); */ case task_type_grav_long_range:
/* break; */ // runner_do_grav_fft(r);
break;
case task_type_cooling: case task_type_cooling:
if (e->policy & engine_policy_cooling) runner_do_end_force(r, ci, 1); if (e->policy & engine_policy_cooling) runner_do_end_force(r, ci, 1);
runner_do_cooling(r, t->ci, 1); runner_do_cooling(r, t->ci, 1);
......
...@@ -247,6 +247,9 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements, ...@@ -247,6 +247,9 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements,
c->drift = NULL; c->drift = NULL;
c->cooling = NULL; c->cooling = NULL;
c->sourceterms = NULL; c->sourceterms = NULL;
c->grav_top_level = NULL;
c->grav_long_range = NULL;
c->grav_down = NULL;
c->super = c; c->super = c;
if (c->sort != NULL) { if (c->sort != NULL) {
free(c->sort); free(c->sort);
......
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