Commit 9d330d2e authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added new task sub-type for communication of spart only (without gpart).

parent 16336b88
......@@ -1436,7 +1436,7 @@ void runner_do_recv_gpart(struct runner *r, struct cell *c, int timer) {
else {
for (int k = 0; k < 8; k++) {
if (c->progeny[k] != NULL) {
runner_do_recv_cell(r, c->progeny[k], 0);
runner_do_recv_gpart(r, c->progeny[k], 0);
ti_end_min = min(ti_end_min, c->progeny[k]->ti_end_min);
ti_end_max = max(ti_end_max, c->progeny[k]->ti_end_max);
}
......@@ -1463,6 +1463,69 @@ void runner_do_recv_gpart(struct runner *r, struct cell *c, int timer) {
#endif
}
/**
* @brief Construct the cell properties from the received #spart.
*
* @param r The runner thread.
* @param c The cell.
* @param timer Are we timing this ?
*/
void runner_do_recv_spart(struct runner *r, struct cell *c, int timer) {
#ifdef WITH_MPI
const struct spart *restrict sparts = c->sparts;
const size_t nr_sparts = c->scount;
const integertime_t ti_current = r->e->ti_current;
TIMER_TIC;
integertime_t ti_end_min = max_nr_timesteps;
integertime_t ti_end_max = 0;
/* If this cell is a leaf, collect the particle data. */
if (!c->split) {
/* Collect everything... */
for (size_t k = 0; k < nr_sparts; k++) {
const integertime_t ti_end =
get_integer_time_end(ti_current, sparts[k].time_bin);
ti_end_min = min(ti_end_min, ti_end);
ti_end_max = max(ti_end_max, ti_end);
}
}
/* Otherwise, recurse and collect. */
else {
for (int k = 0; k < 8; k++) {
if (c->progeny[k] != NULL) {
runner_do_recv_spart(r, c->progeny[k], 0);
ti_end_min = min(ti_end_min, c->progeny[k]->ti_end_min);
ti_end_max = max(ti_end_max, c->progeny[k]->ti_end_max);
}
}
}
#ifdef SWIFT_DEBUG_CHECKS
if (ti_end_min < ti_current)
error(
"Received a cell at an incorrect time c->ti_end_min=%lld, "
"e->ti_current=%lld.",
ti_end_min, ti_current);
#endif
/* ... and store. */
c->ti_end_min = ti_end_min;
c->ti_end_max = ti_end_max;
c->ti_old = ti_current;
if (timer) TIMER_TOC(timer_dorecv_spart);
#else
error("SWIFT was not compiled with MPI support.");
#endif
}
/**
* @brief The #runner main thread routine.
*
......@@ -1661,6 +1724,10 @@ void *runner_main(void *data) {
runner_do_recv_part(r, ci, 1);
} else if (t->subtype == task_subtype_gpart) {
runner_do_recv_gpart(r, ci, 1);
} else if (t->subtype == task_subtype_spart) {
runner_do_recv_spart(r, ci, 1);
} else {
error("Unknown/invalid task subtype (%d).", t->subtype);
}
break;
#endif
......
......@@ -1208,6 +1208,9 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
} else if (t->subtype == task_subtype_gpart) {
err = MPI_Irecv(t->ci->gparts, t->ci->gcount, gpart_mpi_type,
t->ci->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
} else if (t->subtype == task_subtype_spart) {
err = MPI_Irecv(t->ci->sparts, t->ci->scount, spart_mpi_type,
t->ci->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
} else {
error("Unknown communication sub-type");
}
......@@ -1236,13 +1239,15 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
#endif
err = MPI_Isend(t->ci->parts, t->ci->count, part_mpi_type,
t->cj->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
// message( "sending %i parts with tag=%i from %i to %i." ,
// t->ci->count , t->flags , s->nodeID , t->cj->nodeID );
// fflush(stdout);
} else if (t->subtype == task_subtype_gpart) {
err = MPI_Isend(t->ci->gparts, t->ci->gcount, gpart_mpi_type,
t->cj->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
} else if (t->subtype == task_subtype_spart) {
err = MPI_Isend(t->ci->sparts, t->ci->scount, spart_mpi_type,
t->cj->nodeID, t->flags, MPI_COMM_WORLD, &t->req);
} else {
error("Unknown communication sub-type");
}
......
......@@ -55,8 +55,8 @@ const char *taskID_names[task_type_count] = {
"sourceterms"};
const char *subtaskID_names[task_subtype_count] = {
"none", "density", "gradient", "force", "grav",
"external_grav", "tend", "xv", "rho", "gpart"};
"none", "density", "gradient", "force", "grav", "external_grav",
"tend", "xv", "rho", "gpart", "spart"};
/**
* @brief Computes the overlap between the parts array of two given cells.
......
......@@ -74,6 +74,7 @@ enum task_subtypes {
task_subtype_xv,
task_subtype_rho,
task_subtype_gpart,
task_subtype_spart,
task_subtype_count
} __attribute__((packed));
......
......@@ -62,6 +62,7 @@ enum {
timer_do_extra_ghost,
timer_dorecv_part,
timer_dorecv_gpart,
timer_dorecv_spart,
timer_gettask,
timer_qget,
timer_qsteal,
......
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