19 #ifndef EIGEN_MEMORY_H
20 #define EIGEN_MEMORY_H
29 #if defined(__GLIBC__) && ((__GLIBC__>=2 && __GLIBC_MINOR__ >= 8) || __GLIBC__>2) \
31 #define EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED 1
33 #define EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED 0
40 #if defined(__FreeBSD__) && !defined(__arm__) && !defined(__mips__)
41 #define EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED 1
43 #define EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED 0
46 #if defined(__APPLE__) \
48 || EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED \
49 || EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED
50 #define EIGEN_MALLOC_ALREADY_ALIGNED 1
52 #define EIGEN_MALLOC_ALREADY_ALIGNED 0
55 #if ((defined __QNXNTO__) || (defined _GNU_SOURCE) || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))) \
56 && (defined _POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO > 0)
57 #define EIGEN_HAS_POSIX_MEMALIGN 1
59 #define EIGEN_HAS_POSIX_MEMALIGN 0
62 #ifdef EIGEN_VECTORIZE_SSE
63 #define EIGEN_HAS_MM_MALLOC 1
65 #define EIGEN_HAS_MM_MALLOC 0
72 inline void throw_std_bad_alloc()
74 #ifdef EIGEN_EXCEPTIONS
75 throw std::bad_alloc();
77 std::size_t huge = -1;
91 inline void* handmade_aligned_malloc(std::size_t size)
93 void *original = std::malloc(size+16);
94 if (original == 0)
return 0;
95 void *aligned =
reinterpret_cast<void*
>((
reinterpret_cast<std::size_t
>(original) & ~(std::size_t(15))) + 16);
96 *(
reinterpret_cast<void**
>(aligned) - 1) = original;
101 inline void handmade_aligned_free(
void *ptr)
103 if (ptr) std::free(*(reinterpret_cast<void**>(ptr) - 1));
111 inline void* handmade_aligned_realloc(
void* ptr, std::size_t size, std::size_t = 0)
113 if (ptr == 0)
return handmade_aligned_malloc(size);
114 void *original = *(
reinterpret_cast<void**
>(ptr) - 1);
115 std::ptrdiff_t previous_offset =
static_cast<char *
>(ptr)-static_cast<char *>(original);
116 original = std::realloc(original,size+16);
117 if (original == 0)
return 0;
118 void *aligned =
reinterpret_cast<void*
>((
reinterpret_cast<std::size_t
>(original) & ~(std::size_t(15))) + 16);
119 void *previous_aligned =
static_cast<char *
>(original)+previous_offset;
120 if(aligned!=previous_aligned)
121 std::memmove(aligned, previous_aligned, size);
123 *(
reinterpret_cast<void**
>(aligned) - 1) = original;
131 void* aligned_malloc(std::size_t size);
132 void aligned_free(
void *ptr);
139 inline void* generic_aligned_realloc(
void* ptr,
size_t size,
size_t old_size)
142 return aligned_malloc(size);
150 void* newptr = aligned_malloc(size);
153 #ifdef EIGEN_HAS_ERRNO
161 std::memcpy(newptr, ptr, (std::min)(size,old_size));
172 #ifdef EIGEN_NO_MALLOC
173 inline void check_that_malloc_is_allowed()
175 eigen_assert(
false &&
"heap allocation is forbidden (EIGEN_NO_MALLOC is defined)");
177 #elif defined EIGEN_RUNTIME_NO_MALLOC
178 inline bool is_malloc_allowed_impl(
bool update,
bool new_value =
false)
180 static bool value =
true;
185 inline bool is_malloc_allowed() {
return is_malloc_allowed_impl(
false); }
186 inline bool set_is_malloc_allowed(
bool new_value) {
return is_malloc_allowed_impl(
true, new_value); }
187 inline void check_that_malloc_is_allowed()
189 eigen_assert(is_malloc_allowed() &&
"heap allocation is forbidden (EIGEN_RUNTIME_NO_MALLOC is defined and g_is_malloc_allowed is false)");
192 inline void check_that_malloc_is_allowed()
199 inline void* aligned_malloc(
size_t size)
201 check_that_malloc_is_allowed();
205 result = std::malloc(size);
206 #elif EIGEN_MALLOC_ALREADY_ALIGNED
207 result = std::malloc(size);
208 #elif EIGEN_HAS_POSIX_MEMALIGN
209 if(posix_memalign(&result, 16, size)) result = 0;
210 #elif EIGEN_HAS_MM_MALLOC
211 result = _mm_malloc(size, 16);
212 #elif defined(_MSC_VER) && (!defined(_WIN32_WCE))
213 result = _aligned_malloc(size, 16);
215 result = handmade_aligned_malloc(size);
219 throw_std_bad_alloc();
225 inline void aligned_free(
void *ptr)
229 #elif EIGEN_MALLOC_ALREADY_ALIGNED
231 #elif EIGEN_HAS_POSIX_MEMALIGN
233 #elif EIGEN_HAS_MM_MALLOC
235 #elif defined(_MSC_VER) && (!defined(_WIN32_WCE))
238 handmade_aligned_free(ptr);
247 inline void* aligned_realloc(
void *ptr,
size_t new_size,
size_t old_size)
249 EIGEN_UNUSED_VARIABLE(old_size);
253 result = std::realloc(ptr,new_size);
254 #elif EIGEN_MALLOC_ALREADY_ALIGNED
255 result = std::realloc(ptr,new_size);
256 #elif EIGEN_HAS_POSIX_MEMALIGN
257 result = generic_aligned_realloc(ptr,new_size,old_size);
258 #elif EIGEN_HAS_MM_MALLOC
262 #if defined(_MSC_VER) && defined(_mm_free)
263 result = _aligned_realloc(ptr,new_size,16);
265 result = generic_aligned_realloc(ptr,new_size,old_size);
267 #elif defined(_MSC_VER)
268 result = _aligned_realloc(ptr,new_size,16);
270 result = handmade_aligned_realloc(ptr,new_size,old_size);
273 if (!result && new_size)
274 throw_std_bad_alloc();
286 template<
bool Align>
inline void* conditional_aligned_malloc(
size_t size)
288 return aligned_malloc(size);
291 template<>
inline void* conditional_aligned_malloc<false>(
size_t size)
293 check_that_malloc_is_allowed();
295 void *result = std::malloc(size);
297 throw_std_bad_alloc();
302 template<
bool Align>
inline void conditional_aligned_free(
void *ptr)
307 template<>
inline void conditional_aligned_free<false>(
void *ptr)
312 template<
bool Align>
inline void* conditional_aligned_realloc(
void* ptr,
size_t new_size,
size_t old_size)
314 return aligned_realloc(ptr, new_size, old_size);
317 template<>
inline void* conditional_aligned_realloc<false>(
void* ptr,
size_t new_size, size_t)
319 return std::realloc(ptr, new_size);
329 template<
typename T>
inline T* construct_elements_of_array(T *ptr,
size_t size)
331 for (
size_t i=0; i < size; ++i) ::
new (ptr + i) T;
338 template<
typename T>
inline void destruct_elements_of_array(T *ptr,
size_t size)
342 while(size) ptr[--size].~T();
350 EIGEN_ALWAYS_INLINE
void check_size_for_overflow(
size_t size)
352 if(size >
size_t(-1) /
sizeof(T))
353 throw_std_bad_alloc();
360 template<
typename T>
inline T* aligned_new(
size_t size)
362 check_size_for_overflow<T>(size);
363 T *result =
reinterpret_cast<T*
>(aligned_malloc(
sizeof(T)*size));
364 return construct_elements_of_array(result, size);
367 template<
typename T,
bool Align>
inline T* conditional_aligned_new(
size_t size)
369 check_size_for_overflow<T>(size);
370 T *result =
reinterpret_cast<T*
>(conditional_aligned_malloc<Align>(
sizeof(T)*size));
371 return construct_elements_of_array(result, size);
377 template<
typename T>
inline void aligned_delete(T *ptr,
size_t size)
379 destruct_elements_of_array<T>(ptr, size);
386 template<
typename T,
bool Align>
inline void conditional_aligned_delete(T *ptr,
size_t size)
388 destruct_elements_of_array<T>(ptr, size);
389 conditional_aligned_free<Align>(ptr);
392 template<
typename T,
bool Align>
inline T* conditional_aligned_realloc_new(T* pts,
size_t new_size,
size_t old_size)
394 check_size_for_overflow<T>(new_size);
395 check_size_for_overflow<T>(old_size);
396 if(new_size < old_size)
397 destruct_elements_of_array(pts+new_size, old_size-new_size);
398 T *result =
reinterpret_cast<T*
>(conditional_aligned_realloc<Align>(
reinterpret_cast<void*
>(pts),
sizeof(T)*new_size,
sizeof(T)*old_size));
399 if(new_size > old_size)
400 construct_elements_of_array(result+old_size, new_size-old_size);
405 template<
typename T,
bool Align>
inline T* conditional_aligned_new_auto(
size_t size)
407 check_size_for_overflow<T>(size);
408 T *result =
reinterpret_cast<T*
>(conditional_aligned_malloc<Align>(
sizeof(T)*size));
409 if(NumTraits<T>::RequireInitialization)
410 construct_elements_of_array(result, size);
414 template<
typename T,
bool Align>
inline T* conditional_aligned_realloc_new_auto(T* pts,
size_t new_size,
size_t old_size)
416 check_size_for_overflow<T>(new_size);
417 check_size_for_overflow<T>(old_size);
418 if(NumTraits<T>::RequireInitialization && (new_size < old_size))
419 destruct_elements_of_array(pts+new_size, old_size-new_size);
420 T *result =
reinterpret_cast<T*
>(conditional_aligned_realloc<Align>(
reinterpret_cast<void*
>(pts),
sizeof(T)*new_size,
sizeof(T)*old_size));
421 if(NumTraits<T>::RequireInitialization && (new_size > old_size))
422 construct_elements_of_array(result+old_size, new_size-old_size);
426 template<
typename T,
bool Align>
inline void conditional_aligned_delete_auto(T *ptr,
size_t size)
428 if(NumTraits<T>::RequireInitialization)
429 destruct_elements_of_array<T>(ptr, size);
430 conditional_aligned_free<Align>(ptr);
451 template<
typename Scalar,
typename Index>
452 static inline Index first_aligned(
const Scalar* array, Index size)
455 enum { PacketSize = packet_traits<Scalar>::size,
456 PacketAlignedMask = PacketSize-1
465 else if(
size_t(array) & (
sizeof(Scalar)-1))
473 return std::min<Index>( (PacketSize - (Index((
size_t(array)/
sizeof(Scalar))) & PacketAlignedMask))
474 & PacketAlignedMask, size);
481 template<
typename T,
bool UseMemcpy>
struct smart_copy_helper;
483 template<
typename T>
void smart_copy(
const T* start,
const T* end, T* target)
485 smart_copy_helper<T,!NumTraits<T>::RequireInitialization>::run(start, end, target);
488 template<
typename T>
struct smart_copy_helper<T,true> {
489 static inline void run(
const T* start,
const T* end, T* target)
490 { memcpy(target, start, std::ptrdiff_t(end)-std::ptrdiff_t(start)); }
493 template<
typename T>
struct smart_copy_helper<T,false> {
494 static inline void run(
const T* start,
const T* end, T* target)
495 { std::copy(start, end, target); }
506 #if (defined __linux__)
507 #define EIGEN_ALLOCA alloca
508 #elif defined(_MSC_VER)
509 #define EIGEN_ALLOCA _alloca
515 template<
typename T>
class aligned_stack_memory_handler
524 aligned_stack_memory_handler(T* ptr,
size_t size,
bool dealloc)
525 : m_ptr(ptr), m_size(size), m_deallocate(dealloc)
527 if(NumTraits<T>::RequireInitialization && m_ptr)
528 Eigen::internal::construct_elements_of_array(m_ptr, size);
530 ~aligned_stack_memory_handler()
532 if(NumTraits<T>::RequireInitialization && m_ptr)
533 Eigen::internal::destruct_elements_of_array<T>(m_ptr, m_size);
535 Eigen::internal::aligned_free(m_ptr);
563 #define EIGEN_ALIGNED_ALLOCA(SIZE) reinterpret_cast<void*>((reinterpret_cast<size_t>(EIGEN_ALLOCA(SIZE+16)) & ~(size_t(15))) + 16)
565 #define EIGEN_ALIGNED_ALLOCA EIGEN_ALLOCA
568 #define ei_declare_aligned_stack_constructed_variable(TYPE,NAME,SIZE,BUFFER) \
569 Eigen::internal::check_size_for_overflow<TYPE>(SIZE); \
570 TYPE* NAME = (BUFFER)!=0 ? (BUFFER) \
571 : reinterpret_cast<TYPE*>( \
572 (sizeof(TYPE)*SIZE<=EIGEN_STACK_ALLOCATION_LIMIT) ? EIGEN_ALIGNED_ALLOCA(sizeof(TYPE)*SIZE) \
573 : Eigen::internal::aligned_malloc(sizeof(TYPE)*SIZE) ); \
574 Eigen::internal::aligned_stack_memory_handler<TYPE> EIGEN_CAT(NAME,_stack_memory_destructor)((BUFFER)==0 ? NAME : 0,SIZE,sizeof(TYPE)*SIZE>EIGEN_STACK_ALLOCATION_LIMIT)
578 #define ei_declare_aligned_stack_constructed_variable(TYPE,NAME,SIZE,BUFFER) \
579 Eigen::internal::check_size_for_overflow<TYPE>(SIZE); \
580 TYPE* NAME = (BUFFER)!=0 ? BUFFER : reinterpret_cast<TYPE*>(Eigen::internal::aligned_malloc(sizeof(TYPE)*SIZE)); \
581 Eigen::internal::aligned_stack_memory_handler<TYPE> EIGEN_CAT(NAME,_stack_memory_destructor)((BUFFER)==0 ? NAME : 0,SIZE,true)
591 #ifdef EIGEN_EXCEPTIONS
592 #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
593 void* operator new(size_t size, const std::nothrow_t&) throw() { \
594 try { return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); } \
595 catch (...) { return 0; } \
599 #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
600 void* operator new(size_t size, const std::nothrow_t&) throw() { \
601 return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \
605 #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \
606 void *operator new(size_t size) { \
607 return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \
609 void *operator new[](size_t size) { \
610 return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \
612 void operator delete(void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
613 void operator delete[](void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
617 static void *operator new(size_t size, void *ptr) { return ::operator new(size,ptr); } \
618 void operator delete(void * memory, void *ptr) throw() { return ::operator delete(memory,ptr); } \
620 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
621 void operator delete(void *ptr, const std::nothrow_t&) throw() { \
622 Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); \
624 typedef void eigen_aligned_operator_new_marker_type;
626 #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
629 #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(true)
630 #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar,Size) \
631 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(bool(((Size)!=Eigen::Dynamic) && ((sizeof(Scalar)*(Size))%16==0)))
655 typedef size_t size_type;
656 typedef std::ptrdiff_t difference_type;
658 typedef const T* const_pointer;
659 typedef T& reference;
660 typedef const T& const_reference;
661 typedef T value_type;
669 pointer address( reference value )
const
674 const_pointer address( const_reference value )
const
696 size_type max_size()
const
698 return (std::numeric_limits<size_type>::max)();
701 pointer allocate( size_type num,
const void* hint = 0 )
703 EIGEN_UNUSED_VARIABLE(hint);
704 internal::check_size_for_overflow<T>(num);
705 return static_cast<pointer
>( internal::aligned_malloc( num *
sizeof(T) ) );
708 void construct( pointer p,
const T& value )
710 ::new( p ) T( value );
714 #if (__cplusplus >= 201103L)
715 template<
typename... Args>
716 void construct(pointer p, Args&&... args)
718 ::new(p) T(std::forward<Args>(args)...);
722 void destroy( pointer p )
727 void deallocate( pointer p, size_type )
729 internal::aligned_free( p );
741 #if !defined(EIGEN_NO_CPUID)
742 # if defined(__GNUC__) && ( defined(__i386__) || defined(__x86_64__) )
743 # if defined(__PIC__) && defined(__i386__)
745 # define EIGEN_CPUID(abcd,func,id) \
746 __asm__ __volatile__ ("xchgl %%ebx, %%esi;cpuid; xchgl %%ebx,%%esi": "=a" (abcd[0]), "=S" (abcd[1]), "=c" (abcd[2]), "=d" (abcd[3]) : "a" (func), "c" (id));
749 # define EIGEN_CPUID(abcd,func,id) \
750 __asm__ __volatile__ ("cpuid": "=a" (abcd[0]), "=b" (abcd[1]), "=c" (abcd[2]), "=d" (abcd[3]) : "a" (func), "c" (id) );
752 # elif defined(_MSC_VER)
753 # if (_MSC_VER > 1500) && ( defined(_M_IX86) || defined(_M_X64) )
754 # define EIGEN_CPUID(abcd,func,id) __cpuidex((int*)abcd,func,id)
763 inline bool cpuid_is_vendor(
int abcd[4],
const char* vendor)
765 return abcd[1]==(
reinterpret_cast<const int*
>(vendor))[0] && abcd[3]==(
reinterpret_cast<const int*
>(vendor))[1] && abcd[2]==(
reinterpret_cast<const int*
>(vendor))[2];
768 inline void queryCacheSizes_intel_direct(
int& l1,
int& l2,
int& l3)
775 abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;
776 EIGEN_CPUID(abcd,0x4,cache_id);
777 cache_type = (abcd[0] & 0x0F) >> 0;
778 if(cache_type==1||cache_type==3)
780 int cache_level = (abcd[0] & 0xE0) >> 5;
781 int ways = (abcd[1] & 0xFFC00000) >> 22;
782 int partitions = (abcd[1] & 0x003FF000) >> 12;
783 int line_size = (abcd[1] & 0x00000FFF) >> 0;
784 int sets = (abcd[2]);
786 int cache_size = (ways+1) * (partitions+1) * (line_size+1) * (sets+1);
790 case 1: l1 = cache_size;
break;
791 case 2: l2 = cache_size;
break;
792 case 3: l3 = cache_size;
break;
797 }
while(cache_type>0 && cache_id<16);
800 inline void queryCacheSizes_intel_codes(
int& l1,
int& l2,
int& l3)
803 abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;
805 EIGEN_CPUID(abcd,0x00000002,0);
806 unsigned char * bytes =
reinterpret_cast<unsigned char *
>(abcd)+2;
807 bool check_for_p2_core2 =
false;
808 for(
int i=0; i<14; ++i)
812 case 0x0A: l1 = 8;
break;
813 case 0x0C: l1 = 16;
break;
814 case 0x0E: l1 = 24;
break;
815 case 0x10: l1 = 16;
break;
816 case 0x15: l1 = 16;
break;
817 case 0x2C: l1 = 32;
break;
818 case 0x30: l1 = 32;
break;
819 case 0x60: l1 = 16;
break;
820 case 0x66: l1 = 8;
break;
821 case 0x67: l1 = 16;
break;
822 case 0x68: l1 = 32;
break;
823 case 0x1A: l2 = 96;
break;
824 case 0x22: l3 = 512;
break;
825 case 0x23: l3 = 1024;
break;
826 case 0x25: l3 = 2048;
break;
827 case 0x29: l3 = 4096;
break;
828 case 0x39: l2 = 128;
break;
829 case 0x3A: l2 = 192;
break;
830 case 0x3B: l2 = 128;
break;
831 case 0x3C: l2 = 256;
break;
832 case 0x3D: l2 = 384;
break;
833 case 0x3E: l2 = 512;
break;
834 case 0x40: l2 = 0;
break;
835 case 0x41: l2 = 128;
break;
836 case 0x42: l2 = 256;
break;
837 case 0x43: l2 = 512;
break;
838 case 0x44: l2 = 1024;
break;
839 case 0x45: l2 = 2048;
break;
840 case 0x46: l3 = 4096;
break;
841 case 0x47: l3 = 8192;
break;
842 case 0x48: l2 = 3072;
break;
843 case 0x49:
if(l2!=0) l3 = 4096;
else {check_for_p2_core2=
true; l3 = l2 = 4096;}
break;
844 case 0x4A: l3 = 6144;
break;
845 case 0x4B: l3 = 8192;
break;
846 case 0x4C: l3 = 12288;
break;
847 case 0x4D: l3 = 16384;
break;
848 case 0x4E: l2 = 6144;
break;
849 case 0x78: l2 = 1024;
break;
850 case 0x79: l2 = 128;
break;
851 case 0x7A: l2 = 256;
break;
852 case 0x7B: l2 = 512;
break;
853 case 0x7C: l2 = 1024;
break;
854 case 0x7D: l2 = 2048;
break;
855 case 0x7E: l2 = 256;
break;
856 case 0x7F: l2 = 512;
break;
857 case 0x80: l2 = 512;
break;
858 case 0x81: l2 = 128;
break;
859 case 0x82: l2 = 256;
break;
860 case 0x83: l2 = 512;
break;
861 case 0x84: l2 = 1024;
break;
862 case 0x85: l2 = 2048;
break;
863 case 0x86: l2 = 512;
break;
864 case 0x87: l2 = 1024;
break;
865 case 0x88: l3 = 2048;
break;
866 case 0x89: l3 = 4096;
break;
867 case 0x8A: l3 = 8192;
break;
868 case 0x8D: l3 = 3072;
break;
873 if(check_for_p2_core2 && l2 == l3)
880 inline void queryCacheSizes_intel(
int& l1,
int& l2,
int& l3,
int max_std_funcs)
883 queryCacheSizes_intel_direct(l1,l2,l3);
885 queryCacheSizes_intel_codes(l1,l2,l3);
888 inline void queryCacheSizes_amd(
int& l1,
int& l2,
int& l3)
891 abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;
892 EIGEN_CPUID(abcd,0x80000005,0);
893 l1 = (abcd[2] >> 24) * 1024;
894 abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;
895 EIGEN_CPUID(abcd,0x80000006,0);
896 l2 = (abcd[2] >> 16) * 1024;
897 l3 = ((abcd[3] & 0xFFFC000) >> 18) * 512 * 1024;
903 inline void queryCacheSizes(
int& l1,
int& l2,
int& l3)
909 EIGEN_CPUID(abcd,0x0,0);
910 int max_std_funcs = abcd[1];
911 if(cpuid_is_vendor(abcd,
"GenuineIntel"))
912 queryCacheSizes_intel(l1,l2,l3,max_std_funcs);
913 else if(cpuid_is_vendor(abcd,
"AuthenticAMD") || cpuid_is_vendor(abcd,
"AMDisbetter!"))
914 queryCacheSizes_amd(l1,l2,l3);
917 queryCacheSizes_intel(l1,l2,l3,max_std_funcs);
937 inline int queryL1CacheSize()
940 queryCacheSizes(l1,l2,l3);
946 inline int queryTopLevelCacheSize()
948 int l1, l2(-1), l3(-1);
949 queryCacheSizes(l1,l2,l3);
950 return (std::max)(l2,l3);
957 #endif // EIGEN_MEMORY_H