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