Skip to content
Snippets Groups Projects
Commit 99968ea5 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Updated tests to pass with the new definition of the vectorization macros

parent 5f8b5e71
No related branches found
No related tags found
1 merge request!200Macro vectorisation
...@@ -648,8 +648,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force( ...@@ -648,8 +648,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force(
pi[k]->force.v_sig = vi_sig.f[k]; pi[k]->force.v_sig = vi_sig.f[k];
pj[k]->force.v_sig = vj_sig.f[k]; pj[k]->force.v_sig = vj_sig.f[k];
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
pi[k]->a[j] -= pia[j].f[k]; pi[k]->a_hydro[j] -= pia[j].f[k];
pj[k]->a[j] += pja[j].f[k]; pj[k]->a_hydro[j] += pja[j].f[k];
} }
} }
...@@ -945,7 +945,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_vec_force( ...@@ -945,7 +945,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_vec_force(
pi[k]->h_dt -= pih_dt.f[k]; pi[k]->h_dt -= pih_dt.f[k];
pi[k]->force.v_sig = vi_sig.f[k]; pi[k]->force.v_sig = vi_sig.f[k];
pj[k]->force.v_sig = vj_sig.f[k]; pj[k]->force.v_sig = vj_sig.f[k];
for (j = 0; j < 3; j++) pi[k]->a[j] -= pia[j].f[k]; for (j = 0; j < 3; j++) pi[k]->a_hydro[j] -= pia[j].f[k];
} }
#else #else
......
...@@ -22,7 +22,7 @@ AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS) ...@@ -22,7 +22,7 @@ AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
# List of programs and scripts to run in the test suite # List of programs and scripts to run in the test suite
TESTS = testGreetings testReading.sh testSingle testPair.sh testPairPerturbed.sh \ TESTS = testGreetings testReading.sh testSingle testPair.sh testPairPerturbed.sh \
test27cells.sh test27cellsPerturbed.sh testParser.sh testKernel test27cells.sh test27cellsPerturbed.sh testParser.sh testKernel testSPHStep
# List of test programs to compile # List of test programs to compile
check_PROGRAMS = testGreetings testReading testSingle testTimeIntegration \ check_PROGRAMS = testGreetings testReading testSingle testTimeIntegration \
......
...@@ -126,7 +126,6 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, ...@@ -126,7 +126,6 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
cell->sorted = 0; cell->sorted = 0;
cell->sort = NULL; cell->sort = NULL;
cell->sortsize = 0; cell->sortsize = 0;
runner_do_sort(NULL, cell, 0x1FFF, 0);
return cell; return cell;
} }
...@@ -240,7 +239,7 @@ int main(int argc, char *argv[]) { ...@@ -240,7 +239,7 @@ int main(int argc, char *argv[]) {
char outputFileNameExtension[200] = ""; char outputFileNameExtension[200] = "";
char outputFileName[200] = ""; char outputFileName[200] = "";
int vel = velocity_zero; int vel = velocity_zero;
/* Initialize CPU frequency, this also starts time. */ /* Initialize CPU frequency, this also starts time. */
unsigned long long cpufreq = 0; unsigned long long cpufreq = 0;
clocks_set_cpufreq(cpufreq); clocks_set_cpufreq(cpufreq);
...@@ -331,6 +330,8 @@ int main(int argc, char *argv[]) { ...@@ -331,6 +330,8 @@ int main(int argc, char *argv[]) {
double offset[3] = {i * size, j * size, k * size}; double offset[3] = {i * size, j * size, k * size};
cells[i * 9 + j * 3 + k] = make_cell(particles, offset, size, h, rho, cells[i * 9 + j * 3 + k] = make_cell(particles, offset, size, h, rho,
&partId, perturbation, vel); &partId, perturbation, vel);
runner_do_sort(&runner, cells[i * 9 + j * 3 + k], 0x1FFF, 0);
} }
} }
} }
...@@ -345,6 +346,8 @@ int main(int argc, char *argv[]) { ...@@ -345,6 +346,8 @@ int main(int argc, char *argv[]) {
const ticks tic = getticks(); const ticks tic = getticks();
#if defined(DEFAULT_SPH) || !defined(WITH_VECTORIZATION)
/* Run all the pairs */ /* Run all the pairs */
for (int j = 0; j < 27; ++j) for (int j = 0; j < 27; ++j)
if (cells[j] != main_cell) if (cells[j] != main_cell)
...@@ -353,6 +356,8 @@ int main(int argc, char *argv[]) { ...@@ -353,6 +356,8 @@ int main(int argc, char *argv[]) {
/* And now the self-interaction */ /* And now the self-interaction */
runner_doself1_density(&runner, main_cell); runner_doself1_density(&runner, main_cell);
#endif
const ticks toc = getticks(); const ticks toc = getticks();
time += toc - tic; time += toc - tic;
...@@ -377,6 +382,8 @@ int main(int argc, char *argv[]) { ...@@ -377,6 +382,8 @@ int main(int argc, char *argv[]) {
const ticks tic = getticks(); const ticks tic = getticks();
#if defined(DEFAULT_SPH) || !defined(WITH_VECTORIZATION)
/* Run all the brute-force pairs */ /* Run all the brute-force pairs */
for (int j = 0; j < 27; ++j) for (int j = 0; j < 27; ++j)
if (cells[j] != main_cell) pairs_all_density(&runner, main_cell, cells[j]); if (cells[j] != main_cell) pairs_all_density(&runner, main_cell, cells[j]);
...@@ -384,6 +391,8 @@ int main(int argc, char *argv[]) { ...@@ -384,6 +391,8 @@ int main(int argc, char *argv[]) {
/* And now the self-interaction */ /* And now the self-interaction */
self_all_density(&runner, main_cell); self_all_density(&runner, main_cell);
#endif
const ticks toc = getticks(); const ticks toc = getticks();
/* Let's get physical ! */ /* Let's get physical ! */
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* *
******************************************************************************/ ******************************************************************************/
#define NO__AVX__
#include "kernel_hydro.h" #include "kernel_hydro.h"
#include "vector.h" #include "vector.h"
...@@ -53,6 +52,9 @@ int main() { ...@@ -53,6 +52,9 @@ int main() {
printf("\nVector Output for VEC_SIZE=%d\n", VEC_SIZE); printf("\nVector Output for VEC_SIZE=%d\n", VEC_SIZE);
printf("-------------\n"); printf("-------------\n");
#ifdef WITH_VECORIZATION
for (int i = 0; i < numPoints; i += VEC_SIZE) { for (int i = 0; i < numPoints; i += VEC_SIZE) {
vector vx, vx_h; vector vx, vx_h;
...@@ -84,5 +86,7 @@ int main() { ...@@ -84,5 +86,7 @@ int main() {
} }
printf("\nAll values are consistent\n"); printf("\nAll values are consistent\n");
#endif
return 0; return 0;
} }
...@@ -91,7 +91,6 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, ...@@ -91,7 +91,6 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
cell->sorted = 0; cell->sorted = 0;
cell->sort = NULL; cell->sort = NULL;
cell->sortsize = 0; cell->sortsize = 0;
runner_do_sort(NULL, cell, 0x1FFF, 0);
return cell; return cell;
} }
...@@ -245,6 +244,10 @@ int main(int argc, char *argv[]) { ...@@ -245,6 +244,10 @@ int main(int argc, char *argv[]) {
for (size_t i = 0; i < type + 1; ++i) offset[i] = 1.; for (size_t i = 0; i < type + 1; ++i) offset[i] = 1.;
cj = make_cell(particles, offset, size, h, rho, &partId, perturbation); cj = make_cell(particles, offset, size, h, rho, &partId, perturbation);
runner_do_sort(&runner, ci, 0x1FFF, 0);
runner_do_sort(&runner, cj, 0x1FFF, 0);
time = 0; time = 0;
for (size_t i = 0; i < runs; ++i) { for (size_t i = 0; i < runs; ++i) {
/* Zero the fields */ /* Zero the fields */
...@@ -253,9 +256,11 @@ int main(int argc, char *argv[]) { ...@@ -253,9 +256,11 @@ int main(int argc, char *argv[]) {
tic = getticks(); tic = getticks();
#if defined(DEFAULT_SPH) || !defined(WITH_VECTORIZATION)
/* Run the test */ /* Run the test */
runner_dopair1_density(&runner, ci, cj); runner_dopair1_density(&runner, ci, cj);
#endif
toc = getticks(); toc = getticks();
time += toc - tic; time += toc - tic;
...@@ -277,8 +282,10 @@ int main(int argc, char *argv[]) { ...@@ -277,8 +282,10 @@ int main(int argc, char *argv[]) {
tic = getticks(); tic = getticks();
#if defined(DEFAULT_SPH) || !defined(WITH_VECTORIZATION)
/* Run the brute-force test */ /* Run the brute-force test */
pairs_all_density(&runner, ci, cj); pairs_all_density(&runner, ci, cj);
#endif
toc = getticks(); toc = getticks();
......
...@@ -28,22 +28,23 @@ ...@@ -28,22 +28,23 @@
struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) { struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) {
size_t count = N * N * N; size_t count = N * N * N;
struct cell *cell = malloc(sizeof(struct cell)); struct cell *cell = malloc(sizeof(struct cell));
bzero(cell, sizeof(struct cell));
struct part *part; struct part *part;
struct xpart *xpart; struct xpart *xpart;
float h; float h;
size_t x, y, z, size; size_t x, y, z, size;
size = count * sizeof(struct part); size = count * sizeof(struct part);
if (posix_memalign((void **)&cell->parts, 32, size) != 0) { if (posix_memalign((void **)&cell->parts, part_align, size) != 0) {
error("couldn't allocate particles"); error("couldn't allocate particles");
} }
size = count * sizeof(struct xpart); size = count * sizeof(struct xpart);
if (posix_memalign((void **)&cell->xparts, 32, size) != 0) { if (posix_memalign((void **)&cell->xparts, xpart_align, size) != 0) {
error("couldn't allocate extended particles"); error("couldn't allocate extended particles");
} }
h = 1.127 * cellSize / N; h = 1.2348 * cellSize / N;
part = cell->parts; part = cell->parts;
xpart = cell->xparts; xpart = cell->xparts;
...@@ -61,6 +62,9 @@ struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) { ...@@ -61,6 +62,9 @@ struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) {
part->h = h; part->h = h;
part->id = x * N * N + y * N + z + id_offset; part->id = x * N * N + y * N + z + id_offset;
++part; ++part;
part->ti_begin = 0;
part->ti_end = 1;
} }
} }
} }
...@@ -68,22 +72,35 @@ struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) { ...@@ -68,22 +72,35 @@ struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) {
cell->split = 0; cell->split = 0;
cell->h_max = h; cell->h_max = h;
cell->count = count; cell->count = count;
cell->gcount = 0;
cell->dx_max = 0.;
cell->h[0] = cellSize; cell->h[0] = cellSize;
cell->h[1] = cellSize; cell->h[1] = cellSize;
cell->h[2] = cellSize; cell->h[2] = cellSize;
cell->ti_end_min = 1;
cell->ti_end_max = 1;
cell->sorted = 0;
cell->sort = NULL;
cell->sortsize = 0;
return cell; return cell;
} }
#ifdef DEFAULT_SPH
/* Just a forward declaration... */ /* Just a forward declaration... */
void runner_doself1_density(struct runner *r, struct cell *ci); void runner_doself1_density(struct runner *r, struct cell *ci);
void runner_doself2_force(struct runner *r, struct cell *ci); void runner_doself2_force(struct runner *r, struct cell *ci);
void runner_dopair1_density(struct runner *r, struct cell *ci, struct cell *cj);
void runner_dopair2_force(struct runner *r, struct cell *ci, struct cell *cj);
/* Run a full time step integration for one cell */ /* Run a full time step integration for one cell */
int main() { int main() {
#ifndef DEFAULT_SPH
return 0;
#else
int i, j, k, offset[3]; int i, j, k, offset[3];
struct part *p; struct part *p;
...@@ -92,6 +109,13 @@ int main() { ...@@ -92,6 +109,13 @@ int main() {
float rho = 2.; float rho = 2.;
float P = 1.; float P = 1.;
/* Initialize CPU frequency, this also starts time. */
unsigned long long cpufreq = 0;
clocks_set_cpufreq(cpufreq);
/* Get some randomness going */
srand(0);
/* Create cells */ /* Create cells */
struct cell *cells[27]; struct cell *cells[27];
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
...@@ -117,7 +141,13 @@ int main() { ...@@ -117,7 +141,13 @@ int main() {
struct cell *ci = cells[13]; struct cell *ci = cells[13];
/* Create the infrastructure */ /* Create the infrastructure */
struct space space;
space.periodic = 0;
space.h_max = 1.;
struct engine e; struct engine e;
e.s = &space;
struct runner r; struct runner r;
r.e = &e; r.e = &e;
...@@ -125,29 +155,45 @@ int main() { ...@@ -125,29 +155,45 @@ int main() {
e.timeBegin = 0.; e.timeBegin = 0.;
e.timeEnd = 1.; e.timeEnd = 1.;
e.timeOld = 0.; e.timeOld = 0.;
e.time = 0.; e.time = 0.1f;
e.dt_min = 0.; e.ti_current = 1;
e.dt_max = 1e10;
/* The tracked particle */ /* The tracked particle */
p = &(ci->parts[N * N * N / 2 + N * N / 2 + N / 2]); p = &(ci->parts[N * N * N / 2 + N * N / 2 + N / 2]);
message("Studying particle p->id=%lld", p->id); message("Studying particle p->id=%lld", p->id);
/* Sort the particles */
for (j = 0; j < 27; ++j) {
runner_do_sort(&r, cells[j], 0x1FFF, 0);
}
message("Sorting done");
/* Initialise the particles */ /* Initialise the particles */
for (j = 0; j < 27; ++j) { for (j = 0; j < 27; ++j) {
runner_doinit(&r, cells[j], 0); runner_do_init(&r, cells[j], 0);
} }
message("Init done");
/* Compute density */ /* Compute density */
runner_doself1_density(&r, ci); runner_doself1_density(&r, ci);
message("Self done");
for (int j = 0; j < 27; ++j)
if (cells[j] != ci)
runner_dopair1_density(&r, ci, cells[j]);
message("Density done");
/* Ghost task */
runner_do_ghost(&r, ci); runner_do_ghost(&r, ci);
message("h=%f rho=%f N_ngb=%f", p->h, p->rho, p->density.wcount); message("h=%f rho=%f N_ngb=%f", p->h, p->rho, p->density.wcount);
message("c=%f", p->force.c); message("c=%f", p->force.c);
runner_doself2_force(&r, ci); runner_doself2_force(&r, ci);
runner_dokick(&r, ci, 1); runner_do_kick(&r, ci, 1);
message("ti_end=%d", p->ti_end); message("ti_end=%d", p->ti_end);
...@@ -155,10 +201,8 @@ int main() { ...@@ -155,10 +201,8 @@ int main() {
free(ci->xparts); free(ci->xparts);
return 0; return 0;
}
#else
int main() { return 0; }
#endif #endif
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment