From 8d1b26dd4b2d97f9b6aba144082f5d50f71971ed Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Fri, 15 May 2015 11:32:11 +0100 Subject: [PATCH] Key of mm_malloc.h --- lib/Grid_aligned_allocator.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/Grid_aligned_allocator.h b/lib/Grid_aligned_allocator.h index f0b93172..0e74e842 100644 --- a/lib/Grid_aligned_allocator.h +++ b/lib/Grid_aligned_allocator.h @@ -2,6 +2,9 @@ #define GRID_ALIGNED_ALLOCATOR_H #include +#ifdef HAVE_MM_MALLOC_H +#include +#endif namespace Grid { @@ -36,16 +39,20 @@ public: pointer allocate(size_type __n, const void* = 0) { -#ifdef AVX512 - _Tp * ptr = (_Tp *) memalign(128,__n*sizeof(_Tp)); -#else +#ifdef HAVE_MM_MALLOC_H _Tp * ptr = (_Tp *) _mm_malloc(__n*sizeof(_Tp),128); +#else + _Tp * ptr = (_Tp *) memalign(128,__n*sizeof(_Tp)); #endif return ptr; } void deallocate(pointer __p, size_type) { - free(__p); +#ifdef HAVE_MM_MALLOC_H + _mm_free(__p); +#else + free(__p); +#endif } void construct(pointer __p, const _Tp& __val) { }; void construct(pointer __p) { };