From 0de9dae063af8d4662ff8ce85c62e01698989e32 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Thu, 1 Sep 2016 16:52:25 +0100
Subject: [PATCH] Align critical structures on 128 bytes and make all their
 sizes multiples of 32 bytes.

---
 src/cell.h                         | 4 ++--
 src/gravity/Default/gravity_part.h | 2 +-
 src/hydro/Default/hydro_part.h     | 4 ++--
 src/hydro/Gadget2/hydro_part.h     | 4 ++--
 src/hydro/Gizmo/hydro_part.h       | 4 ++--
 src/hydro/Minimal/hydro_part.h     | 4 ++--
 src/part.h                         | 6 +++---
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/cell.h b/src/cell.h
index 9f3971dd59..dc9606e372 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -44,7 +44,7 @@ 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
+#define cell_align 128
 
 /* Global variables. */
 extern int cell_next_tag;
@@ -205,7 +205,7 @@ struct cell {
 
 #endif
 
-} __attribute__((aligned(cell_align)));
+} __attribute__((aligned(32)));
 
 /* Convert cell location to ID. */
 #define cell_getid(cdim, i, j, k) \
diff --git a/src/gravity/Default/gravity_part.h b/src/gravity/Default/gravity_part.h
index 1850ff0a16..e85cf30d79 100644
--- a/src/gravity/Default/gravity_part.h
+++ b/src/gravity/Default/gravity_part.h
@@ -53,6 +53,6 @@ struct gpart {
      which this gpart is linked. */
   long long id_or_neg_offset;
 
-} __attribute__((aligned(gpart_align)));
+} __attribute__((aligned(32)));
 
 #endif /* SWIFT_DEFAULT_GRAVITY_PART_H */
diff --git a/src/hydro/Default/hydro_part.h b/src/hydro/Default/hydro_part.h
index f42c3dc886..46c5d0e29e 100644
--- a/src/hydro/Default/hydro_part.h
+++ b/src/hydro/Default/hydro_part.h
@@ -33,7 +33,7 @@ struct xpart {
   /* Old density. */
   float omega;
 
-} __attribute__((aligned(xpart_align)));
+} __attribute__((aligned(32)));
 
 /* Data of a single particle. */
 struct part {
@@ -120,6 +120,6 @@ struct part {
   /* Pointer to corresponding gravity part. */
   struct gpart* gpart;
 
-} __attribute__((aligned(part_align)));
+} __attribute__((aligned(32)));
 
 #endif /* SWIFT_DEFAULT_HYDRO_PART_H */
diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h
index 484792438d..3fd5c28d22 100644
--- a/src/hydro/Gadget2/hydro_part.h
+++ b/src/hydro/Gadget2/hydro_part.h
@@ -28,7 +28,7 @@ struct xpart {
   /* Velocity at the last full step. */
   float v_full[3];
 
-} __attribute__((aligned(xpart_align)));
+} __attribute__((aligned(32)));
 
 /* Data of a single particle. */
 struct part {
@@ -110,6 +110,6 @@ struct part {
   /* Pointer to corresponding gravity part. */
   struct gpart* gpart;
 
-} __attribute__((aligned(part_align)));
+} __attribute__((aligned(32)));
 
 #endif /* SWIFT_GADGET2_HYDRO_PART_H */
diff --git a/src/hydro/Gizmo/hydro_part.h b/src/hydro/Gizmo/hydro_part.h
index d425294671..c7983f9f94 100644
--- a/src/hydro/Gizmo/hydro_part.h
+++ b/src/hydro/Gizmo/hydro_part.h
@@ -26,7 +26,7 @@ struct xpart {
   /* Velocity at the last full step. */
   float v_full[3];
 
-} __attribute__((aligned(xpart_align)));
+} __attribute__((aligned(32)));
 
 /* Data of a single particle. */
 struct part {
@@ -196,4 +196,4 @@ struct part {
   /* Associated gravitas. */
   struct gpart *gpart;
 
-} __attribute__((aligned(part_align)));
+} __attribute__((aligned(32)));
diff --git a/src/hydro/Minimal/hydro_part.h b/src/hydro/Minimal/hydro_part.h
index ad65f8b44f..2110730620 100644
--- a/src/hydro/Minimal/hydro_part.h
+++ b/src/hydro/Minimal/hydro_part.h
@@ -47,7 +47,7 @@ struct xpart {
 
   float v_full[3]; /*!< Velocity at the last full step. */
 
-} __attribute__((aligned(xpart_align)));
+} __attribute__((aligned(32)));
 
 /**
  * @brief Particle fields for the SPH particles
@@ -120,6 +120,6 @@ struct part {
 
   struct gpart* gpart; /*!< Pointer to corresponding gravity part. */
 
-} __attribute__((aligned(part_align)));
+} __attribute__((aligned(32)));
 
 #endif /* SWIFT_MINIMAL_HYDRO_PART_H */
diff --git a/src/part.h b/src/part.h
index ea895e6e02..63996160e8 100644
--- a/src/part.h
+++ b/src/part.h
@@ -34,9 +34,9 @@
 #include "const.h"
 
 /* Some constants. */
-#define part_align 64
-#define xpart_align 32
-#define gpart_align 32
+#define part_align 128
+#define xpart_align 128
+#define gpart_align 128
 
 /* Import the right hydro particle definition */
 #if defined(MINIMAL_SPH)
-- 
GitLab