mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-10-30 19:44:32 +00:00 
			
		
		
		
	Key of mm_malloc.h
This commit is contained in:
		| @@ -2,6 +2,9 @@ | |||||||
| #define GRID_ALIGNED_ALLOCATOR_H | #define GRID_ALIGNED_ALLOCATOR_H | ||||||
|  |  | ||||||
| #include <immintrin.h> | #include <immintrin.h> | ||||||
|  | #ifdef HAVE_MM_MALLOC_H | ||||||
|  | #include <mm_malloc.h> | ||||||
|  | #endif | ||||||
|  |  | ||||||
| namespace Grid { | namespace Grid { | ||||||
|  |  | ||||||
| @@ -36,16 +39,20 @@ public: | |||||||
|  |  | ||||||
|   pointer allocate(size_type __n, const void* = 0) |   pointer allocate(size_type __n, const void* = 0) | ||||||
|   {  |   {  | ||||||
| #ifdef AVX512 | #ifdef HAVE_MM_MALLOC_H | ||||||
|     _Tp * ptr = (_Tp *) memalign(128,__n*sizeof(_Tp)); |  | ||||||
| #else |  | ||||||
|     _Tp * ptr = (_Tp *) _mm_malloc(__n*sizeof(_Tp),128); |     _Tp * ptr = (_Tp *) _mm_malloc(__n*sizeof(_Tp),128); | ||||||
|  | #else | ||||||
|  |     _Tp * ptr = (_Tp *) memalign(128,__n*sizeof(_Tp)); | ||||||
| #endif | #endif | ||||||
|     return ptr; |     return ptr; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void deallocate(pointer __p, size_type) {  |   void deallocate(pointer __p, size_type) {  | ||||||
|  | #ifdef HAVE_MM_MALLOC_H | ||||||
|  |     _mm_free(__p);  | ||||||
|  | #else | ||||||
|     free(__p); |     free(__p); | ||||||
|  | #endif | ||||||
|   } |   } | ||||||
|   void construct(pointer __p, const _Tp& __val) { }; |   void construct(pointer __p, const _Tp& __val) { }; | ||||||
|   void construct(pointer __p) { }; |   void construct(pointer __p) { }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user