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