Commit 100212e6 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Better semantic and type for runner_shift[]

parent 778c4cca
......@@ -57,46 +57,20 @@
#include "timestep.h"
/* Orientation of the cell pairs */
const float runner_shift[13 * 3] = {
5.773502691896258e-01,
5.773502691896258e-01,
5.773502691896258e-01,
7.071067811865475e-01,
7.071067811865475e-01,
0.0,
5.773502691896258e-01,
5.773502691896258e-01,
-5.773502691896258e-01,
7.071067811865475e-01,
0.0,
7.071067811865475e-01,
1.0,
0.0,
0.0,
7.071067811865475e-01,
0.0,
-7.071067811865475e-01,
5.773502691896258e-01,
-5.773502691896258e-01,
5.773502691896258e-01,
7.071067811865475e-01,
-7.071067811865475e-01,
0.0,
5.773502691896258e-01,
-5.773502691896258e-01,
-5.773502691896258e-01,
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,
const double runner_shift[13][3] = {
{5.773502691896258e-01, 5.773502691896258e-01, 5.773502691896258e-01},
{7.071067811865475e-01, 7.071067811865475e-01, 0.0},
{5.773502691896258e-01, 5.773502691896258e-01, -5.773502691896258e-01},
{7.071067811865475e-01, 0.0, 7.071067811865475e-01},
{1.0, 0.0, 0.0},
{7.071067811865475e-01, 0.0, -7.071067811865475e-01},
{5.773502691896258e-01, -5.773502691896258e-01, 5.773502691896258e-01},
{7.071067811865475e-01, -7.071067811865475e-01, 0.0},
{5.773502691896258e-01, -5.773502691896258e-01, -5.773502691896258e-01},
{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},
};
/* Does the axis need flipping ? */
......@@ -255,8 +229,8 @@ void runner_do_sort(struct runner *r, struct cell *c, int flags, int clock) {
struct entry *sort;
int j, k, count = c->count;
int i, ind, off[8], inds[8], temp_i, missing;
// float shift[3];
float buff[8], px[3];
float buff[8];
double px[3];
TIMER_TIC
......@@ -360,9 +334,9 @@ void runner_do_sort(struct runner *r, struct cell *c, int flags, int clock) {
for (j = 0; j < 13; j++)
if (flags & (1 << j)) {
sort[j * (count + 1) + k].i = k;
sort[j * (count + 1) + k].d = px[0] * runner_shift[3 * j + 0] +
px[1] * runner_shift[3 * j + 1] +
px[2] * runner_shift[3 * j + 2];
sort[j * (count + 1) + k].d = px[0] * runner_shift[j][0] +
px[1] * runner_shift[j][1] +
px[2] * runner_shift[j][2];
}
}
......@@ -505,9 +479,9 @@ void runner_do_gsort(struct runner *r, struct cell *c, int flags, int clock) {
for (j = 0; j < 13; j++)
if (flags & (1 << j)) {
gsort[j * (count + 1) + k].i = k;
gsort[j * (count + 1) + k].d = px[0] * runner_shift[3 * j + 0] +
px[1] * runner_shift[3 * j + 1] +
px[2] * runner_shift[3 * j + 2];
gsort[j * (count + 1) + k].d = px[0] * runner_shift[j][0] +
px[1] * runner_shift[j][1] +
px[2] * runner_shift[j][2];
}
}
......
......@@ -27,7 +27,7 @@
#include "cell.h"
#include "inline.h"
extern const float runner_shift[13 * 3];
extern const double runner_shift[13][3];
extern const char runner_flip[27];
/* A struct representing a runner's thread and its data. */
......
......@@ -376,9 +376,8 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci,
for (k = 0; k < 3; k++) pix[k] = pi->x[k] - shift[k];
hi = pi->h;
hig2 = hi * hi * kernel_gamma2;
di = hi * kernel_gamma + dxj + pix[0] * runner_shift[3 * sid + 0] +
pix[1] * runner_shift[3 * sid + 1] +
pix[2] * runner_shift[3 * sid + 2];
di = hi * kernel_gamma + dxj + pix[0] * runner_shift[sid][0] +
pix[1] * runner_shift[sid][1] + pix[2] * runner_shift[sid][2];
/* Loop over the parts in cj. */
for (pjd = 0; pjd < count_j && sort_j[pjd].d < di; pjd++) {
......@@ -439,9 +438,8 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci,
for (k = 0; k < 3; k++) pix[k] = pi->x[k] - shift[k];
hi = pi->h;
hig2 = hi * hi * kernel_gamma2;
di = -hi * kernel_gamma - dxj + pix[0] * runner_shift[3 * sid + 0] +
pix[1] * runner_shift[3 * sid + 1] +
pix[2] * runner_shift[3 * sid + 2];
di = -hi * kernel_gamma - dxj + pix[0] * runner_shift[sid][0] +
pix[1] * runner_shift[sid][1] + pix[2] * runner_shift[sid][2];
/* Loop over the parts in cj. */
for (pjd = count_j - 1; pjd >= 0 && di < sort_j[pjd].d; pjd--) {
......@@ -758,7 +756,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj) {
/* Get the cutoff shift. */
for (rshift = 0.0, k = 0; k < 3; k++)
rshift += shift[k] * runner_shift[3 * sid + k];
rshift += shift[k] * runner_shift[sid][k];
/* Pick-out the sorted lists. */
sort_i = &ci->sort[sid * (ci->count + 1)];
......@@ -952,7 +950,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) {
/* Get the cutoff shift. */
for (rshift = 0.0, k = 0; k < 3; k++)
rshift += shift[k] * runner_shift[3 * sid + k];
rshift += shift[k] * runner_shift[sid][k];
/* Pick-out the sorted lists. */
sort_i = &ci->sort[sid * (ci->count + 1)];
......
......@@ -69,7 +69,7 @@ void runner_dopair_grav_new(struct runner *r, struct cell *ci,
/* Get the cutoff shift. */
for (rshift = 0.0, k = 0; k < 3; k++)
rshift += shift[k] * runner_shift[3 * sid + k];
rshift += shift[k] * runner_shift[sid][k];
/* Pick-out the sorted lists. */
sort_i = &ci->gsort[sid * (ci->count + 1)];
......
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