Commit 290cf60b authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Documentation and code formatting.

parent a7da6b3f
...@@ -2199,7 +2199,8 @@ void cell_set_super(struct cell *c, struct cell *super) { ...@@ -2199,7 +2199,8 @@ void cell_set_super(struct cell *c, struct cell *super) {
* @brief Set the super-cell pointers for all cells in a hierarchy. * @brief Set the super-cell pointers for all cells in a hierarchy.
* *
* @param c The top-level #cell to play with. * @param c The top-level #cell to play with.
* @param super Pointer to the deepest cell with tasks in this part of the tree. * @param super_hydro Pointer to the deepest cell with tasks in this part of the
* tree.
*/ */
void cell_set_super_hydro(struct cell *c, struct cell *super_hydro) { void cell_set_super_hydro(struct cell *c, struct cell *super_hydro) {
...@@ -2212,14 +2213,16 @@ void cell_set_super_hydro(struct cell *c, struct cell *super_hydro) { ...@@ -2212,14 +2213,16 @@ void cell_set_super_hydro(struct cell *c, struct cell *super_hydro) {
/* 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) cell_set_super_hydro(c->progeny[k], super_hydro); if (c->progeny[k] != NULL)
cell_set_super_hydro(c->progeny[k], super_hydro);
} }
/** /**
* @brief Set the super-cell pointers for all cells in a hierarchy. * @brief Set the super-cell pointers for all cells in a hierarchy.
* *
* @param c The top-level #cell to play with. * @param c The top-level #cell to play with.
* @param super Pointer to the deepest cell with tasks in this part of the tree. * @param super_gravity Pointer to the deepest cell with tasks in this part of
* the tree.
*/ */
void cell_set_super_gravity(struct cell *c, struct cell *super_gravity) { void cell_set_super_gravity(struct cell *c, struct cell *super_gravity) {
...@@ -2232,7 +2235,8 @@ void cell_set_super_gravity(struct cell *c, struct cell *super_gravity) { ...@@ -2232,7 +2235,8 @@ void cell_set_super_gravity(struct cell *c, struct cell *super_gravity) {
/* 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) cell_set_super_gravity(c->progeny[k], super_gravity); if (c->progeny[k] != NULL)
cell_set_super_gravity(c->progeny[k], super_gravity);
} }
/** /**
...@@ -2244,13 +2248,13 @@ void cell_set_super_gravity(struct cell *c, struct cell *super_gravity) { ...@@ -2244,13 +2248,13 @@ void cell_set_super_gravity(struct cell *c, struct cell *super_gravity) {
*/ */
void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data) { void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data) {
const struct engine *e = (const struct engine*) extra_data; const struct engine *e = (const struct engine *)extra_data;
for (int ind = 0; ind < num_elements; ind++) { for (int ind = 0; ind < num_elements; ind++) {
struct cell *c = &((struct cell *)map_data)[ind]; struct cell *c = &((struct cell *)map_data)[ind];
if(e->policy & engine_policy_hydro) if (e->policy & engine_policy_hydro) cell_set_super_hydro(c, NULL);
cell_set_super_hydro(c, NULL); if (e->policy &
if(e->policy & (engine_policy_self_gravity | engine_policy_external_gravity)) (engine_policy_self_gravity | engine_policy_external_gravity))
cell_set_super_gravity(c, NULL); cell_set_super_gravity(c, NULL);
cell_set_super(c, NULL); cell_set_super(c, NULL);
} }
......
...@@ -181,10 +181,12 @@ struct cell { ...@@ -181,10 +181,12 @@ struct cell {
/*! Super cell, i.e. the highest-level parent cell with *any* task */ /*! Super cell, i.e. the highest-level parent cell with *any* task */
struct cell *super; struct cell *super;
/*! Super cell, i.e. the highest-level parent cell that has a hydro pair/self tasks */ /*! Super cell, i.e. the highest-level parent cell that has a hydro pair/self
* tasks */
struct cell *super_hydro; struct cell *super_hydro;
/*! Super cell, i.e. the highest-level parent cell that has a grav pair/self tasks */ /*! Super cell, i.e. the highest-level parent cell that has a grav pair/self
* tasks */
struct cell *super_gravity; struct cell *super_gravity;
/*! Linked list of the tasks computing this cell's hydro density. */ /*! Linked list of the tasks computing this cell's hydro density. */
......
...@@ -154,6 +154,18 @@ void engine_add_ghosts(struct engine *e, struct cell *c, struct task *ghost_in, ...@@ -154,6 +154,18 @@ void engine_add_ghosts(struct engine *e, struct cell *c, struct task *ghost_in,
} }
} }
/**
* @brief Generate the hydro hierarchical tasks for a hierarchy of cells -
* i.e. all the O(Npart) tasks -- timestep version
*
* Tasks are only created here. The dependencies will be added later on.
*
* Note that there is no need to recurse below the super-cell. Note also
* that we only add tasks if the relevant particles are present in the cell.
*
* @param e The #engine.
* @param c The #cell.
*/
void engine_make_hierarchical_tasks_common(struct engine *e, struct cell *c) { void engine_make_hierarchical_tasks_common(struct engine *e, struct cell *c) {
struct scheduler *s = &e->sched; struct scheduler *s = &e->sched;
...@@ -191,7 +203,7 @@ void engine_make_hierarchical_tasks_common(struct engine *e, struct cell *c) { ...@@ -191,7 +203,7 @@ void engine_make_hierarchical_tasks_common(struct engine *e, struct cell *c) {
/** /**
* @brief Generate the hydro hierarchical tasks for a hierarchy of cells - * @brief Generate the hydro hierarchical tasks for a hierarchy of cells -
* i.e. all the O(Npart) tasks. * i.e. all the O(Npart) tasks -- hydro version
* *
* Tasks are only created here. The dependencies will be added later on. * Tasks are only created here. The dependencies will be added later on.
* *
...@@ -211,8 +223,8 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c) { ...@@ -211,8 +223,8 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c) {
if (c->super_hydro == c) { if (c->super_hydro == c) {
/* Add the sort task. */ /* Add the sort task. */
c->sorts = scheduler_addtask(s, task_type_sort, task_subtype_none, 0, 0, c->sorts =
c, NULL); scheduler_addtask(s, task_type_sort, task_subtype_none, 0, 0, c, NULL);
/* Local tasks only... */ /* Local tasks only... */
if (c->nodeID == e->nodeID) { if (c->nodeID == e->nodeID) {
...@@ -236,7 +248,6 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c) { ...@@ -236,7 +248,6 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c) {
task_subtype_none, 0, 0, c, NULL); task_subtype_none, 0, 0, c, NULL);
#endif #endif
/* Cooling task */ /* Cooling task */
if (is_with_cooling) { if (is_with_cooling) {
c->cooling = scheduler_addtask(s, task_type_cooling, task_subtype_none, c->cooling = scheduler_addtask(s, task_type_cooling, task_subtype_none,
...@@ -250,7 +261,6 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c) { ...@@ -250,7 +261,6 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c) {
c->sourceterms = scheduler_addtask(s, task_type_sourceterms, c->sourceterms = scheduler_addtask(s, task_type_sourceterms,
task_subtype_none, 0, 0, c, NULL); task_subtype_none, 0, 0, c, NULL);
} }
} }
} else { /* We are above the super-cell so need to go deeper */ } else { /* We are above the super-cell so need to go deeper */
...@@ -263,7 +273,18 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c) { ...@@ -263,7 +273,18 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c) {
} }
} }
/**
* @brief Generate the hydro hierarchical tasks for a hierarchy of cells -
* i.e. all the O(Npart) tasks -- gravity version
*
* Tasks are only created here. The dependencies will be added later on.
*
* Note that there is no need to recurse below the super-cell. Note also
* that we only add tasks if the relevant particles are present in the cell.
*
* @param e The #engine.
* @param c The #cell.
*/
void engine_make_hierarchical_tasks_gravity(struct engine *e, struct cell *c) { void engine_make_hierarchical_tasks_gravity(struct engine *e, struct cell *c) {
struct scheduler *s = &e->sched; struct scheduler *s = &e->sched;
...@@ -279,16 +300,15 @@ void engine_make_hierarchical_tasks_gravity(struct engine *e, struct cell *c) { ...@@ -279,16 +300,15 @@ void engine_make_hierarchical_tasks_gravity(struct engine *e, struct cell *c) {
c->drift_gpart = scheduler_addtask(s, task_type_drift_gpart, c->drift_gpart = scheduler_addtask(s, task_type_drift_gpart,
task_subtype_none, 0, 0, c, NULL); task_subtype_none, 0, 0, c, NULL);
if (is_self_gravity) {
if(is_self_gravity) {
/* Initialisation of the multipoles */ /* Initialisation of the multipoles */
c->init_grav = scheduler_addtask(s, task_type_init_grav, c->init_grav = scheduler_addtask(s, task_type_init_grav,
task_subtype_none, 0, 0, c, NULL); task_subtype_none, 0, 0, c, NULL);
/* Gravity non-neighbouring pm calculations */ /* Gravity non-neighbouring pm calculations */
c->grav_long_range = scheduler_addtask(s, task_type_grav_long_range, c->grav_long_range = scheduler_addtask(
task_subtype_none, 0, 0, c, NULL); s, task_type_grav_long_range, task_subtype_none, 0, 0, c, NULL);
/* Gravity recursive down-pass */ /* Gravity recursive down-pass */
c->grav_down = scheduler_addtask(s, task_type_grav_down, c->grav_down = scheduler_addtask(s, task_type_grav_down,
...@@ -299,7 +319,6 @@ void engine_make_hierarchical_tasks_gravity(struct engine *e, struct cell *c) { ...@@ -299,7 +319,6 @@ void engine_make_hierarchical_tasks_gravity(struct engine *e, struct cell *c) {
scheduler_addunlock(s, c->init_grav, c->grav_long_range); scheduler_addunlock(s, c->init_grav, c->grav_long_range);
scheduler_addunlock(s, c->grav_long_range, c->grav_down); scheduler_addunlock(s, c->grav_long_range, c->grav_down);
scheduler_addunlock(s, c->grav_down, c->super->kick2); scheduler_addunlock(s, c->grav_down, c->super->kick2);
} }
} }
...@@ -313,23 +332,22 @@ void engine_make_hierarchical_tasks_gravity(struct engine *e, struct cell *c) { ...@@ -313,23 +332,22 @@ void engine_make_hierarchical_tasks_gravity(struct engine *e, struct cell *c) {
} }
} }
void engine_make_hierarchical_tasks_mapper(void *map_data, int num_elements, void engine_make_hierarchical_tasks_mapper(void *map_data, int num_elements,
void *extra_data) { void *extra_data) {
struct engine *e = (struct engine *)extra_data; struct engine *e = (struct engine *)extra_data;
const int is_with_hydro = (e->policy & engine_policy_hydro); const int is_with_hydro = (e->policy & engine_policy_hydro);
const int is_with_self_gravity = (e->policy & engine_policy_self_gravity); const int is_with_self_gravity = (e->policy & engine_policy_self_gravity);
const int is_with_external_gravity = (e->policy & engine_policy_external_gravity); const int is_with_external_gravity =
(e->policy & engine_policy_external_gravity);
for (int ind = 0; ind < num_elements; ind++) { for (int ind = 0; ind < num_elements; ind++) {
struct cell *c = &((struct cell *)map_data)[ind]; struct cell *c = &((struct cell *)map_data)[ind];
/* Make the common tasks (time integration) */ /* Make the common tasks (time integration) */
engine_make_hierarchical_tasks_common(e, c); engine_make_hierarchical_tasks_common(e, c);
/* Add the hydro stuff */ /* Add the hydro stuff */
if(is_with_hydro) if (is_with_hydro) engine_make_hierarchical_tasks_hydro(e, c);
engine_make_hierarchical_tasks_hydro(e, c);
/* And the gravity stuff */ /* And the gravity stuff */
if(is_with_self_gravity || is_with_external_gravity) if (is_with_self_gravity || is_with_external_gravity)
engine_make_hierarchical_tasks_gravity(e, c); engine_make_hierarchical_tasks_gravity(e, c);
} }
} }
...@@ -1138,7 +1156,8 @@ void engine_addtasks_send_hydro(struct engine *e, struct cell *ci, ...@@ -1138,7 +1156,8 @@ void engine_addtasks_send_hydro(struct engine *e, struct cell *ci,
scheduler_addunlock(s, ci->super_hydro->extra_ghost, t_gradient); scheduler_addunlock(s, ci->super_hydro->extra_ghost, t_gradient);
/* The send_rho task should unlock the super_hydro-cell's extra_ghost task. */ /* The send_rho task should unlock the super_hydro-cell's extra_ghost
* task. */
scheduler_addunlock(s, t_rho, ci->super_hydro->extra_ghost); scheduler_addunlock(s, t_rho, ci->super_hydro->extra_ghost);
/* The send_rho task depends on the cell's ghost task. */ /* The send_rho task depends on the cell's ghost task. */
...@@ -2568,7 +2587,8 @@ void engine_link_gravity_tasks(struct engine *e) { ...@@ -2568,7 +2587,8 @@ void engine_link_gravity_tasks(struct engine *e) {
engine_make_self_gravity_dependencies(sched, t, t->ci); engine_make_self_gravity_dependencies(sched, t, t->ci);
} }
if (t->cj->nodeID == nodeID && t->ci->super_gravity != t->cj->super_gravity) { if (t->cj->nodeID == nodeID &&
t->ci->super_gravity != t->cj->super_gravity) {
engine_make_self_gravity_dependencies(sched, t, t->cj); engine_make_self_gravity_dependencies(sched, t, t->cj);
} }
...@@ -2599,7 +2619,8 @@ void engine_link_gravity_tasks(struct engine *e) { ...@@ -2599,7 +2619,8 @@ void engine_link_gravity_tasks(struct engine *e) {
engine_make_self_gravity_dependencies(sched, t, t->ci); engine_make_self_gravity_dependencies(sched, t, t->ci);
} }
if (t->cj->nodeID == nodeID && t->ci->super_gravity != t->cj->super_gravity) { if (t->cj->nodeID == nodeID &&
t->ci->super_gravity != t->cj->super_gravity) {
engine_make_self_gravity_dependencies(sched, t, t->cj); engine_make_self_gravity_dependencies(sched, t, t->cj);
} }
...@@ -2770,9 +2791,10 @@ void engine_make_extra_hydroloop_tasks_mapper(void *map_data, int num_elements, ...@@ -2770,9 +2791,10 @@ void engine_make_extra_hydroloop_tasks_mapper(void *map_data, int num_elements,
scheduler_addunlock(sched, t2, t->ci->super->kick2); scheduler_addunlock(sched, t2, t->ci->super->kick2);
} }
if (t->cj->nodeID == nodeID) { if (t->cj->nodeID == nodeID) {
if(t->ci->super_hydro != t->cj->super_hydro) if (t->ci->super_hydro != t->cj->super_hydro)
engine_make_hydro_loops_dependencies(sched, t, t2, t->cj, with_cooling); engine_make_hydro_loops_dependencies(sched, t, t2, t->cj,
if(t->ci->super != t->cj->super) with_cooling);
if (t->ci->super != t->cj->super)
scheduler_addunlock(sched, t2, t->cj->super->kick2); scheduler_addunlock(sched, t2, t->cj->super->kick2);
} }
...@@ -2823,8 +2845,7 @@ void engine_make_extra_hydroloop_tasks_mapper(void *map_data, int num_elements, ...@@ -2823,8 +2845,7 @@ void engine_make_extra_hydroloop_tasks_mapper(void *map_data, int num_elements,
if (t->ci->nodeID == nodeID) { if (t->ci->nodeID == nodeID) {
engine_make_hydro_loops_dependencies(sched, t, t2, t->ci, with_cooling); engine_make_hydro_loops_dependencies(sched, t, t2, t->ci, with_cooling);
scheduler_addunlock(sched, t2, t->ci->super->kick2); scheduler_addunlock(sched, t2, t->ci->super->kick2);
} } else
else
error("oo"); error("oo");
#endif #endif
} }
...@@ -2887,9 +2908,10 @@ void engine_make_extra_hydroloop_tasks_mapper(void *map_data, int num_elements, ...@@ -2887,9 +2908,10 @@ void engine_make_extra_hydroloop_tasks_mapper(void *map_data, int num_elements,
scheduler_addunlock(sched, t2, t->ci->super->kick2); scheduler_addunlock(sched, t2, t->ci->super->kick2);
} }
if (t->cj->nodeID == nodeID) { if (t->cj->nodeID == nodeID) {
if(t->ci->super_hydro != t->cj->super_hydro) if (t->ci->super_hydro != t->cj->super_hydro)
engine_make_hydro_loops_dependencies(sched, t, t2, t->cj, with_cooling); engine_make_hydro_loops_dependencies(sched, t, t2, t->cj,
if(t->ci->super != t->cj->super) with_cooling);
if (t->ci->super != t->cj->super)
scheduler_addunlock(sched, t2, t->cj->super->kick2); scheduler_addunlock(sched, t2, t->cj->super->kick2);
} }
#endif #endif
...@@ -3577,8 +3599,6 @@ void engine_rebuild(struct engine *e, int clean_h_values) { ...@@ -3577,8 +3599,6 @@ void engine_rebuild(struct engine *e, int clean_h_values) {
/* Clear the forcerebuild flag, whatever it was. */ /* Clear the forcerebuild flag, whatever it was. */
e->forcerebuild = 0; e->forcerebuild = 0;
message("REBUILD");
/* Re-build the space. */ /* Re-build the space. */
space_rebuild(e->s, e->verbose); space_rebuild(e->s, e->verbose);
...@@ -3615,7 +3635,7 @@ void engine_rebuild(struct engine *e, int clean_h_values) { ...@@ -3615,7 +3635,7 @@ void engine_rebuild(struct engine *e, int clean_h_values) {
error("engine_marktasks failed after space_rebuild."); error("engine_marktasks failed after space_rebuild.");
/* Print the status of the system */ /* Print the status of the system */
// if (e->verbose) engine_print_task_counts(e); if (e->verbose) engine_print_task_counts(e);
/* Flag that a rebuild has taken place */ /* Flag that a rebuild has taken place */
e->step_props |= engine_step_prop_rebuild; e->step_props |= engine_step_prop_rebuild;
...@@ -4223,9 +4243,9 @@ void engine_step(struct engine *e) { ...@@ -4223,9 +4243,9 @@ void engine_step(struct engine *e) {
if (e->nodeID == 0) { if (e->nodeID == 0) {
/* Print some information to the screen */ /* Print some information to the screen */
printf(" %6d %14e %14e %12zu %12zu %12zu %21.3f %6d\n", e->step, printf(" %6d %14e %14e %12zu %12zu %12zu %21.3f %6d\n", e->step, e->time,
e->time, e->timeStep, e->updates, e->g_updates, e->timeStep, e->updates, e->g_updates, e->s_updates,
e->s_updates, e->wallclock_time, e->step_props); e->wallclock_time, e->step_props);
fflush(stdout); fflush(stdout);
fprintf(e->file_timesteps, " %6d %14e %14e %12zu %12zu %12zu %21.3f %6d\n", fprintf(e->file_timesteps, " %6d %14e %14e %12zu %12zu %12zu %21.3f %6d\n",
...@@ -4247,8 +4267,6 @@ void engine_step(struct engine *e) { ...@@ -4247,8 +4267,6 @@ void engine_step(struct engine *e) {
/* Prepare the tasks to be launched, rebuild or repartition if needed. */ /* Prepare the tasks to be launched, rebuild or repartition if needed. */
engine_prepare(e); engine_prepare(e);
engine_print_task_counts(e);
#ifdef WITH_MPI #ifdef WITH_MPI
/* Repartition the space amongst the nodes? */ /* Repartition the space amongst the nodes? */
engine_repartition_trigger(e); engine_repartition_trigger(e);
......
...@@ -1427,7 +1427,7 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { ...@@ -1427,7 +1427,7 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
switch (t->type) { switch (t->type) {
case task_type_self: case task_type_self:
case task_type_sub_self: case task_type_sub_self:
if(t->subtype == task_subtype_grav) if (t->subtype == task_subtype_grav)
qid = t->ci->super_gravity->owner; qid = t->ci->super_gravity->owner;
else else
qid = t->ci->super_hydro->owner; qid = t->ci->super_hydro->owner;
......
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