diff --git a/include/engine/Port.hpp b/include/engine/Port.hpp index ac92e42f3..af87d9ab3 100644 --- a/include/engine/Port.hpp +++ b/include/engine/Port.hpp @@ -13,7 +13,9 @@ static const int PORT_MAX_CHANNELS = 16; struct Port { /** Voltage of the port. */ - union { + /** NOTE alignas is required in order to allow SSE usage. + Consecutive data (like in a vector) would otherwise pack Ports in a way that breaks SSE. */ + union alignas(32) { /** Unstable API. Use getVoltage() and setVoltage() instead. */ float voltages[PORT_MAX_CHANNELS] = {}; /** DEPRECATED. Unstable API. Use getVoltage() and setVoltage() instead. */ diff --git a/include/simd/Vector.hpp b/include/simd/Vector.hpp index 9d2556698..579e783c8 100644 --- a/include/simd/Vector.hpp +++ b/include/simd/Vector.hpp @@ -34,7 +34,8 @@ struct Vector { using type = float; constexpr static int size = 4; - union { + /** NOTE alignas is required in order to allow SSE usage. */ + union alignas(32) { __m128 v; /** Accessing this array of scalars is slow and defeats the purpose of vectorizing. */ @@ -108,7 +109,8 @@ struct Vector { using type = int32_t; constexpr static int size = 4; - union { + /** NOTE alignas is required in order to allow SSE usage. */ + union alignas(32) { __m128i v; int32_t s[4]; };