From cee9478773927a99ce40e625b9cc20bfdea32597 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 18 Dec 2017 17:04:03 -1000 Subject: [PATCH] Make atVec3d 32-byte aligned --- include/athena/Types.hpp | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/include/athena/Types.hpp b/include/athena/Types.hpp index 58b1691..72b15c8 100644 --- a/include/athena/Types.hpp +++ b/include/athena/Types.hpp @@ -14,8 +14,7 @@ using atUint64 = uint64_t; // Vector types #if __SSE__ -#include -#include +#include #ifndef _WIN32 #include #endif @@ -32,6 +31,16 @@ void operator delete(void* buf) noexcept \ void operator delete[](void* buf) noexcept \ {_mm_free(buf);} +#define AT_ALIGNED_ALLOCATOR32 \ +void* operator new(size_t bytes) noexcept \ +{return _mm_malloc(bytes, 32);} \ +void* operator new[](size_t bytes) noexcept \ +{return _mm_malloc(bytes, 32);} \ +void operator delete(void* buf) noexcept \ +{_mm_free(buf);} \ +void operator delete[](void* buf) noexcept \ +{_mm_free(buf);} + typedef union alignas(16) { #if __clang__ @@ -77,20 +86,30 @@ typedef union alignas(16) double vec[2]; } atVec2d; -typedef union alignas(16) +typedef union alignas(32) { +#if __AVX__ + __m256d mVec256; + AT_ALIGNED_ALLOCATOR32 +#elif __SSE__ + AT_ALIGNED_ALLOCATOR +#endif #if __SSE__ __m128d mVec128[2]; - AT_ALIGNED_ALLOCATOR #endif double vec[3]; } atVec3d; -typedef union alignas(16) +typedef union alignas(32) { +#if __AVX__ + __m256d mVec256; + AT_ALIGNED_ALLOCATOR32 +#elif __SSE__ + AT_ALIGNED_ALLOCATOR +#endif #if __SSE__ __m128d mVec128[2]; - AT_ALIGNED_ALLOCATOR #endif double vec[4]; } atVec4d;