Make atVec3d 32-byte aligned

This commit is contained in:
Jack Andersen 2017-12-18 17:04:03 -10:00
parent 2c66d56076
commit cee9478773
1 changed files with 25 additions and 6 deletions

View File

@ -14,8 +14,7 @@ using atUint64 = uint64_t;
// Vector types
#if __SSE__
#include <xmmintrin.h>
#include <emmintrin.h>
#include <immintrin.h>
#ifndef _WIN32
#include <mm_malloc.h>
#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;