Commit 1c7e15cb authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added the necessary set of gravty tasks.

parent c707ab6b
......@@ -1820,101 +1820,106 @@ static inline void engine_make_external_gravity_dependencies(
*/
void engine_link_gravity_tasks(struct engine *e) {
struct scheduler *sched = &e->sched;
const int nodeID = e->nodeID;
const int nr_tasks = sched->nr_tasks;
/* struct scheduler *sched = &e->sched; */
/* const int nodeID = e->nodeID; */
/* const int nr_tasks = sched->nr_tasks; */
/* Add one task gathering all the multipoles */
struct task *gather = scheduler_addtask(
sched, task_type_grav_gather_m, task_subtype_none, 0, 0, NULL, NULL, 0);
/* /\* Add one task gathering all the multipoles *\/ */
/* struct task *gather = scheduler_addtask( */
/* sched, task_type_grav_gather_m, task_subtype_none, 0, 0, NULL, NULL,
* 0); */
/* And one task performing the FFT */
struct task *fft = scheduler_addtask(sched, task_type_grav_fft,
task_subtype_none, 0, 0, NULL, NULL, 0);
/* /\* And one task performing the FFT *\/ */
/* struct task *fft = scheduler_addtask(sched, task_type_grav_fft, */
/* task_subtype_none, 0, 0, NULL, NULL,
* 0); */
scheduler_addunlock(sched, gather, fft);
/* scheduler_addunlock(sched, gather, fft); */
for (int k = 0; k < nr_tasks; k++) {
/* for (int k = 0; k < nr_tasks; k++) { */
/* Get a pointer to the task. */
struct task *t = &sched->tasks[k];
/* /\* Get a pointer to the task. *\/ */
/* struct task *t = &sched->tasks[k]; */
/* Multipole construction */
if (t->type == task_type_grav_up) {
scheduler_addunlock(sched, t, gather);
}
/* /\* Multipole construction *\/ */
/* if (t->type == task_type_grav_up) { */
/* scheduler_addunlock(sched, t, gather); */
/* } */
/* Long-range interaction */
if (t->type == task_type_grav_mm) {
/* /\* Long-range interaction *\/ */
/* if (t->type == task_type_grav_mm) { */
/* Gather the multipoles --> mm interaction --> kick */
scheduler_addunlock(sched, gather, t);
scheduler_addunlock(sched, t, t->ci->super->kick2);
/* /\* Gather the multipoles --> mm interaction --> kick *\/ */
/* scheduler_addunlock(sched, gather, t); */
/* scheduler_addunlock(sched, t, t->ci->super->kick2); */
/* init --> mm interaction */
scheduler_addunlock(sched, t->ci->super->init, t);
}
/* /\* init --> mm interaction *\/ */
/* scheduler_addunlock(sched, t->ci->super->init, t); */
/* } */
/* Self-interaction for self-gravity? */
if (t->type == task_type_self && t->subtype == task_subtype_grav) {
/* /\* Self-interaction for self-gravity? *\/ */
/* if (t->type == task_type_self && t->subtype == task_subtype_grav) { */
engine_make_gravity_dependencies(sched, t, t->ci);
/* engine_make_gravity_dependencies(sched, t, t->ci); */
}
/* } */
/* Self-interaction for external gravity ? */
else if (t->type == task_type_self &&
t->subtype == task_subtype_external_grav) {
/* /\* Self-interaction for external gravity ? *\/ */
/* else if (t->type == task_type_self && */
/* t->subtype == task_subtype_external_grav) { */
engine_make_external_gravity_dependencies(sched, t, t->ci);
/* engine_make_external_gravity_dependencies(sched, t, t->ci); */
}
/* } */
/* Otherwise, pair interaction? */
else if (t->type == task_type_pair && t->subtype == task_subtype_grav) {
/* /\* Otherwise, pair interaction? *\/ */
/* else if (t->type == task_type_pair && t->subtype == task_subtype_grav) {
*/
if (t->ci->nodeID == nodeID) {
/* if (t->ci->nodeID == nodeID) { */
engine_make_gravity_dependencies(sched, t, t->ci);
}
/* engine_make_gravity_dependencies(sched, t, t->ci); */
/* } */
if (t->cj->nodeID == nodeID && t->ci->super != t->cj->super) {
/* if (t->cj->nodeID == nodeID && t->ci->super != t->cj->super) { */
engine_make_gravity_dependencies(sched, t, t->cj);
}
/* engine_make_gravity_dependencies(sched, t, t->cj); */
/* } */
}
/* } */
/* Otherwise, sub-self interaction? */
else if (t->type == task_type_sub_self && t->subtype == task_subtype_grav) {
/* /\* Otherwise, sub-self interaction? *\/ */
/* else if (t->type == task_type_sub_self && t->subtype ==
* task_subtype_grav) { */
if (t->ci->nodeID == nodeID) {
engine_make_gravity_dependencies(sched, t, t->ci);
}
}
/* if (t->ci->nodeID == nodeID) { */
/* engine_make_gravity_dependencies(sched, t, t->ci); */
/* } */
/* } */
/* Sub-self-interaction for external gravity ? */
else if (t->type == task_type_sub_self &&
t->subtype == task_subtype_external_grav) {
/* /\* Sub-self-interaction for external gravity ? *\/ */
/* else if (t->type == task_type_sub_self && */
/* t->subtype == task_subtype_external_grav) { */
if (t->ci->nodeID == nodeID) {
engine_make_external_gravity_dependencies(sched, t, t->ci);
}
}
/* if (t->ci->nodeID == nodeID) { */
/* engine_make_external_gravity_dependencies(sched, t, t->ci); */
/* } */
/* } */
/* Otherwise, sub-pair interaction? */
else if (t->type == task_type_sub_pair && t->subtype == task_subtype_grav) {
/* /\* Otherwise, sub-pair interaction? *\/ */
/* else if (t->type == task_type_sub_pair && t->subtype ==
* task_subtype_grav) { */
if (t->ci->nodeID == nodeID) {
/* if (t->ci->nodeID == nodeID) { */
engine_make_gravity_dependencies(sched, t, t->ci);
}
if (t->cj->nodeID == nodeID && t->ci->super != t->cj->super) {
/* engine_make_gravity_dependencies(sched, t, t->ci); */
/* } */
/* if (t->cj->nodeID == nodeID && t->ci->super != t->cj->super) { */
engine_make_gravity_dependencies(sched, t, t->cj);
}
}
}
/* engine_make_gravity_dependencies(sched, t, t->cj); */
/* } */
/* } */
/* } */
}
#ifdef EXTRA_HYDRO_LOOP
......@@ -2189,32 +2194,34 @@ void engine_make_extra_hydroloop_tasks(struct engine *e) {
*/
void engine_make_gravityrecursive_tasks(struct engine *e) {
struct space *s = e->s;
struct scheduler *sched = &e->sched;
const int nodeID = e->nodeID;
const int nr_cells = s->nr_cells;
struct cell *cells = s->cells_top;
for (int k = 0; k < nr_cells; k++) {
/* Only do this for local cells containing gravity particles */
if (cells[k].nodeID == nodeID && cells[k].gcount > 0) {
/* Create tasks at top level. */
struct task *up =
scheduler_addtask(sched, task_type_grav_up, task_subtype_none, 0, 0,
&cells[k], NULL, 0);
struct task *down = NULL;
/* struct task *down = */
/* scheduler_addtask(sched, task_type_grav_down, task_subtype_none, 0,
* 0, */
/* &cells[k], NULL, 0); */
/* Push tasks down the cell hierarchy. */
engine_addtasks_grav(e, &cells[k], up, down);
}
}
/* struct space *s = e->s; */
/* struct scheduler *sched = &e->sched; */
/* const int nodeID = e->nodeID; */
/* const int nr_cells = s->nr_cells; */
/* struct cell *cells = s->cells_top; */
/* for (int k = 0; k < nr_cells; k++) { */
/* /\* Only do this for local cells containing gravity particles *\/ */
/* if (cells[k].nodeID == nodeID && cells[k].gcount > 0) { */
/* /\* Create tasks at top level. *\/ */
/* struct task *up = */
/* scheduler_addtask(sched, task_type_grav_up, task_subtype_none, 0,
* 0, */
/* &cells[k], NULL, 0); */
/* struct task *down = NULL; */
/* /\* struct task *down = *\/ */
/* /\* scheduler_addtask(sched, task_type_grav_down,
* task_subtype_none, 0, */
/* * 0, *\/ */
/* /\* &cells[k], NULL, 0); *\/ */
/* /\* Push tasks down the cell hierarchy. *\/ */
/* engine_addtasks_grav(e, &cells[k], up, down); */
/* } */
/* } */
}
/**
......@@ -2489,10 +2496,10 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
}
/* Tasks with no cells should not be skipped? */
else if (t->type == task_type_grav_gather_m ||
t->type == task_type_grav_fft) {
scheduler_activate(s, t);
}
/* else if (t->type == task_type_grav_gather_m || */
/* t->type == task_type_grav_fft) { */
/* scheduler_activate(s, t); */
/* } */
}
}
......
......@@ -1579,8 +1579,7 @@ void *runner_main(void *data) {
#ifndef WITH_MPI
if (ci == NULL && cj == NULL) {
if (t->type != task_type_grav_gather_m && t->type != task_type_grav_fft)
error("Task not associated with cells!");
error("Task not associated with cells!");
} else if (cj == NULL) { /* self */
......@@ -1738,14 +1737,14 @@ void *runner_main(void *data) {
case task_type_grav_mm:
runner_do_grav_mm(r, t->ci, 1);
break;
case task_type_grav_up:
runner_do_grav_up(r, t->ci);
break;
case task_type_grav_gather_m:
break;
case task_type_grav_fft:
runner_do_grav_fft(r);
break;
/* case task_type_grav_up: */
/* runner_do_grav_up(r, t->ci); */
/* break; */
/* case task_type_grav_gather_m: */
/* break; */
/* case task_type_grav_fft: */
/* runner_do_grav_fft(r); */
/* break; */
case task_type_cooling:
if (e->policy & engine_policy_cooling) runner_do_end_force(r, ci, 1);
runner_do_cooling(r, t->ci, 1);
......
......@@ -1092,8 +1092,7 @@ void scheduler_start(struct scheduler *s) {
if (ci == NULL && cj == NULL) {
if (t->type != task_type_grav_gather_m && t->type != task_type_grav_fft)
error("Task not associated with cells!");
error("Task not associated with cells!");
} else if (cj == NULL) { /* self */
......
......@@ -47,12 +47,27 @@
#include "lock.h"
/* Task type names. */
const char *taskID_names[task_type_count] = {
"none", "sort", "self", "pair", "sub_self",
"sub_pair", "init", "ghost", "extra_ghost", "drift",
"kick1", "kick2", "timestep", "send", "recv",
"grav_gather_m", "grav_fft", "grav_mm", "grav_up", "cooling",
"sourceterms"};
const char *taskID_names[task_type_count] = {"none",
"sort",
"self",
"pair",
"sub_self",
"sub_pair",
"init",
"ghost",
"extra_ghost",
"drift",
"kick1",
"kick2",
"timestep",
"send",
"recv",
"grav_top_level",
"grav_long_range",
"grav_mm",
"grav_down",
"cooling",
"sourceterms"};
const char *subtaskID_names[task_subtype_count] = {
"none", "density", "gradient", "force", "grav", "external_grav",
......@@ -165,13 +180,15 @@ __attribute__((always_inline)) INLINE static enum task_actions task_acts_on(
error("Task without particles");
break;
case task_type_grav_gather_m:
case task_type_grav_fft:
case task_type_grav_top_level:
case task_type_grav_long_range:
case task_type_grav_mm:
case task_type_grav_up:
return task_action_multipole;
break;
case task_type_grav_down:
return task_action_gpart;
default:
error("Unknown task_action for task");
return task_action_none;
......
......@@ -51,10 +51,10 @@ enum task_types {
task_type_timestep,
task_type_send,
task_type_recv,
task_type_grav_gather_m,
task_type_grav_fft,
task_type_grav_top_level,
task_type_grav_long_range,
task_type_grav_mm,
task_type_grav_up,
task_type_grav_down,
task_type_cooling,
task_type_sourceterms,
task_type_count
......
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