Commit 25bd066d authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Add a gsuper pointer to the cells.

parent 54aa9fea
......@@ -110,9 +110,14 @@ struct cell {
/* Parent cell. */
struct cell *parent;
/* Super cell, i.e. the highest-level supercell that has interactions. */
/* Super cell, i.e. the highest-level supercell that has hydro interactions.
*/
struct cell *super;
/* Super cell, i.e. the highest-level supercell that has gravity interactions.
*/
struct cell *gsuper;
/* The task computing this cell's sorts. */
struct task *sorts;
int sortsize;
......
......@@ -122,10 +122,10 @@ void engine_addlink(struct engine *e, struct link **l, struct task *t) {
*
* @param e The #engine.
* @param c The #cell.
* @param super The super #cell.
* @param gsuper The gsuper #cell.
*/
void engine_make_gravity_hierarchical_tasks(struct engine *e, struct cell *c,
struct cell *super) {
struct cell *gsuper) {
struct scheduler *s = &e->sched;
const int is_with_external_gravity =
......@@ -134,10 +134,10 @@ void engine_make_gravity_hierarchical_tasks(struct engine *e, struct cell *c,
const int is_fixdt = (e->policy & engine_policy_fixdt) == engine_policy_fixdt;
/* Is this the super-cell? */
if (super == NULL && (c->grav != NULL || (!c->split && c->gcount > 0))) {
if (gsuper == NULL && (c->grav != NULL || (!c->split && c->gcount > 0))) {
/* This is the super cell, i.e. the first with gravity tasks attached. */
super = c;
gsuper = c;
/* Local tasks only... */
if (c->nodeID == e->nodeID) {
......@@ -165,13 +165,13 @@ void engine_make_gravity_hierarchical_tasks(struct engine *e, struct cell *c,
}
/* Set the super-cell. */
c->super = super;
c->gsuper = gsuper;
/* Recurse. */
if (c->split)
for (int k = 0; k < 8; k++)
if (c->progeny[k] != NULL)
engine_make_gravity_hierarchical_tasks(e, c->progeny[k], super);
engine_make_gravity_hierarchical_tasks(e, c->progeny[k], gsuper);
}
/**
......@@ -1428,11 +1428,11 @@ static inline void engine_make_gravity_dependencies(struct scheduler *sched,
struct cell *c) {
/* init --> gravity --> kick */
scheduler_addunlock(sched, c->super->init, gravity);
scheduler_addunlock(sched, gravity, c->super->kick);
scheduler_addunlock(sched, c->gsuper->init, gravity);
scheduler_addunlock(sched, gravity, c->gsuper->kick);
/* grav_up --> gravity ( --> kick) */
scheduler_addunlock(sched, c->super->grav_up, gravity);
scheduler_addunlock(sched, c->gsuper->grav_up, gravity);
}
/**
......@@ -1474,10 +1474,10 @@ void engine_link_gravity_tasks(struct engine *e) {
/* Gather the multipoles --> mm interaction --> kick */
scheduler_addunlock(sched, gather, t);
scheduler_addunlock(sched, t, t->ci->super->kick);
scheduler_addunlock(sched, t, t->ci->gsuper->kick);
/* init --> mm interaction */
scheduler_addunlock(sched, t->ci->super->init, t);
scheduler_addunlock(sched, t->ci->gsuper->init, t);
}
/* Self-interaction? */
......@@ -1495,7 +1495,7 @@ void engine_link_gravity_tasks(struct engine *e) {
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->gsuper != t->cj->gsuper) {
engine_make_gravity_dependencies(sched, t, t->cj);
}
......@@ -1517,7 +1517,7 @@ void engine_link_gravity_tasks(struct engine *e) {
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->gsuper != t->cj->gsuper) {
engine_make_gravity_dependencies(sched, t, t->cj);
}
......
......@@ -1104,10 +1104,20 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
break;
case task_type_pair:
case task_type_sub_pair:
if (t->subtype == task_subtype_grav) {
qid = t->ci->gsuper->owner;
if (qid < 0 ||
s->queues[qid].count > s->queues[t->cj->gsuper->owner].count)
qid = t->cj->gsuper->owner;
} else {
qid = t->ci->super->owner;
if (qid < 0 ||
s->queues[qid].count > s->queues[t->cj->super->owner].count)
qid = t->cj->super->owner;
}
break;
case task_type_recv:
#ifdef WITH_MPI
......
......@@ -294,6 +294,7 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
c->count = 0;
c->gcount = 0;
c->super = c;
c->gsuper = c;
lock_init(&c->lock);
}
......@@ -364,6 +365,7 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
s->cells[k].ghost = NULL;
s->cells[k].kick = NULL;
s->cells[k].super = &s->cells[k];
s->cells[k].gsuper = &s->cells[k];
}
s->maxdepth = 0;
}
......@@ -1282,6 +1284,8 @@ void space_split_mapper(void *map_data, int num_elements, void *extra_data) {
temp->dx_max = 0.f;
temp->nodeID = c->nodeID;
temp->parent = c;
temp->super = NULL;
temp->gsuper = NULL;
c->progeny[k] = temp;
}
......
......@@ -48,7 +48,6 @@ struct UnitSystem {
/*! Conversion factor from Kelvins to internal temperature units. */
double UnitTemperature_in_cgs;
};
/**
......
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