Skip to content
Snippets Groups Projects
Commit 7d1cbf8e authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Take care with structure alignments, we should allocate cells with...

Take care with structure alignments, we should allocate cells with posix_memalign and when passing aligned structs, like runner, do this by pointer not value, not sure how aligned memory will work on the stack

Was crashing on COSMA6, so AVX not AVX2 this time

Note part of this squashes the report 'note: The ABI for passing parameters with 64-byte alignment has changed in GCC 4.6' when calling test_boundary_conditions()
parent 21d7608f
No related branches found
No related tags found
1 merge request!997Fixes for checks on optimized AXV2 architectures
......@@ -78,7 +78,10 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
enum velocity_types vel) {
const size_t count = n * n * n;
const double volume = size * size * size;
struct cell *cell = (struct cell *)malloc(sizeof(struct cell));
struct cell *cell = NULL;
if (posix_memalign((void **)&cell, cell_align, sizeof(struct cell)) != 0) {
error("couldn't allocate cell");
}
bzero(cell, sizeof(struct cell));
if (posix_memalign((void **)&cell->hydro.parts, part_align,
......@@ -290,7 +293,7 @@ void runner_dopair1_branch_density(struct runner *r, struct cell *ci,
struct cell *cj);
void runner_doself1_branch_density(struct runner *r, struct cell *c);
void test_boundary_conditions(struct cell **cells, struct runner runner,
void test_boundary_conditions(struct cell **cells, struct runner *runner,
const int loc_i, const int loc_j, const int loc_k,
const int dim, char *swiftOutputFileName,
char *bruteForceOutputFileName) {
......@@ -303,10 +306,10 @@ void test_boundary_conditions(struct cell **cells, struct runner runner,
/* Run all the pairs */
#ifdef WITH_VECTORIZATION
runner.ci_cache.count = 0;
cache_init(&runner.ci_cache, 512);
runner.cj_cache.count = 0;
cache_init(&runner.cj_cache, 512);
runner->ci_cache.count = 0;
cache_init(&runner->ci_cache, 512);
runner->cj_cache.count = 0;
cache_init(&runner->cj_cache, 512);
#endif
/* Now loop over all the neighbours of this cell
......@@ -324,17 +327,17 @@ void test_boundary_conditions(struct cell **cells, struct runner runner,
/* Get the neighbouring cell */
struct cell *cj = cells[iii * (dim * dim) + jjj * dim + kkk];
if (cj != main_cell) DOPAIR1(&runner, main_cell, cj);
if (cj != main_cell) DOPAIR1(runner, main_cell, cj);
}
}
}
/* And now the self-interaction */
DOSELF1(&runner, main_cell);
DOSELF1(runner, main_cell);
/* Let's get physical ! */
end_calculation(main_cell, runner.e->cosmology);
end_calculation(main_cell, runner->e->cosmology);
/* Dump particles from the main cell. */
dump_particle_fields(swiftOutputFileName, main_cell, loc_i, loc_j, loc_k);
......@@ -359,16 +362,16 @@ void test_boundary_conditions(struct cell **cells, struct runner runner,
/* Get the neighbouring cell */
struct cell *cj = cells[iii * (dim * dim) + jjj * dim + kkk];
if (cj != main_cell) pairs_all_density(&runner, main_cell, cj);
if (cj != main_cell) pairs_all_density(runner, main_cell, cj);
}
}
}
/* And now the self-interaction */
self_all_density(&runner, main_cell);
self_all_density(runner, main_cell);
/* Let's get physical ! */
end_calculation(main_cell, runner.e->cosmology);
end_calculation(main_cell, runner->e->cosmology);
/* Dump */
dump_particle_fields(bruteForceOutputFileName, main_cell, loc_i, loc_j,
......@@ -491,8 +494,9 @@ int main(int argc, char *argv[]) {
engine.hydro_properties = &hp;
engine.nodeID = NODE_ID;
struct runner runner;
runner.e = &engine;
struct runner real_runner;
struct runner *runner = &real_runner;
runner->e = &engine;
struct cosmology cosmo;
cosmology_init_no_cosmo(&cosmo);
......@@ -508,9 +512,9 @@ int main(int argc, char *argv[]) {
cells[i * (dim * dim) + j * dim + k] = make_cell(
particles, offset, size, h, rho, &partId, perturbation, vel);
runner_do_drift_part(&runner, cells[i * (dim * dim) + j * dim + k], 0);
runner_do_drift_part(runner, cells[i * (dim * dim) + j * dim + k], 0);
runner_do_hydro_sort(&runner, cells[i * (dim * dim) + j * dim + k],
runner_do_hydro_sort(runner, cells[i * (dim * dim) + j * dim + k],
0x1FFF, 0, 0);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment