From edaa3ba1db0ebab67ac6b93d110197aabf3525b3 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Tue, 23 Aug 2016 15:37:11 +0100
Subject: [PATCH] Define a constant for the cell memory allocation alignment.

---
 src/cell.h   | 4 +++-
 src/engine.c | 2 +-
 src/space.c  | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/cell.h b/src/cell.h
index 199c901a78..a2f7ab6912 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -44,6 +44,8 @@ struct space;
  * The maximum was lowered by a further factor of 2 to be on the safe side.*/
 #define cell_max_tag (1 << 29)
 
+#define cell_align 32
+
 /* Global variables. */
 extern int cell_next_tag;
 
@@ -198,7 +200,7 @@ struct cell {
 
 #endif
 
-} __attribute__((aligned(64)));
+} __attribute__((aligned(cell_align)));
 
 /* Convert cell location to ID. */
 #define cell_getid(cdim, i, j, k) \
diff --git a/src/engine.c b/src/engine.c
index 2874ee2c6a..5097230aff 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -3126,7 +3126,7 @@ void engine_init(struct engine *e, struct space *s,
   e->timeStep = 0.;
   e->timeBase = 0.;
   e->timeBase_inv = 0.;
-  e->drift_all = 0;
+  e->drift_all = (policy & engine_policy_drift_all);
   e->internalUnits = internal_units;
   e->timeFirstSnapshot =
       parser_get_param_double(params, "Snapshots:time_first");
diff --git a/src/space.c b/src/space.c
index 2f4442c472..3cce9e01f9 100644
--- a/src/space.c
+++ b/src/space.c
@@ -272,7 +272,7 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
 
     /* Allocate the highest level of cells. */
     s->tot_cells = s->nr_cells = cdim[0] * cdim[1] * cdim[2];
-    if (posix_memalign((void *)&s->cells, 64,
+    if (posix_memalign((void *)&s->cells, cell_align,
                        s->nr_cells * sizeof(struct cell)) != 0)
       error("Failed to allocate cells.");
     bzero(s->cells, s->nr_cells * sizeof(struct cell));
@@ -1406,7 +1406,7 @@ struct cell *space_getcell(struct space *s) {
 
   /* Is the buffer empty? */
   if (s->cells_new == NULL) {
-    if (posix_memalign((void *)&s->cells_new, 64,
+    if (posix_memalign((void *)&s->cells_new, cell_align,
                        space_cellallocchunk * sizeof(struct cell)) != 0)
       error("Failed to allocate more cells.");
     bzero(s->cells_new, space_cellallocchunk * sizeof(struct cell));
-- 
GitLab