Commit 2e6b26fd authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

purge the drift tasks.

parent 5f444a68
......@@ -119,7 +119,7 @@ struct cell {
int nr_density, nr_force, nr_grav;
/* The hierarchical tasks. */
struct task *ghost, *init, *drift, *kick;
struct task *ghost, *init, *kick;
/* Task receiving data. */
struct task *recv_xv, *recv_rho;
......
......@@ -66,11 +66,19 @@
#include "timers.h"
#include "units.h"
const char *engine_policy_names[13] = {
"none", "rand", "steal", "keep",
"block", "fix_dt", "cpu_tight", "mpi",
"numa_affinity", "hydro", "self_gravity", "external_gravity",
"cosmology_integration"};
const char *engine_policy_names[13] = {"none",
"rand",
"steal",
"keep",
"block",
"fix_dt",
"cpu_tight",
"mpi",
"numa_affinity",
"hydro",
"self_gravity",
"external_gravity",
"cosmology_integration"};
/** The rank of the engine as a global variable (for messages). */
int engine_rank;
......@@ -136,10 +144,6 @@ void engine_make_hierarchical_tasks(struct engine *e, struct cell *c,
c->init = scheduler_addtask(s, task_type_init, task_subtype_none, 0, 0, c,
NULL, 0);
/* Add the drift task. */
c->drift = scheduler_addtask(s, task_type_drift, task_subtype_none, 0, 0,
c, NULL, 0);
/* Add the kick task that matches the policy. */
if (is_fixdt) {
c->kick = scheduler_addtask(s, task_type_kick_fixdt, task_subtype_none,
......@@ -1821,10 +1825,6 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
t->ci->g_updated = 0;
}
/* Drift? */
else if (t->type == task_type_drift)
t->skip = 0;
/* Init? */
else if (t->type == task_type_init) {
/* Set this task's skip. */
......@@ -1902,10 +1902,6 @@ int engine_marktasks_serial(struct engine *e) {
t->ci->g_updated = 0;
}
/* Drift? */
else if (t->type == task_type_drift)
t->skip = 0;
/* Init? */
else if (t->type == task_type_init) {
/* Set this task's skip. */
......@@ -2205,9 +2201,6 @@ void engine_collect_timestep(struct engine *e) {
*/
void engine_collect_drift(struct cell *c) {
/* Skip super-cells (Their values are already set) */
if (c->drift != NULL) return;
/* Counters for the different quantities. */
double e_kin = 0.0, e_int = 0.0, e_pot = 0.0, mass = 0.0;
double mom[3] = {0.0, 0.0, 0.0}, ang_mom[3] = {0.0, 0.0, 0.0};
......@@ -2253,6 +2246,7 @@ void engine_collect_drift(struct cell *c) {
c->ang_mom[1] = ang_mom[1];
c->ang_mom[2] = ang_mom[2];
}
/**
* @brief Print the conserved quantities statistics to a log file
*
......@@ -2479,7 +2473,8 @@ void engine_step(struct engine *e) {
snapshot_drift_time = e->timeStep;
/* Drift everybody to the snapshot position */
engine_launch(e, e->nr_threads, 1 << task_type_drift, 0);
threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells,
e->s->nr_cells, sizeof(struct cell), 1, e);
/* Dump... */
engine_dump_snapshot(e);
......@@ -2497,7 +2492,6 @@ void engine_step(struct engine *e) {
e->timeStep = (e->ti_current - e->ti_old) * e->timeBase + snapshot_drift_time;
/* Drift everybody */
// engine_launch(e, e->nr_threads, 1 << task_type_drift, 0);
threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells,
e->s->nr_cells, sizeof(struct cell), 1, e);
......
......@@ -454,7 +454,6 @@ static void repart_edge_metis(int partweights, int bothweights, int nodeID,
/* Skip un-interesting tasks. */
if (t->type != task_type_self && t->type != task_type_pair &&
t->type != task_type_sub_self && t->type != task_type_sub_self &&
t->type != task_type_ghost && t->type != task_type_drift &&
t->type != task_type_kick && t->type != task_type_init)
continue;
......@@ -487,8 +486,7 @@ static void repart_edge_metis(int partweights, int bothweights, int nodeID,
int cid = ci - cells;
/* Different weights for different tasks. */
if (t->type == task_type_ghost || t->type == task_type_drift ||
t->type == task_type_kick) {
if (t->type == task_type_ghost || t->type == task_type_kick) {
/* Particle updates add only to vertex weight. */
if (taskvweights) weights_v[cid] += w;
......
......@@ -71,7 +71,8 @@ const double runner_shift[13][3] = {
{0.0, 7.071067811865475e-01, 7.071067811865475e-01},
{0.0, 1.0, 0.0},
{0.0, 7.071067811865475e-01, -7.071067811865475e-01},
{0.0, 0.0, 1.0}, };
{0.0, 0.0, 1.0},
};
/* Does the axis need flipping ? */
const char runner_flip[27] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
......@@ -575,149 +576,12 @@ void runner_do_ghost(struct runner *r, struct cell *c) {
}
/**
* @brief Drift particles and g-particles forward in time
* @brief Mapper function to drift particles and g-particles forward in time.
*
* @param r The runner thread.
* @param c The cell.
* @param timer Are we timing this ?
* @param map_data An array of #cells.
* @param num_elements Chunk size.
* @param extra_data Pointer to an #engine.
*/
void runner_do_drift(struct runner *r, struct cell *c, int timer) {
const double timeBase = r->e->timeBase;
const double dt = (r->e->ti_current - r->e->ti_old) * timeBase;
const int ti_old = r->e->ti_old;
const int ti_current = r->e->ti_current;
struct part *const parts = c->parts;
struct xpart *const xparts = c->xparts;
struct gpart *const gparts = c->gparts;
float dx_max = 0.f, dx2_max = 0.f, h_max = 0.f;
double e_kin = 0.0, e_int = 0.0, e_pot = 0.0, mass = 0.0;
double mom[3] = {0.0, 0.0, 0.0};
double ang_mom[3] = {0.0, 0.0, 0.0};
TIMER_TIC
#ifdef TASK_VERBOSE
OUT;
#endif
/* No children? */
if (!c->split) {
/* Loop over all the g-particles in the cell */
const int nr_gparts = c->gcount;
for (size_t k = 0; k < nr_gparts; k++) {
/* Get a handle on the gpart. */
struct gpart *const gp = &gparts[k];
/* Drift... */
drift_gpart(gp, dt, timeBase, ti_old, ti_current);
/* Compute (square of) motion since last cell construction */
const float dx2 = gp->x_diff[0] * gp->x_diff[0] +
gp->x_diff[1] * gp->x_diff[1] +
gp->x_diff[2] * gp->x_diff[2];
dx2_max = fmaxf(dx2_max, dx2);
}
/* Loop over all the particles in the cell (more work for these !) */
const size_t nr_parts = c->count;
for (size_t k = 0; k < nr_parts; k++) {
/* Get a handle on the part. */
struct part *const p = &parts[k];
struct xpart *const xp = &xparts[k];
/* Drift... */
drift_part(p, xp, dt, timeBase, ti_old, ti_current);
/* Compute (square of) motion since last cell construction */
const float dx2 = xp->x_diff[0] * xp->x_diff[0] +
xp->x_diff[1] * xp->x_diff[1] +
xp->x_diff[2] * xp->x_diff[2];
dx2_max = fmaxf(dx2_max, dx2);
/* Maximal smoothing length */
h_max = fmaxf(p->h, h_max);
/* Now collect quantities for statistics */
const float half_dt =
(ti_current - (p->ti_begin + p->ti_end) / 2) * timeBase;
const double x[3] = {p->x[0], p->x[1], p->x[2]};
const float v[3] = {xp->v_full[0] + p->a_hydro[0] * half_dt,
xp->v_full[1] + p->a_hydro[1] * half_dt,
xp->v_full[2] + p->a_hydro[2] * half_dt};
const float m = p->mass;
/* Collect mass */
mass += m;
/* Collect momentum */
mom[0] += m * v[0];
mom[1] += m * v[1];
mom[2] += m * v[2];
/* Collect angular momentum */
ang_mom[0] += m * (x[1] * v[2] - x[2] * v[1]);
ang_mom[1] += m * (x[2] * v[0] - x[0] * v[2]);
ang_mom[2] += m * (x[0] * v[1] - x[1] * v[0]);
/* Collect energies. */
e_kin += 0.5 * m * (v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
e_pot += 0.;
e_int += m * hydro_get_internal_energy(p, half_dt);
}
/* Now, get the maximal particle motion from its square */
dx_max = sqrtf(dx2_max);
}
/* Otherwise, aggregate data from children. */
else {
/* Loop over the progeny. */
for (int k = 0; k < 8; k++)
if (c->progeny[k] != NULL) {
/* Recurse */
struct cell *cp = c->progeny[k];
runner_do_drift(r, cp, 0);
/* Collect */
dx_max = fmaxf(dx_max, cp->dx_max);
h_max = fmaxf(h_max, cp->h_max);
mass += cp->mass;
e_kin += cp->e_kin;
e_int += cp->e_int;
e_pot += cp->e_pot;
mom[0] += cp->mom[0];
mom[1] += cp->mom[1];
mom[2] += cp->mom[2];
ang_mom[0] += cp->ang_mom[0];
ang_mom[1] += cp->ang_mom[1];
ang_mom[2] += cp->ang_mom[2];
}
}
/* Store the values */
c->h_max = h_max;
c->dx_max = dx_max;
c->mass = mass;
c->e_kin = e_kin;
c->e_int = e_int;
c->e_pot = e_pot;
c->mom[0] = mom[0];
c->mom[1] = mom[1];
c->mom[2] = mom[2];
c->ang_mom[0] = ang_mom[0];
c->ang_mom[1] = ang_mom[1];
c->ang_mom[2] = ang_mom[2];
if (timer) TIMER_TOC(timer_drift);
}
void runner_do_drift_mapper(void *map_data, int num_elements,
void *extra_data) {
......@@ -826,7 +690,7 @@ void runner_do_drift_mapper(void *map_data, int num_elements,
for (int k = 0; k < 8; k++)
if (c->progeny[k] != NULL) {
struct cell *cp = c->progeny[k];
/* Recurse. */
runner_do_drift_mapper(cp, 1, e);
......@@ -1229,9 +1093,6 @@ void *runner_main(void *data) {
case task_type_ghost:
runner_do_ghost(r, ci);
break;
case task_type_drift:
runner_do_drift(r, ci, 1);
break;
case task_type_kick:
runner_do_kick(r, ci, 1);
break;
......
......@@ -51,8 +51,8 @@ void runner_do_sort(struct runner *r, struct cell *c, int flag, int clock);
void runner_do_gsort(struct runner *r, struct cell *c, int flag, int clock);
void runner_do_kick(struct runner *r, struct cell *c, int timer);
void runner_do_kick_fixdt(struct runner *r, struct cell *c, int timer);
void runner_do_drift(struct runner *r, struct cell *c, int timer);
void runner_do_init(struct runner *r, struct cell *c, int timer);
void *runner_main(void *data);
void runner_do_drift_mapper(void *map_data, int num_elements, void *extra_data);
#endif /* SWIFT_RUNNER_H */
......@@ -136,7 +136,6 @@ void scheduler_splittasks_mapper(void *map_data, int num_elements,
/* Non-splittable task? */
if ((t->ci == NULL || (t->type == task_type_pair && t->cj == NULL)) ||
((t->type == task_type_kick) && t->ci->nodeID != s->nodeID) ||
((t->type == task_type_drift) && t->ci->nodeID != s->nodeID) ||
((t->type == task_type_init) && t->ci->nodeID != s->nodeID)) {
t->type = task_type_none;
t->skip = 1;
......@@ -954,9 +953,6 @@ void scheduler_reweight(struct scheduler *s) {
case task_type_kick:
t->weight += wscale * t->ci->count;
break;
case task_type_drift:
t->weight += wscale * t->ci->count;
break;
case task_type_init:
t->weight += wscale * t->ci->count;
break;
......@@ -1052,8 +1048,8 @@ void scheduler_start(struct scheduler *s, unsigned int mask,
sizeof(struct task), 1000, s);
/* Loop over the tasks and enqueue whoever is ready. */
threadpool_map(s->threadpool, scheduler_enqueue_mapper, s->tasks_ind, s->nr_tasks,
sizeof(int), 1000, s);
threadpool_map(s->threadpool, scheduler_enqueue_mapper, s->tasks_ind,
s->nr_tasks, sizeof(int), 1000, s);
/* To be safe, fire of one last sleep_cond in a safe way. */
pthread_mutex_lock(&s->sleep_mutex);
......@@ -1107,7 +1103,6 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) {
case task_type_sort:
case task_type_ghost:
case task_type_kick:
case task_type_drift:
case task_type_init:
qid = t->ci->super->owner;
break;
......
......@@ -349,7 +349,6 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
s->cells[k].gcount = 0;
s->cells[k].init = NULL;
s->cells[k].ghost = NULL;
s->cells[k].drift = NULL;
s->cells[k].kick = NULL;
s->cells[k].super = &s->cells[k];
}
......
......@@ -47,8 +47,8 @@
/* Task type names. */
const char *taskID_names[task_type_count] = {
"none", "sort", "self", "pair", "sub",
"init", "ghost", "drift", "kick", "kick_fixdt",
"none", "sort", "self", "pair", "sub_self",
"sub_pair", "init", "ghost", "kick", "kick_fixdt",
"send", "recv", "grav_pp", "grav_mm", "grav_up",
"grav_down", "grav_external", "comm_root"};
......
......@@ -41,7 +41,6 @@ enum task_types {
task_type_sub_pair,
task_type_init,
task_type_ghost,
task_type_drift,
task_type_kick,
task_type_kick_fixdt,
task_type_send,
......
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