diff --git a/src/Makefile.am b/src/Makefile.am index 2343ab99ffd90a27e588344c1fae4f1491b4625e..569ccea6990c7939c166afb74eb9d9513cb324e1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -55,7 +55,7 @@ AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \ runner_doiact_fft.c threadpool.c cooling.c # Include files for distribution, not installation. -nobase_noinst_HEADERS = approx_math.h atomic.h cycle.h error.h inline.h kernel_hydro.h kernel_gravity.h \ +nobase_noinst_HEADERS = align.h approx_math.h atomic.h cycle.h error.h inline.h kernel_hydro.h kernel_gravity.h \ kernel_long_gravity.h vector.h runner_doiact.h runner_doiact_grav.h runner_doiact_fft.h \ units.h intrinsics.h minmax.h kick.h timestep.h drift.h adiabatic_index.h io_properties.h \ dimension.h equation_of_state.h \ diff --git a/src/align.h b/src/align.h new file mode 100644 index 0000000000000000000000000000000000000000..84e2909c0866c18f0f8378df9d0efc8d0f6545b5 --- /dev/null +++ b/src/align.h @@ -0,0 +1,27 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ +#ifndef SWIFT_ALIGN_H +#define SWIFT_ALIGN_H + +/** + * @brief Defines alignment of structures + */ +#define SWIFT_STRUCT_ALIGN __attribute__((aligned(32))) + +#endif /* SWIFT_ALIGN_H */ diff --git a/src/cell.h b/src/cell.h index 084fbcaef779d0083701c6c5a5aaba2c62f1768a..22ecaeb27fc2a958d9d33bb87bdf9422a3dea42f 100644 --- a/src/cell.h +++ b/src/cell.h @@ -30,6 +30,7 @@ #include <stddef.h> /* Local includes. */ +#include "align.h" #include "lock.h" #include "multipole.h" #include "part.h" @@ -74,7 +75,8 @@ struct pcell { /* Relative indices of the cell's progeny. */ int progeny[8]; -}; + +} SWIFT_STRUCT_ALIGN; /* Structure to store the data of a single cell. */ struct cell { @@ -208,7 +210,7 @@ struct cell { #endif -} __attribute__((aligned(32))); +} SWIFT_STRUCT_ALIGN; /* 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 e85cf30d795a3373258e2e014f451e911d3a55a3..f06e65e5b30ebcd609c0c6204de33da17b770add 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(32))); +} SWIFT_STRUCT_ALIGN; #endif /* SWIFT_DEFAULT_GRAVITY_PART_H */ diff --git a/src/hydro/Default/hydro_part.h b/src/hydro/Default/hydro_part.h index 46c5d0e29ef0cbc21997ea02d12cd8e916d6c4c1..aa1d516e82995b3f389b7fea9f92687929bef63b 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(32))); +} SWIFT_STRUCT_ALIGN; /* Data of a single particle. */ struct part { @@ -120,6 +120,6 @@ struct part { /* Pointer to corresponding gravity part. */ struct gpart* gpart; -} __attribute__((aligned(32))); +} SWIFT_STRUCT_ALIGN; #endif /* SWIFT_DEFAULT_HYDRO_PART_H */ diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h index 3fd5c28d22b4aa30bbb1a0f12571f079c297c0d7..94797b979af54f0ab8f41eacff49d392262d3249 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(32))); +} SWIFT_STRUCT_ALIGN; /* Data of a single particle. */ struct part { @@ -110,6 +110,6 @@ struct part { /* Pointer to corresponding gravity part. */ struct gpart* gpart; -} __attribute__((aligned(32))); +} SWIFT_STRUCT_ALIGN; #endif /* SWIFT_GADGET2_HYDRO_PART_H */ diff --git a/src/hydro/Gizmo/hydro_part.h b/src/hydro/Gizmo/hydro_part.h index c7983f9f94f321f330ad26645393728df6b2f04b..cc2e9c9db178c59189b6bad4ad81523725173147 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(32))); +} SWIFT_STRUCT_ALIGN; /* Data of a single particle. */ struct part { @@ -196,4 +196,4 @@ struct part { /* Associated gravitas. */ struct gpart *gpart; -} __attribute__((aligned(32))); +} SWIFT_STRUCT_ALIGN; diff --git a/src/hydro/Minimal/hydro_part.h b/src/hydro/Minimal/hydro_part.h index 2110730620853e9abb86717ff4df7febe7063a45..bf6c464777fe1abfe57b47a99229404d0f14ff86 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(32))); +} SWIFT_STRUCT_ALIGN; /** * @brief Particle fields for the SPH particles @@ -120,6 +120,6 @@ struct part { struct gpart* gpart; /*!< Pointer to corresponding gravity part. */ -} __attribute__((aligned(32))); +} SWIFT_STRUCT_ALIGN; #endif /* SWIFT_MINIMAL_HYDRO_PART_H */ diff --git a/src/part.h b/src/part.h index 63996160e857ce3aae9ba4acce46a92e96c7e8fa..af39d10fafc11d4435ddbcc087fbf08178b18959 100644 --- a/src/part.h +++ b/src/part.h @@ -31,6 +31,7 @@ #endif /* Local headers. */ +#include "align.h" #include "const.h" /* Some constants. */ diff --git a/src/task.h b/src/task.h index f070451fe4e79e0c16dc3dcca1ce145c08841c47..4928dc00bcd7958efdd6987b5aec90ab4b3e92fa 100644 --- a/src/task.h +++ b/src/task.h @@ -26,6 +26,7 @@ #include "../config.h" /* Includes. */ +#include "align.h" #include "cell.h" #include "cycle.h" @@ -149,7 +150,7 @@ struct task { /*! Is this task implicit (i.e. does not do anything) ? */ char implicit; -} __attribute__((aligned(32))); +} SWIFT_STRUCT_ALIGN; /* Function prototypes. */ void task_unlock(struct task *t);