diff --git a/src/hydro/Default/hydro_iact.h b/src/hydro/Default/hydro_iact.h index 74ea95563d691cc41120a487e30f4d173de37590..cb7b1591a38a914ffa8ce528ed4d547fe6257a48 100644 --- a/src/hydro/Default/hydro_iact.h +++ b/src/hydro/Default/hydro_iact.h @@ -648,8 +648,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force( pi[k]->force.v_sig = vi_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]; - pj[k]->a[j] += pja[j].f[k]; + pi[k]->a_hydro[j] -= pia[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( pi[k]->h_dt -= pih_dt.f[k]; pi[k]->force.v_sig = vi_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 diff --git a/tests/Makefile.am b/tests/Makefile.am index 163a9ad096ddc2a79489de2930bb1d4288d1eb3e..64496e0e420b3db591e4f00b8fd697050d761514 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 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 check_PROGRAMS = testGreetings testReading testSingle testTimeIntegration \ diff --git a/tests/test27cells.c b/tests/test27cells.c index 3e2f11c7aabac0a7ff2df19f2c48f9f81ea55df5..7182c5776f60091205230f1baa93321a534b4977 100644 --- a/tests/test27cells.c +++ b/tests/test27cells.c @@ -126,7 +126,6 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, cell->sorted = 0; cell->sort = NULL; cell->sortsize = 0; - runner_do_sort(NULL, cell, 0x1FFF, 0); return cell; } @@ -240,7 +239,7 @@ int main(int argc, char *argv[]) { char outputFileNameExtension[200] = ""; char outputFileName[200] = ""; int vel = velocity_zero; - + /* Initialize CPU frequency, this also starts time. */ unsigned long long cpufreq = 0; clocks_set_cpufreq(cpufreq); @@ -331,6 +330,8 @@ int main(int argc, char *argv[]) { double offset[3] = {i * size, j * size, k * size}; cells[i * 9 + j * 3 + k] = make_cell(particles, offset, size, h, rho, &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[]) { const ticks tic = getticks(); +#if defined(DEFAULT_SPH) || !defined(WITH_VECTORIZATION) + /* Run all the pairs */ for (int j = 0; j < 27; ++j) if (cells[j] != main_cell) @@ -353,6 +356,8 @@ int main(int argc, char *argv[]) { /* And now the self-interaction */ runner_doself1_density(&runner, main_cell); +#endif + const ticks toc = getticks(); time += toc - tic; @@ -377,6 +382,8 @@ int main(int argc, char *argv[]) { const ticks tic = getticks(); +#if defined(DEFAULT_SPH) || !defined(WITH_VECTORIZATION) + /* Run all the brute-force pairs */ for (int j = 0; j < 27; ++j) if (cells[j] != main_cell) pairs_all_density(&runner, main_cell, cells[j]); @@ -384,6 +391,8 @@ int main(int argc, char *argv[]) { /* And now the self-interaction */ self_all_density(&runner, main_cell); +#endif + const ticks toc = getticks(); /* Let's get physical ! */ diff --git a/tests/testKernel.c b/tests/testKernel.c index 182bae5334e1a5061e584212a31186dc4e7f0818..7efdd5e0a8b4f20f0918c98a8f7d0215a397946d 100644 --- a/tests/testKernel.c +++ b/tests/testKernel.c @@ -18,7 +18,6 @@ * ******************************************************************************/ -#define NO__AVX__ #include "kernel_hydro.h" #include "vector.h" @@ -53,6 +52,9 @@ int main() { printf("\nVector Output for VEC_SIZE=%d\n", VEC_SIZE); printf("-------------\n"); + +#ifdef WITH_VECORIZATION + for (int i = 0; i < numPoints; i += VEC_SIZE) { vector vx, vx_h; @@ -84,5 +86,7 @@ int main() { } printf("\nAll values are consistent\n"); + +#endif return 0; } diff --git a/tests/testPair.c b/tests/testPair.c index f9539fc1a444828c65b39e56618eb7bb98bd67de..d9cb1833ae8d75561662fe341a540600a7db9a73 100644 --- a/tests/testPair.c +++ b/tests/testPair.c @@ -91,7 +91,6 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, cell->sorted = 0; cell->sort = NULL; cell->sortsize = 0; - runner_do_sort(NULL, cell, 0x1FFF, 0); return cell; } @@ -245,6 +244,10 @@ int main(int argc, char *argv[]) { for (size_t i = 0; i < type + 1; ++i) offset[i] = 1.; 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; for (size_t i = 0; i < runs; ++i) { /* Zero the fields */ @@ -253,9 +256,11 @@ int main(int argc, char *argv[]) { tic = getticks(); +#if defined(DEFAULT_SPH) || !defined(WITH_VECTORIZATION) /* Run the test */ runner_dopair1_density(&runner, ci, cj); - +#endif + toc = getticks(); time += toc - tic; @@ -277,8 +282,10 @@ int main(int argc, char *argv[]) { tic = getticks(); +#if defined(DEFAULT_SPH) || !defined(WITH_VECTORIZATION) /* Run the brute-force test */ pairs_all_density(&runner, ci, cj); +#endif toc = getticks(); diff --git a/tests/testSPHStep.c b/tests/testSPHStep.c index 3af0c6ad1afdeab749a378153fd1a8e016f29659..97051a877f5e0c5205c1cced08b57d47fb9b1d39 100644 --- a/tests/testSPHStep.c +++ b/tests/testSPHStep.c @@ -28,22 +28,23 @@ struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) { size_t count = N * N * N; struct cell *cell = malloc(sizeof(struct cell)); + bzero(cell, sizeof(struct cell)); struct part *part; struct xpart *xpart; float h; size_t x, y, z, size; 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"); } 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"); } - h = 1.127 * cellSize / N; + h = 1.2348 * cellSize / N; part = cell->parts; xpart = cell->xparts; @@ -61,6 +62,9 @@ struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) { part->h = h; part->id = x * N * N + y * N + z + id_offset; ++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) { cell->split = 0; cell->h_max = h; cell->count = count; + cell->gcount = 0; + cell->dx_max = 0.; cell->h[0] = cellSize; cell->h[1] = 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; } -#ifdef DEFAULT_SPH - /* Just a forward declaration... */ void runner_doself1_density(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 */ int main() { +#ifndef DEFAULT_SPH + return 0; +#else + int i, j, k, offset[3]; struct part *p; @@ -92,6 +109,13 @@ int main() { float rho = 2.; 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 */ struct cell *cells[27]; for (i = 0; i < 3; i++) @@ -117,7 +141,13 @@ int main() { struct cell *ci = cells[13]; /* Create the infrastructure */ + struct space space; + space.periodic = 0; + space.h_max = 1.; + struct engine e; + e.s = &space; + struct runner r; r.e = &e; @@ -125,29 +155,45 @@ int main() { e.timeBegin = 0.; e.timeEnd = 1.; e.timeOld = 0.; - e.time = 0.; - e.dt_min = 0.; - e.dt_max = 1e10; - + e.time = 0.1f; + e.ti_current = 1; + /* The tracked particle */ p = &(ci->parts[N * N * N / 2 + N * N / 2 + N / 2]); 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 */ for (j = 0; j < 27; ++j) { - runner_doinit(&r, cells[j], 0); + runner_do_init(&r, cells[j], 0); } + message("Init done"); + /* Compute density */ 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); message("h=%f rho=%f N_ngb=%f", p->h, p->rho, p->density.wcount); message("c=%f", p->force.c); runner_doself2_force(&r, ci); - runner_dokick(&r, ci, 1); + runner_do_kick(&r, ci, 1); message("ti_end=%d", p->ti_end); @@ -155,10 +201,8 @@ int main() { free(ci->xparts); return 0; -} - -#else - -int main() { return 0; } #endif + +} +