Commit 2f013910 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Ported all of the runner

parent 0aaf0ce8
......@@ -850,8 +850,8 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
int k, count = 0, nr_parts = c->count, updated;
float new_dt = 0.0f, new_dt_hydro = 0.0f, new_dt_grav = 0.0f,
current_dt = 0.0f;
float t_start, t_end, t_current = r->e->time, dt, t_end_min = FLT_MAX,
t_end_max = 0.;
float t_start, t_end, t_current = r->e->time, t_end_min = FLT_MAX,
t_end_max = 0., dt;
float dt_max_timeline = r->e->timeEnd - r->e->timeBegin, dt_timeline;
float dt_min = r->e->dt_min, dt_max = r->e->dt_max;
float h_max, dx_max;
......@@ -880,7 +880,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
x[0] = p->x[0], x[1] = p->x[1], x[2] = p->x[2];
if (p->id == 0)
message("Kick ! dt=%f t_beg=%f t_end=%f t_cur=%f", dt, p->t_begin,
message("Kick ! t_beg=%f t_end=%f t_cur=%f", p->t_begin,
p->t_end, t_current);
/* If particle needs to be kicked */
......
......@@ -110,7 +110,7 @@ void DOPAIR_NAIVE(struct runner *r, struct cell *restrict ci,
struct part *restrict pi, *restrict pj;
double pix[3];
float dx[3], hi, hig2, r2;
float dt_step = e->dt_step;
float t_current = e->time;
#ifdef VECTORIZE
int icount = 0;
float r2q[VEC_SIZE] __attribute__((aligned(16)));
......@@ -122,7 +122,7 @@ void DOPAIR_NAIVE(struct runner *r, struct cell *restrict ci,
TIMER_TIC
/* Anything to do here? */
if (ci->dt_min > dt_step && cj->dt_min > dt_step) return;
if (ci->t_end_min > t_current && cj->t_end_min > t_current) return;
/* Get the relative distance between the pairs, wrapping. */
for (k = 0; k < 3; k++) {
......@@ -219,7 +219,7 @@ void DOSELF_NAIVE(struct runner *r, struct cell *restrict c) {
struct part *restrict pi, *restrict pj;
double pix[3] = {0.0, 0.0, 0.0};
float dx[3], hi, hig2, r2;
float dt_step = r->e->dt_step;
float t_current = r->e->time;
#ifdef VECTORIZE
int icount = 0;
float r2q[VEC_SIZE] __attribute__((aligned(16)));
......@@ -231,7 +231,7 @@ void DOSELF_NAIVE(struct runner *r, struct cell *restrict c) {
TIMER_TIC
/* Anything to do here? */
if (c->dt_min > dt_step) return;
if (c->t_end_min > t_current) return;
/* printf( "runner_dopair_naive: doing pair [ %g %g %g ]/[ %g %g %g ] with
%i/%i parts and shift = [ %g %g %g ].\n" ,
......@@ -769,7 +769,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj) {
double hi_max, hj_max;
double di_max, dj_min;
int count_i, count_j;
float dt_step = e->dt_step;
float t_current = e->time;
#ifdef VECTORIZE
int icount = 0;
float r2q[VEC_SIZE] __attribute__((aligned(16)));
......@@ -781,7 +781,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj) {
TIMER_TIC
/* Anything to do here? */
if (ci->dt_min > dt_step && cj->dt_min > dt_step) return;
if (ci->t_end_min > t_current && cj->t_end_min > t_current) return;
/* Get the sort ID. */
sid = space_getsid(e->s, &ci, &cj, shift);
......@@ -815,7 +815,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj) {
/* Get a hold of the ith part in ci. */
pi = &parts_i[sort_i[pid].i];
if (pi->dt > dt_step) continue;
if (pi->t_end > t_current) continue;
hi = pi->h;
di = sort_i[pid].d + hi * kernel_gamma + dx_max - rshift;
if (di < dj_min) continue;
......@@ -879,7 +879,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj) {
/* Get a hold of the jth part in cj. */
pj = &parts_j[sort_j[pjd].i];
if (pj->dt > dt_step) continue;
if (pj->t_end > t_current) continue;
hj = pj->h;
dj = sort_j[pjd].d - hj * kernel_gamma - dx_max - rshift;
if (dj > di_max) continue;
......@@ -966,7 +966,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
double hi_max, hj_max;
double di_max, dj_min;
int count_i, count_j;
float dt_step = e->dt_step;
float t_current = e->time;
#ifdef VECTORIZE
int icount1 = 0;
float r2q1[VEC_SIZE] __attribute__((aligned(16)));
......@@ -984,7 +984,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
TIMER_TIC
/* Anything to do here? */
if (ci->dt_min > dt_step && cj->dt_min > dt_step) return;
if (ci->t_end_min > t_current && cj->t_end_min > t_current) return;
/* Get the shift ID. */
sid = space_getsid(e->s, &ci, &cj, shift);
......@@ -1013,28 +1013,28 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
dx_max = (ci->dx_max + cj->dx_max);
/* Collect the number of parts left and right below dt. */
if (ci->dt_max <= dt_step) {
if (ci->t_end_max <= t_current) {
sortdt_i = sort_i;
countdt_i = count_i;
} else if (ci->dt_min <= dt_step) {
} else if (ci->t_end_min <= t_current) {
if ((sortdt_i = (struct entry *)alloca(sizeof(struct entry) * count_i)) ==
NULL)
error("Failed to allocate dt sortlists.");
for (k = 0; k < count_i; k++)
if (parts_i[sort_i[k].i].dt <= dt_step) {
if (parts_i[sort_i[k].i].t_end <= t_current) {
sortdt_i[countdt_i] = sort_i[k];
countdt_i += 1;
}
}
if (cj->dt_max <= dt_step) {
if (cj->t_end_max <= t_current) {
sortdt_j = sort_j;
countdt_j = count_j;
} else if (cj->dt_min <= dt_step) {
} else if (cj->t_end_min <= t_current) {
if ((sortdt_j = (struct entry *)alloca(sizeof(struct entry) * count_j)) ==
NULL)
error("Failed to allocate dt sortlists.");
for (k = 0; k < count_j; k++)
if (parts_j[sort_j[k].i].dt <= dt_step) {
if (parts_j[sort_j[k].i].t_end <= t_current) {
sortdt_j[countdt_j] = sort_j[k];
countdt_j += 1;
}
......@@ -1054,7 +1054,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
for (k = 0; k < 3; k++) pix[k] = pi->x[k] - shift[k];
/* Look at valid dt parts only? */
if (pi->dt > dt_step) {
if (pi->t_end > t_current) {
/* Loop over the parts in cj within dt. */
for (pjd = 0; pjd < countdt_j && sortdt_j[pjd].d < di; pjd++) {
......@@ -1126,7 +1126,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
#ifndef VECTORIZE
/* Does pj need to be updated too? */
if (pj->dt <= dt_step)
if (pj->t_end <= t_current)
IACT(r2, dx, hi, hj, pi, pj);
else
IACT_NONSYM(r2, dx, hi, hj, pi, pj);
......@@ -1134,7 +1134,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
#else
/* Does pj need to be updated too? */
if (pj->dt <= dt_step) {
if (pj->t_end <= t_current) {
/* Add this interaction to the symmetric queue. */
r2q2[icount2] = r2;
......@@ -1199,7 +1199,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
hjg2 = hj * hj * kernel_gamma2;
/* Is this particle outside the dt? */
if (pj->dt > dt_step) {
if (pj->t_end > t_current) {
/* Loop over the parts in ci. */
for (pid = countdt_i - 1; pid >= 0 && sortdt_i[pid].d > dj; pid--) {
......@@ -1270,7 +1270,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
#ifndef VECTORIZE
/* Does pi need to be updated too? */
if (pi->dt <= dt_step)
if (pi->t_end <= t_current)
IACT(r2, dx, hj, hi, pj, pi);
else
IACT_NONSYM(r2, dx, hj, hi, pj, pi);
......@@ -1360,7 +1360,7 @@ void DOSELF1(struct runner *r, struct cell *restrict c) {
double pix[3];
float dx[3], hi, hj, hig2, r2;
struct part *restrict parts = c->parts, *restrict pi, *restrict pj;
float dt_step = r->e->dt_step;
float t_current = r->e->time;
int firstdt = 0, countdt = 0, *indt = NULL, doj;
#ifdef VECTORIZE
int icount1 = 0;
......@@ -1379,13 +1379,13 @@ void DOSELF1(struct runner *r, struct cell *restrict c) {
TIMER_TIC
/* Set up indt if needed. */
if (c->dt_min > dt_step)
if (c->t_end_min > t_current)
return;
else if (c->dt_max > dt_step) {
else if (c->t_end_max > t_current) {
if ((indt = (int *)alloca(sizeof(int) * count)) == NULL)
error("Failed to allocate indt.");
for (k = 0; k < count; k++)
if (parts[k].dt <= dt_step) {
if (parts[k].t_end <= t_current) {
indt[countdt] = k;
countdt += 1;
}
......@@ -1403,7 +1403,7 @@ void DOSELF1(struct runner *r, struct cell *restrict c) {
hig2 = hi * hi * kernel_gamma2;
/* Is the ith particle inactive? */
if (pi->dt > dt_step) {
if (pi->t_end > t_current) {
/* Loop over the other particles .*/
for (pjd = firstdt; pjd < countdt; pjd++) {
......@@ -1471,7 +1471,7 @@ void DOSELF1(struct runner *r, struct cell *restrict c) {
dx[k] = pix[k] - pj->x[k];
r2 += dx[k] * dx[k];
}
doj = (pj->dt <= dt_step) && (r2 < hj * hj * kernel_gamma2);
doj = (pj->t_end <= t_current) && (r2 < hj * hj * kernel_gamma2);
/* Hit or miss? */
if (r2 < hig2 || doj) {
......@@ -1583,7 +1583,7 @@ void DOSELF2(struct runner *r, struct cell *restrict c) {
double pix[3];
float dx[3], hi, hj, hig2, r2;
struct part *restrict parts = c->parts, *restrict pi, *restrict pj;
float dt_step = r->e->dt_step;
float t_current = r->e->time;
int firstdt = 0, countdt = 0, *indt = NULL;
#ifdef VECTORIZE
int icount1 = 0;
......@@ -1602,13 +1602,13 @@ void DOSELF2(struct runner *r, struct cell *restrict c) {
TIMER_TIC
/* Set up indt if needed. */
if (c->dt_min > dt_step)
if (c->t_end_min > t_current)
return;
else if (c->dt_max > dt_step) {
else if (c->t_end_max > t_current) {
if ((indt = (int *)alloca(sizeof(int) * count)) == NULL)
error("Failed to allocate indt.");
for (k = 0; k < count; k++)
if (parts[k].dt <= dt_step) {
if (parts[k].t_end <= t_current) {
indt[countdt] = k;
countdt += 1;
}
......@@ -1626,7 +1626,7 @@ void DOSELF2(struct runner *r, struct cell *restrict c) {
hig2 = hi * hi * kernel_gamma2;
/* Is the ith particle not active? */
if (pi->dt > dt_step) {
if (pi->t_end > t_current) {
/* Loop over the other particles .*/
for (pjd = firstdt; pjd < countdt; pjd++) {
......@@ -1701,7 +1701,7 @@ void DOSELF2(struct runner *r, struct cell *restrict c) {
#ifndef VECTORIZE
/* Does pj need to be updated too? */
if (pj->dt <= dt_step)
if (pj->t_end <= t_current)
IACT(r2, dx, hi, hj, pi, pj);
else
IACT_NONSYM(r2, dx, hi, hj, pi, pj);
......@@ -1709,7 +1709,7 @@ void DOSELF2(struct runner *r, struct cell *restrict c) {
#else
/* Does pj need to be updated too? */
if (pj->dt <= dt_step) {
if (pj->t_end <= t_current) {
/* Add this interaction to the symmetric queue. */
r2q2[icount2] = r2;
......@@ -1794,7 +1794,7 @@ void DOSUB1(struct runner *r, struct cell *ci, struct cell *cj, int sid,
double shift[3];
float h;
struct space *s = r->e->s;
float dt_step = r->e->dt_step;
float t_current = r->e->time;
TIMER_TIC
......@@ -1802,7 +1802,7 @@ void DOSUB1(struct runner *r, struct cell *ci, struct cell *cj, int sid,
if (cj == NULL) {
/* Should we even bother? */
if (ci->dt_min > dt_step) return;
if (ci->t_end_min > t_current) return;
/* Recurse? */
if (ci->split) {
......@@ -1828,7 +1828,7 @@ void DOSUB1(struct runner *r, struct cell *ci, struct cell *cj, int sid,
else {
/* Should we even bother? */
if (ci->dt_min > dt_step && cj->dt_min > dt_step) return;
if (ci->t_end_min > t_current && cj->t_end_min > t_current) return;
/* Get the cell dimensions. */
h = fmin(ci->h[0], fmin(ci->h[1], ci->h[2]));
......@@ -2041,7 +2041,7 @@ void DOSUB1(struct runner *r, struct cell *ci, struct cell *cj, int sid,
}
/* Otherwise, compute the pair directly. */
else if (ci->dt_min <= dt_step || cj->dt_min <= dt_step) {
else if (ci->t_end_min <= t_current || cj->t_end_min <= t_current) {
/* Do any of the cells need to be sorted first? */
if (!(ci->sorted & (1 << sid))) runner_dosort(r, ci, (1 << sid), 1);
......@@ -2069,7 +2069,7 @@ void DOSUB2(struct runner *r, struct cell *ci, struct cell *cj, int sid,
double shift[3];
float h;
struct space *s = r->e->s;
float dt_step = r->e->dt_step;
float t_current = r->e->time;
TIMER_TIC
......@@ -2077,7 +2077,7 @@ void DOSUB2(struct runner *r, struct cell *ci, struct cell *cj, int sid,
if (cj == NULL) {
/* Should we even bother? */
if (ci->dt_min > dt_step) return;
if (ci->t_end_min > t_current) return;
/* Recurse? */
if (ci->split) {
......@@ -2103,7 +2103,7 @@ void DOSUB2(struct runner *r, struct cell *ci, struct cell *cj, int sid,
else {
/* Should we even bother? */
if (ci->dt_min > dt_step && cj->dt_min > dt_step) return;
if (ci->t_end_min > t_current && cj->t_end_min > t_current) return;
/* Get the cell dimensions. */
h = fmin(ci->h[0], fmin(ci->h[1], ci->h[2]));
......@@ -2316,7 +2316,7 @@ void DOSUB2(struct runner *r, struct cell *ci, struct cell *cj, int sid,
}
/* Otherwise, compute the pair directly. */
else if (ci->dt_min <= dt_step || cj->dt_min <= dt_step) {
else if (ci->t_end_min <= t_current || cj->t_end_min <= t_current) {
/* Do any of the cells need to be sorted first? */
if (!(ci->sorted & (1 << sid))) runner_dosort(r, ci, (1 << sid), 1);
......@@ -2345,7 +2345,7 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
float h;
struct space *s = r->e->s;
struct cell *sub = NULL;
float dt_step = r->e->dt_step;
float t_current = r->e->time;
TIMER_TIC
......@@ -2905,7 +2905,7 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
}
/* Otherwise, compute the pair directly. */
else if (ci->dt_min <= dt_step || cj->dt_min <= dt_step) {
else if (ci->t_end_min <= t_current || cj->t_end_min <= t_current) {
/* Get the relative distance between the pairs, wrapping. */
for (k = 0; k < 3; k++) {
......
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