Commit 0473da3a authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Applied code formatting tool.

parent 48df22d5
......@@ -2025,8 +2025,10 @@ void cell_activate_stars_sorts_up(struct cell *c, struct scheduler *s) {
parent->stars.do_sub_sort = 1;
if (parent == c->hydro.super) {
#ifdef SWIFT_DEBUG_CHECKS
if ((parent->nodeID == engine_rank && parent->stars.sorts_local == NULL) ||
(parent->nodeID != engine_rank && parent->stars.sorts_foreign == NULL))
if ((parent->nodeID == engine_rank &&
parent->stars.sorts_local == NULL) ||
(parent->nodeID != engine_rank &&
parent->stars.sorts_foreign == NULL))
error("Trying to activate un-existing parents->stars.sorts");
#endif
if (parent->nodeID == engine_rank) {
......@@ -3343,7 +3345,7 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
struct engine *e = s->space->e;
const int nodeID = e->nodeID;
int rebuild = 0;
/* Un-skip the density tasks involved with this cell. */
for (struct link *l = c->stars.density; l != NULL; l = l->next) {
struct task *t = l->t;
......@@ -3354,11 +3356,10 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
const int ci_nodeID = ci->nodeID;
const int cj_nodeID = (cj != NULL) ? cj->nodeID : -1;
if (t->type == task_type_self &&
ci_active && ci->nodeID == nodeID) {
if (t->type == task_type_self && ci_active && ci->nodeID == nodeID) {
cell_activate_drift_part(ci, s);
cell_activate_drift_spart(ci, s);
cell_activate_drift_part(ci, s);
cell_activate_drift_spart(ci, s);
}
/* Activate cells that contains either a density or a feedback task */
......@@ -3430,21 +3431,21 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
if (cj_active) {
scheduler_activate(s, ci->mpi.hydro.recv_xv);
/* If the local cell is active, more stuff will be needed.
*/
/* If the local cell is active, more stuff will be needed.
*/
scheduler_activate_send(s, cj->mpi.stars.send, ci_nodeID);
/* If the local cell is active, send its ti_end values. */
scheduler_activate_send(s, cj->mpi.send_ti, ci_nodeID);
}
/* If the local cell is active, send its ti_end values. */
scheduler_activate_send(s, cj->mpi.send_ti, ci_nodeID);
}
if (ci_active) {
scheduler_activate(s, ci->mpi.stars.recv);
/* If the foreign cell is active, we want its ti_end values. */
scheduler_activate(s, ci->mpi.recv_ti);
/* If the foreign cell is active, we want its ti_end values. */
scheduler_activate(s, ci->mpi.recv_ti);
/* Is the foreign cell active and will need stuff from us? */
/* Is the foreign cell active and will need stuff from us? */
scheduler_activate_send(s, cj->mpi.hydro.send_xv, ci_nodeID);
/* Drift the cell which will be sent; note that not all sent
......@@ -3458,28 +3459,27 @@ int cell_unskip_stars_tasks(struct cell *c, struct scheduler *s) {
if (ci_active) {
scheduler_activate(s, cj->mpi.hydro.recv_xv);
/* If the local cell is active, more stuff will be needed.
*/
/* If the local cell is active, more stuff will be needed.
*/
scheduler_activate_send(s, ci->mpi.stars.send, cj_nodeID);
/* If the local cell is active, send its ti_end values. */
scheduler_activate_send(s, ci->mpi.send_ti, cj_nodeID);
/* If the local cell is active, send its ti_end values. */
scheduler_activate_send(s, ci->mpi.send_ti, cj_nodeID);
}
if (cj_active) {
scheduler_activate(s, cj->mpi.stars.recv);
/* If the foreign cell is active, we want its ti_end values. */
scheduler_activate(s, cj->mpi.recv_ti);
/* If the foreign cell is active, we want its ti_end values. */
scheduler_activate(s, cj->mpi.recv_ti);
/* Is the foreign cell active and will need stuff from us? */
/* Is the foreign cell active and will need stuff from us? */
scheduler_activate_send(s, ci->mpi.hydro.send_xv, cj_nodeID);
/* Drift the cell which will be sent; note that not all sent
particles will be drifted, only those that are needed. */
cell_activate_drift_part(ci, s);
}
}
#endif
}
......
......@@ -868,16 +868,18 @@ cell_can_recurse_in_self_hydro_task(const struct cell *c) {
* @param cj The #cell with hydro parts.
*/
__attribute__((always_inline)) INLINE static int
cell_can_recurse_in_pair_stars_task(const struct cell *ci, const struct cell *cj) {
cell_can_recurse_in_pair_stars_task(const struct cell *ci,
const struct cell *cj) {
/* Is the cell split ? */
/* If so, is the cut-off radius plus the max distance the parts have moved */
/* smaller than the sub-cell sizes ? */
/* Note: We use the _old values as these might have been updated by a drift */
return ci->split && cj->split && ((kernel_gamma * ci->stars.h_max_old +
ci->stars.dx_max_part_old) < 0.5f * ci->dmin) &&
((kernel_gamma * cj->hydro.h_max_old +
cj->hydro.dx_max_part_old) < 0.5f * cj->dmin);
return ci->split && cj->split &&
((kernel_gamma * ci->stars.h_max_old + ci->stars.dx_max_part_old) <
0.5f * ci->dmin) &&
((kernel_gamma * cj->hydro.h_max_old + cj->hydro.dx_max_part_old) <
0.5f * cj->dmin);
}
/**
......@@ -891,7 +893,7 @@ cell_can_recurse_in_self_stars_task(const struct cell *c) {
/* Is the cell split and not smaller than the smoothing length? */
return c->split && (kernel_gamma * c->stars.h_max_old < 0.5f * c->dmin) &&
(kernel_gamma * c->hydro.h_max_old < 0.5f * c->dmin);
(kernel_gamma * c->hydro.h_max_old < 0.5f * c->dmin);
}
/**
......@@ -946,8 +948,8 @@ __attribute__((always_inline)) INLINE static int cell_can_split_pair_stars_task(
/* Note that since tasks are create after a rebuild no need to take */
/* into account any part motion (i.e. dx_max == 0 here) */
return ci->split && cj->split &&
(space_stretch * kernel_gamma * ci->stars.h_max < 0.5f * ci->dmin) &&
(space_stretch * kernel_gamma * cj->hydro.h_max < 0.5f * cj->dmin);
(space_stretch * kernel_gamma * ci->stars.h_max < 0.5f * ci->dmin) &&
(space_stretch * kernel_gamma * cj->hydro.h_max < 0.5f * cj->dmin);
}
/**
......@@ -965,8 +967,8 @@ __attribute__((always_inline)) INLINE static int cell_can_split_self_stars_task(
/* Note: No need for more checks here as all the sub-pairs and sub-self */
/* tasks will be created. So no need to check for h_max */
return c->split &&
(space_stretch * kernel_gamma * c->stars.h_max < 0.5f * c->dmin) &&
(space_stretch * kernel_gamma * c->hydro.h_max < 0.5f * c->dmin);
(space_stretch * kernel_gamma * c->stars.h_max < 0.5f * c->dmin) &&
(space_stretch * kernel_gamma * c->hydro.h_max < 0.5f * c->dmin);
}
/**
......
......@@ -2684,8 +2684,9 @@ void engine_skip_force_and_kick(struct engine *e) {
t->type == task_type_grav_long_range || t->type == task_type_grav_mm ||
t->type == task_type_grav_down || t->type == task_type_cooling ||
t->type == task_type_star_formation ||
t->type == task_type_extra_ghost || t->subtype == task_subtype_gradient ||
t->subtype == task_subtype_stars_feedback)
t->type == task_type_extra_ghost ||
t->subtype == task_subtype_gradient ||
t->subtype == task_subtype_stars_feedback)
t->skip = 1;
}
......
......@@ -496,18 +496,15 @@ void engine_addtasks_recv_stars(struct engine *e, struct cell *c,
}
struct task *recv_rho = NULL;
if (c->mpi.hydro.recv_rho != NULL)
recv_rho = c->mpi.hydro.recv_rho;
if (c->mpi.hydro.recv_rho != NULL) recv_rho = c->mpi.hydro.recv_rho;
for (struct link *l = c->stars.feedback; l != NULL; l = l->next) {
scheduler_addunlock(s, t_feed, l->t);
/* Need gas density before feedback */
if (recv_rho != NULL)
scheduler_addunlock(s, c->mpi.hydro.recv_rho, l->t);
if (recv_rho != NULL) scheduler_addunlock(s, c->mpi.hydro.recv_rho, l->t);
}
/* Recurse? */
if (c->split)
for (int k = 0; k < 8; k++)
......@@ -979,7 +976,7 @@ void engine_make_hierarchical_tasks_stars(struct engine *e, struct cell *c) {
/* Need to compute the gas density before moving to the feedback */
scheduler_addunlock(s, c->hydro.super->hydro.ghost_out,
c->hydro.super->stars.ghost_out);
c->hydro.super->stars.ghost_out);
}
} else { /* We are above the super-cell so need to go deeper */
......@@ -2050,12 +2047,12 @@ void engine_make_extra_starsloop_tasks_mapper(void *map_data, int num_elements,
}
if (t->cj->nodeID == engine_rank) {
if (t->ci->hydro.super != t->cj->hydro.super) {
if (t->ci->hydro.super != t->cj->hydro.super) {
scheduler_addunlock(sched, t->cj->hydro.super->stars.sorts_local, t);
}
if (t->ci->super != t->cj->super) {
if (t->ci->super != t->cj->super) {
scheduler_addunlock(sched, t->cj->super->grav.drift, t);
}
}
}
/* Start by constructing the task for the second stars loop */
......@@ -2069,7 +2066,8 @@ void engine_make_extra_starsloop_tasks_mapper(void *map_data, int num_elements,
}
if (t->ci->hydro.super != t->cj->hydro.super) {
if (t->cj->nodeID != engine_rank) {
scheduler_addunlock(sched, t->cj->hydro.super->stars.sorts_foreign, t2);
scheduler_addunlock(sched, t->cj->hydro.super->stars.sorts_foreign,
t2);
}
}
......@@ -2085,7 +2083,7 @@ void engine_make_extra_starsloop_tasks_mapper(void *map_data, int num_elements,
if (t->cj->nodeID == nodeID) {
if (t->ci->hydro.super != t->cj->hydro.super) {
engine_make_stars_loops_dependencies(sched, t, t2, t->cj);
}
}
if (t->ci->super != t->cj->super) {
scheduler_addunlock(sched, t2, t->cj->super->end_force);
}
......@@ -2140,12 +2138,12 @@ void engine_make_extra_starsloop_tasks_mapper(void *map_data, int num_elements,
}
if (t->ci->nodeID == engine_rank) {
if (t->ci->super != t->cj->super) {
if (t->ci->super != t->cj->super) {
scheduler_addunlock(sched, t->ci->super->grav.drift, t);
}
if (t->ci->hydro.super != t->cj->hydro.super) {
}
if (t->ci->hydro.super != t->cj->hydro.super) {
scheduler_addunlock(sched, t->ci->hydro.super->stars.sorts_local, t);
}
}
}
/* Start by constructing the task for the second stars loop */
......@@ -2159,7 +2157,8 @@ void engine_make_extra_starsloop_tasks_mapper(void *map_data, int num_elements,
}
if (t->ci->hydro.super != t->cj->hydro.super) {
if (t->ci->nodeID != engine_rank) {
scheduler_addunlock(sched, t->ci->hydro.super->stars.sorts_foreign, t2);
scheduler_addunlock(sched, t->ci->hydro.super->stars.sorts_foreign,
t2);
}
}
......@@ -2248,8 +2247,7 @@ void engine_make_starsloop_tasks_mapper(void *map_data, int num_elements,
struct cell *cj = &cells[cjd];
/* Is that neighbour local and does it have particles ? */
if (cid >= cjd ||
(cj->stars.count == 0 && cj->hydro.count == 0) ||
if (cid >= cjd || (cj->stars.count == 0 && cj->hydro.count == 0) ||
(ci->nodeID != nodeID && cj->nodeID != nodeID))
continue;
......
......@@ -114,13 +114,12 @@ void engine_activate_stars_mpi(struct engine *e, struct scheduler *s,
scheduler_activate(s, cj->mpi.recv_ti);
struct link *l =
scheduler_activate_send(s, ci->mpi.hydro.send_xv, cj_nodeID);
scheduler_activate_send(s, ci->mpi.hydro.send_xv, cj_nodeID);
/* Drift the cell which will be sent at the level at which it is
sent, i.e. drift the cell specified in the send task (l->t)
itself. */
cell_activate_drift_part(l->t->ci, s);
}
}
}
......@@ -241,7 +240,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
t_subtype == task_subtype_stars_feedback) {
if (cell_is_active_stars(ci, e)) {
scheduler_activate(s, t);
cell_activate_subcell_stars_tasks(ci, NULL, s);
cell_activate_subcell_stars_tasks(ci, NULL, s);
}
}
......@@ -333,8 +332,8 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
/* Stars density and feedback */
if ((t_subtype == task_subtype_stars_density ||
t_subtype == task_subtype_stars_feedback) &&
(ci_active_stars || cj_active_stars)) {
t_subtype == task_subtype_stars_feedback) &&
(ci_active_stars || cj_active_stars)) {
scheduler_activate(s, t);
......
......@@ -965,11 +965,10 @@ void runner_do_stars_sort(struct runner *r, struct cell *c, int flags,
for (int k = 0; k < 8; k++) {
if (c->progeny[k] != NULL && c->progeny[k]->stars.count > 0) {
/* Only propagate cleanup if the progeny is stale. */
const int cleanup_prog = cleanup &&
(c->progeny[k]->stars.dx_max_sort_old >
space_maxreldx * c->progeny[k]->dmin);
runner_do_stars_sort(r, c->progeny[k], flags,
cleanup_prog, 0);
const int cleanup_prog =
cleanup && (c->progeny[k]->stars.dx_max_sort_old >
space_maxreldx * c->progeny[k]->dmin);
runner_do_stars_sort(r, c->progeny[k], flags, cleanup_prog, 0);
dx_max_sort = max(dx_max_sort, c->progeny[k]->stars.dx_max_sort);
dx_max_sort_old =
max(dx_max_sort_old, c->progeny[k]->stars.dx_max_sort_old);
......@@ -3122,8 +3121,9 @@ void *runner_main(void *data) {
case task_type_stars_sort_local:
case task_type_stars_sort_foreign:
/* Cleanup only if any of the indices went stale. */
runner_do_stars_sort(r, ci, t->flags,
ci->stars.dx_max_sort_old > space_maxreldx * ci->dmin, 1);
runner_do_stars_sort(
r, ci, t->flags,
ci->stars.dx_max_sort_old > space_maxreldx * ci->dmin, 1);
/* Reset the sort flags as our work here is done. */
t->flags = 0;
break;
......
......@@ -991,8 +991,8 @@ void DOSUB_SUBSET_STARS(struct runner *r, struct cell *ci, struct spart *sparts,
/* Do any of the cells need to be drifted first? */
if (cell_is_active_stars(ci, e)) {
if (!cell_are_spart_drifted(ci, e)) error("Cell should be drifted!");
if (!cell_are_part_drifted(cj, e)) error("Cell should be drifted!");
if (!cell_are_spart_drifted(ci, e)) error("Cell should be drifted!");
if (!cell_are_part_drifted(cj, e)) error("Cell should be drifted!");
}
DOPAIR1_SUBSET_BRANCH_STARS(r, ci, sparts, ind, scount, cj);
......@@ -1146,9 +1146,9 @@ void DOSUB_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj,
/* Should we even bother? */
const int should_do_ci = ci->stars.count != 0 && cj->hydro.count != 0 &&
cell_is_active_stars(ci, e);
cell_is_active_stars(ci, e);
const int should_do_cj = cj->stars.count != 0 && ci->hydro.count != 0 &&
cell_is_active_stars(cj, e);
cell_is_active_stars(cj, e);
if (!should_do_ci && !should_do_cj) return;
/* Get the type of pair if not specified explicitly. */
......
......@@ -1032,13 +1032,13 @@ static void scheduler_splittask_stars(struct task *t, struct scheduler *s) {
/* Empty task? */
/* Need defines in order to evaluate after check for t->ci == NULL */
const int self = (t->ci != NULL) && t->type == task_type_self &&
t->ci->stars.count != 0 && t->ci->hydro.count != 0;
t->ci->stars.count != 0 && t->ci->hydro.count != 0;
const int pair = (t->ci != NULL) && (t->cj != NULL) &&
t->type == task_type_pair &&
((t->ci->stars.count != 0 && t->cj->hydro.count != 0) ||
(t->cj->stars.count != 0 && t->ci->hydro.count != 0));
t->type == task_type_pair &&
((t->ci->stars.count != 0 && t->cj->hydro.count != 0) ||
(t->cj->stars.count != 0 && t->ci->hydro.count != 0));
if (!self && !pair) {
t->type = task_type_none;
t->subtype = task_subtype_none;
......@@ -1080,7 +1080,7 @@ static void scheduler_splittask_stars(struct task *t, struct scheduler *s) {
t->ci = ci->progeny[first_child];
for (int k = first_child + 1; k < 8; k++)
if (ci->progeny[k] != NULL && ci->progeny[k]->stars.count != 0 &&
ci->progeny[k]->hydro.count != 0)
ci->progeny[k]->hydro.count != 0)
scheduler_splittask_stars(
scheduler_addtask(s, task_type_self, t->subtype, 0, 0,
ci->progeny[k], NULL),
......@@ -1091,8 +1091,10 @@ static void scheduler_splittask_stars(struct task *t, struct scheduler *s) {
if (ci->progeny[j] != NULL)
for (int k = j + 1; k < 8; k++)
if (ci->progeny[k] != NULL &&
((ci->progeny[k]->stars.count != 0 && ci->progeny[j]->hydro.count != 0) ||
(ci->progeny[j]->stars.count != 0 && ci->progeny[k]->hydro.count != 0)))
((ci->progeny[k]->stars.count != 0 &&
ci->progeny[j]->hydro.count != 0) ||
(ci->progeny[j]->stars.count != 0 &&
ci->progeny[k]->hydro.count != 0)))
scheduler_splittask_stars(
scheduler_addtask(s, task_type_pair, t->subtype,
sub_sid_flag[j][k], 0, ci->progeny[j],
......@@ -1132,14 +1134,14 @@ static void scheduler_splittask_stars(struct task *t, struct scheduler *s) {
cell_can_split_pair_stars_task(cj, ci)) {
/* Replace by a single sub-task? */
if (scheduler_dosub && /* Use division to avoid integer overflow. */
ci->hydro.count * sid_scale[sid] <
space_subsize_pair_hydro / cj->hydro.count &&
!sort_is_corner(sid)) {
if (scheduler_dosub && /* Use division to avoid integer overflow. */
ci->hydro.count * sid_scale[sid] <
space_subsize_pair_hydro / cj->hydro.count &&
!sort_is_corner(sid)) {
/* Make this task a sub task. */
/* Make this task a sub task. */
t->type = task_type_sub_pair;
/* Otherwise, split it. */
} else {
/* Take a step back (we're going to recycle the current task)... */
......
......@@ -72,7 +72,7 @@ __attribute__((always_inline)) INLINE static void stars_init_spart(
* @param dt_drift The drift time-step for positions.
*/
__attribute__((always_inline)) INLINE static void stars_predict_extra(
struct spart *restrict sp, float dt_drift) {
struct spart* restrict sp, float dt_drift) {
const float h_inv = 1.f / sp->h;
......@@ -82,7 +82,6 @@ __attribute__((always_inline)) INLINE static void stars_predict_extra(
sp->h *= approx_expf(w1); /* 4th order expansion of exp(w) */
else
sp->h *= expf(w1);
}
/**
......@@ -180,7 +179,7 @@ __attribute__((always_inline)) INLINE static void stars_reset_acceleration(
/* Reset time derivative */
p->feedback.h_dt = 0.f;
#ifdef DEBUG_INTERACTIONS_STARS
for (int i = 0; i < MAX_NUM_OF_NEIGHBOURS_STARS; ++i)
p->ids_ngbs_force[i] = -1;
......
......@@ -72,8 +72,7 @@ runner_iact_nonsym_stars_feedback(float r2, const float *dx, float hi, float hj,
float wi_dr = hid_inv * wi_dx;
/* Compute dv dot r */
float dvdr = (si->v[0] - pj->v[0]) * dx[0] +
(si->v[1] - pj->v[1]) * dx[1] +
float dvdr = (si->v[0] - pj->v[0]) * dx[0] + (si->v[1] - pj->v[1]) * dx[1] +
(si->v[2] - pj->v[2]) * dx[2];
/* Get the time derivative for h. */
......
......@@ -305,8 +305,7 @@ float task_overlap(const struct task *restrict ta,
if (tb->ci != NULL) size_union += tb->ci->stars.count;
if (tb->cj != NULL) size_union += tb->cj->stars.count;
if (size_union == 0)
return 0.f;
if (size_union == 0) return 0.f;
/* Compute the intersection of the cell data. */
const size_t size_intersect = task_cell_overlap_spart(ta->ci, tb->ci) +
......
......@@ -202,10 +202,10 @@ __attribute__((always_inline)) INLINE static integertime_t get_spart_timestep(
sp->gpart, a_hydro, e->gravity_properties, e->cosmology);
/* Limit change in smoothing length */
const float dt_h_change =
(sp->feedback.h_dt != 0.0f)
? fabsf(e->stars_properties->log_max_h_change * sp->h / sp->feedback.h_dt)
: FLT_MAX;
const float dt_h_change = (sp->feedback.h_dt != 0.0f)
? fabsf(e->stars_properties->log_max_h_change *
sp->h / sp->feedback.h_dt)
: FLT_MAX;
/* Take the minimum of all */
float new_dt = min3(new_dt_stars, new_dt_self, new_dt_ext);
......
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