Commit 60037b23 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

replace the cell's mpi.grav.recv and recv_ti task pointers with the new linked...

replace the cell's mpi.grav.recv and recv_ti task pointers with the new linked recv pointers. added some utility functions for looking up send/recv tasks of a given subtype in a cell.
parent ac61ca52
......@@ -207,9 +207,7 @@ int cell_link_foreign_parts(struct cell *c, struct part *parts) {
#endif
/* Do we have a hydro task at this level? */
struct link *l = c->mpi.recv;
while (l != NULL && l->t->subtype != task_subtype_xv) l = l->next;
if (l != NULL) {
if (cell_get_recv(c, task_subtype_xv) != NULL) {
/* Recursively attach the parts */
const int counts = cell_link_parts(c, parts);
......@@ -257,8 +255,8 @@ int cell_link_foreign_gparts(struct cell *c, struct gpart *gparts) {
error("Linking foreign particles in a local cell!");
#endif
/* Do we have a hydro task at this level? */
if (c->mpi.grav.recv != NULL) {
/* Do we have a gravity task at this level? */
if (cell_get_recv(c, task_subtype_gpart) != NULL) {
/* Recursively attach the gparts */
const int counts = cell_link_gparts(c, gparts);
......@@ -305,9 +303,7 @@ int cell_count_parts_for_tasks(const struct cell *c) {
#endif
/* Do we have a hydro task at this level? */
struct link *l = c->mpi.recv;
while (l != NULL && l->t->subtype != task_subtype_xv) l = l->next;
if (l != NULL) {
if (cell_get_recv(c, task_subtype_xv) != NULL) {
return c->hydro.count;
}
......@@ -345,8 +341,8 @@ int cell_count_gparts_for_tasks(const struct cell *c) {
error("Counting foreign particles in a local cell!");
#endif
/* Do we have a hydro task at this level? */
if (c->mpi.grav.recv != NULL) {
/* Do we have a gravity task at this level? */
if (cell_get_recv(c, task_subtype_gpart) != NULL) {
return c->grav.count;
}
......@@ -3453,10 +3449,12 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) {
if (ci_nodeID != nodeID) {
/* If the local cell is active, receive data from the foreign cell. */
if (cj_active) scheduler_activate(s, ci->mpi.grav.recv);
if (cj_active)
scheduler_activate_recv(s, ci->mpi.recv, task_subtype_gpart);
/* If the foreign cell is active, we want its ti_end values. */
if (ci_active) scheduler_activate(s, ci->mpi.grav.recv_ti);
if (ci_active)
scheduler_activate_recv(s, ci->mpi.recv, task_subtype_tend_gpart);
/* Is the foreign cell active and will need stuff from us? */
if (ci_active) {
......@@ -3478,10 +3476,12 @@ int cell_unskip_gravity_tasks(struct cell *c, struct scheduler *s) {
} else if (cj_nodeID != nodeID) {
/* If the local cell is active, receive data from the foreign cell. */
if (ci_active) scheduler_activate(s, cj->mpi.grav.recv);
if (ci_active)
scheduler_activate_recv(s, cj->mpi.recv, task_subtype_gpart);
/* If the foreign cell is active, we want its ti_end values. */
if (cj_active) scheduler_activate(s, cj->mpi.grav.recv_ti);
if (cj_active)
scheduler_activate_recv(s, cj->mpi.recv, task_subtype_tend_gpart);
/* Is the foreign cell active and will need stuff from us? */
if (cj_active) {
......@@ -3903,7 +3903,7 @@ int cell_has_tasks(struct cell *c) {
#ifdef WITH_MPI
if (c->timestep != NULL || c->mpi.recv != NULL ||
c->mpi.grav.recv_ti != NULL || c->mpi.stars.recv_ti != NULL)
c->mpi.stars.recv_ti != NULL)
return 1;
#else
if (c->timestep != NULL) return 1;
......
......@@ -580,14 +580,6 @@ struct cell {
struct link *recv;
};
struct {
/* Task receiving gpart data. */
struct task *recv;
/* Task receiving data (time-step). */
struct task *recv_ti;
} grav;
struct {
/* Task receiving spart data. */
struct task *recv;
......@@ -1111,4 +1103,23 @@ __attribute__((always_inline)) INLINE static void cell_free_stars_sorts(
}
}
/**
* @brief Check if a cell has a send/recv task of the given subtype.
*/
#ifdef WITH_MPI
__attribute__((always_inline)) INLINE static struct task *cell_get_send(
const struct cell *c, enum task_subtypes subtype) {
struct link *l = c->mpi.send;
while (l != NULL && l->t->subtype != subtype) l = l->next;
return (l != NULL) ? l->t : NULL;
}
__attribute__((always_inline)) INLINE static struct task *cell_get_recv(
const struct cell *c, enum task_subtypes subtype) {
struct link *l = c->mpi.recv;
while (l != NULL && l->t->subtype != subtype) l = l->next;
return (l != NULL) ? l->t : NULL;
}
#endif // WITH_MPI
#endif /* SWIFT_CELL_H */
......@@ -2394,9 +2394,7 @@ void engine_collect_end_of_step_recurse_hydro(struct cell *c,
/* Skip super-cells (Their values are already set) */
if (c->timestep != NULL) return;
#ifdef WITH_MPI
struct link *l = c->mpi.recv;
while (l != NULL && l->t->subtype != task_subtype_tend_part) l = l->next;
if (l != NULL) return;
if (cell_get_recv(c, task_subtype_tend_part) != NULL) return;
#else
#endif /* WITH_MPI */
......@@ -2453,11 +2451,10 @@ void engine_collect_end_of_step_recurse_hydro(struct cell *c,
void engine_collect_end_of_step_recurse_grav(struct cell *c,
const struct engine *e) {
/* Skip super-cells (Their values are already set) */
#ifdef WITH_MPI
if (c->timestep != NULL || c->mpi.grav.recv_ti != NULL) return;
#else
/* Skip super-cells (Their values are already set) */
if (c->timestep != NULL) return;
#ifdef WITH_MPI
if (cell_get_recv(c, task_subtype_tend_gpart) != NULL) return;
#endif /* WITH_MPI */
#ifdef SWIFT_DEBUG_CHECKS
......
......@@ -335,7 +335,6 @@ void engine_addtasks_recv_hydro(struct engine *e, struct cell *c,
engine_addlink(e, &c->mpi.recv, t_gradient);
#endif
engine_addlink(e, &c->mpi.recv, t_ti);
}
/* Add dependencies. */
if (c->hydro.sorts != NULL) {
......@@ -363,10 +362,12 @@ void engine_addtasks_recv_hydro(struct engine *e, struct cell *c,
}
#endif
/* Make sure the density has been computed before the stars compute theirs. */
/* Make sure the density has been computed before the stars compute theirs.
*/
for (struct link *l = c->stars.density; l != NULL; l = l->next) {
scheduler_addunlock(s, t_rho, l->t);
}
}
/* Recurse? */
if (c->split)
......@@ -469,14 +470,16 @@ void engine_addtasks_recv_gravity(struct engine *e, struct cell *c,
c->mpi.tag, 0, c, NULL);
}
c->mpi.grav.recv = t_grav;
c->mpi.grav.recv_ti = t_ti;
/* If we have tasks, link them. */
if (t_grav != NULL) {
engine_addlink(e, &c->mpi.recv, t_grav);
engine_addlink(e, &c->mpi.recv, t_ti);
for (struct link *l = c->grav.grav; l != NULL; l = l->next) {
scheduler_addunlock(s, t_grav, l->t);
scheduler_addunlock(s, l->t, t_ti);
}
}
/* Recurse? */
if (c->split)
for (int k = 0; k < 8; k++)
......
......@@ -539,10 +539,12 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
if (ci_nodeID != nodeID) {
/* If the local cell is active, receive data from the foreign cell. */
if (cj_active_gravity) scheduler_activate(s, ci->mpi.grav.recv);
if (cj_active_gravity)
scheduler_activate_recv(s, ci->mpi.recv, task_subtype_gpart);
/* If the foreign cell is active, we want its ti_end values. */
if (ci_active_gravity) scheduler_activate(s, ci->mpi.grav.recv_ti);
if (ci_active_gravity)
scheduler_activate_recv(s, ci->mpi.recv, task_subtype_tend_gpart);
/* Is the foreign cell active and will need stuff from us? */
if (ci_active_gravity) {
......@@ -564,10 +566,12 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
} else if (cj_nodeID != nodeID) {
/* If the local cell is active, receive data from the foreign cell. */
if (ci_active_gravity) scheduler_activate(s, cj->mpi.grav.recv);
if (ci_active_gravity)
scheduler_activate_recv(s, cj->mpi.recv, task_subtype_gpart);
/* If the foreign cell is active, we want its ti_end values. */
if (cj_active_gravity) scheduler_activate(s, cj->mpi.grav.recv_ti);
if (cj_active_gravity)
scheduler_activate_recv(s, cj->mpi.recv, task_subtype_tend_gpart);
/* Is the foreign cell active and will need stuff from us? */
if (cj_active_gravity) {
......
......@@ -269,8 +269,6 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements,
c->mpi.tag = -1;
c->mpi.recv = NULL;
c->mpi.grav.recv = NULL;
c->mpi.grav.recv_ti = NULL;
c->mpi.stars.recv = NULL;
c->mpi.stars.recv_ti = NULL;
c->mpi.limiter.recv = NULL;
......
......@@ -27,8 +27,12 @@
/* Includes. */
#include "align.h"
#include "cell.h"
#include "cycle.h"
#include "timeline.h"
/* Forward declarations to avoid circular inclusion dependencies. */
struct cell;
struct engine;
#define task_align 128
......
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