Lines 1-12
Link Here
|
1 |
// This file is part of Eigen, a lightweight C++ template library |
1 |
// This file is part of Eigen, a lightweight C++ template library |
2 |
// for linear algebra. |
2 |
// for linear algebra. |
3 |
// |
3 |
// |
4 |
// Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr> |
4 |
// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr> |
5 |
// Copyright (C) 2008-2009 Benoit Jacob <jacob.benoit.1@gmail.com> |
5 |
// Copyright (C) 2008-2009 Benoit Jacob <jacob.benoit.1@gmail.com> |
6 |
// Copyright (C) 2009 Kenneth Riddile <kfriddile@yahoo.com> |
6 |
// Copyright (C) 2009 Kenneth Riddile <kfriddile@yahoo.com> |
7 |
// Copyright (C) 2010 Hauke Heibel <hauke.heibel@gmail.com> |
7 |
// Copyright (C) 2010 Hauke Heibel <hauke.heibel@gmail.com> |
8 |
// Copyright (C) 2010 Thomas Capricelli <orzel@freehackers.org> |
8 |
// Copyright (C) 2010 Thomas Capricelli <orzel@freehackers.org> |
9 |
// Copyright (C) 2013 Pavel Holoborodko <pavel@holoborodko.com> |
9 |
// Copyright (C) 2013 Pavel Holoborodko <pavel@holoborodko.com> |
10 |
// |
10 |
// |
11 |
// This Source Code Form is subject to the terms of the Mozilla |
11 |
// This Source Code Form is subject to the terms of the Mozilla |
12 |
// Public License v. 2.0. If a copy of the MPL was not distributed |
12 |
// Public License v. 2.0. If a copy of the MPL was not distributed |
Lines 27-60
Link Here
|
27 |
// On 64-bit systems, glibc's malloc returns 16-byte-aligned pointers, see: |
27 |
// On 64-bit systems, glibc's malloc returns 16-byte-aligned pointers, see: |
28 |
// http://www.gnu.org/s/libc/manual/html_node/Aligned-Memory-Blocks.html |
28 |
// http://www.gnu.org/s/libc/manual/html_node/Aligned-Memory-Blocks.html |
29 |
// This is true at least since glibc 2.8. |
29 |
// This is true at least since glibc 2.8. |
30 |
// This leaves the question how to detect 64-bit. According to this document, |
30 |
// This leaves the question how to detect 64-bit. According to this document, |
31 |
// http://gcc.fyxm.net/summit/2003/Porting%20to%2064%20bit.pdf |
31 |
// http://gcc.fyxm.net/summit/2003/Porting%20to%2064%20bit.pdf |
32 |
// page 114, "[The] LP64 model [...] is used by all 64-bit UNIX ports" so it's indeed |
32 |
// page 114, "[The] LP64 model [...] is used by all 64-bit UNIX ports" so it's indeed |
33 |
// quite safe, at least within the context of glibc, to equate 64-bit with LP64. |
33 |
// quite safe, at least within the context of glibc, to equate 64-bit with LP64. |
34 |
#if defined(__GLIBC__) && ((__GLIBC__>=2 && __GLIBC_MINOR__ >= 8) || __GLIBC__>2) \ |
34 |
#if defined(__GLIBC__) && ((__GLIBC__>=2 && __GLIBC_MINOR__ >= 8) || __GLIBC__>2) \ |
35 |
&& defined(__LP64__) && ! defined( __SANITIZE_ADDRESS__ ) && (EIGEN_ALIGN_BYTES == 16) |
35 |
&& defined(__LP64__) && ! defined( __SANITIZE_ADDRESS__ ) && (EIGEN_MAX_ALIGN_BYTES == 16) |
36 |
#define EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED 1 |
36 |
#define EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED 1 |
37 |
#else |
37 |
#else |
38 |
#define EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED 0 |
38 |
#define EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED 0 |
39 |
#endif |
39 |
#endif |
40 |
|
40 |
|
41 |
// FreeBSD 6 seems to have 16-byte aligned malloc |
41 |
// FreeBSD 6 seems to have 16-byte aligned malloc |
42 |
// See http://svn.freebsd.org/viewvc/base/stable/6/lib/libc/stdlib/malloc.c?view=markup |
42 |
// See http://svn.freebsd.org/viewvc/base/stable/6/lib/libc/stdlib/malloc.c?view=markup |
43 |
// FreeBSD 7 seems to have 16-byte aligned malloc except on ARM and MIPS architectures |
43 |
// FreeBSD 7 seems to have 16-byte aligned malloc except on ARM and MIPS architectures |
44 |
// See http://svn.freebsd.org/viewvc/base/stable/7/lib/libc/stdlib/malloc.c?view=markup |
44 |
// See http://svn.freebsd.org/viewvc/base/stable/7/lib/libc/stdlib/malloc.c?view=markup |
45 |
#if defined(__FreeBSD__) && !(EIGEN_ARCH_ARM || EIGEN_ARCH_MIPS) && (EIGEN_ALIGN_BYTES == 16) |
45 |
#if defined(__FreeBSD__) && !(EIGEN_ARCH_ARM || EIGEN_ARCH_MIPS) && (EIGEN_MAX_ALIGN_BYTES == 16) |
46 |
#define EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED 1 |
46 |
#define EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED 1 |
47 |
#else |
47 |
#else |
48 |
#define EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED 0 |
48 |
#define EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED 0 |
49 |
#endif |
49 |
#endif |
50 |
|
50 |
|
51 |
#if (EIGEN_OS_MAC && (EIGEN_ALIGN_BYTES == 16)) \ |
51 |
#if (EIGEN_OS_MAC && (EIGEN_MAX_ALIGN_BYTES == 16)) \ |
52 |
|| (EIGEN_OS_WIN64 && (EIGEN_ALIGN_BYTES == 16)) \ |
52 |
|| (EIGEN_OS_WIN64 && (EIGEN_MAX_ALIGN_BYTES == 16)) \ |
53 |
|| EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED \ |
53 |
|| EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED \ |
54 |
|| EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED |
54 |
|| EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED |
55 |
#define EIGEN_MALLOC_ALREADY_ALIGNED 1 |
55 |
#define EIGEN_MALLOC_ALREADY_ALIGNED 1 |
56 |
#else |
56 |
#else |
57 |
#define EIGEN_MALLOC_ALREADY_ALIGNED 0 |
57 |
#define EIGEN_MALLOC_ALREADY_ALIGNED 0 |
58 |
#endif |
58 |
#endif |
59 |
|
59 |
|
60 |
#endif |
60 |
#endif |
Lines 102-120
inline void throw_std_bad_alloc()
Link Here
|
102 |
|
102 |
|
103 |
/* ----- Hand made implementations of aligned malloc/free and realloc ----- */ |
103 |
/* ----- Hand made implementations of aligned malloc/free and realloc ----- */ |
104 |
|
104 |
|
105 |
/** \internal Like malloc, but the returned pointer is guaranteed to be 16-byte aligned. |
105 |
/** \internal Like malloc, but the returned pointer is guaranteed to be 16-byte aligned. |
106 |
* Fast, but wastes 16 additional bytes of memory. Does not throw any exception. |
106 |
* Fast, but wastes 16 additional bytes of memory. Does not throw any exception. |
107 |
*/ |
107 |
*/ |
108 |
inline void* handmade_aligned_malloc(std::size_t size) |
108 |
inline void* handmade_aligned_malloc(std::size_t size) |
109 |
{ |
109 |
{ |
110 |
void *original = std::malloc(size+EIGEN_ALIGN_BYTES); |
110 |
void *original = std::malloc(size+EIGEN_MAX_ALIGN_BYTES); |
111 |
if (original == 0) return 0; |
111 |
if (original == 0) return 0; |
112 |
void *aligned = reinterpret_cast<void*>((reinterpret_cast<std::size_t>(original) & ~(std::size_t(EIGEN_ALIGN_BYTES-1))) + EIGEN_ALIGN_BYTES); |
112 |
void *aligned = reinterpret_cast<void*>((reinterpret_cast<std::size_t>(original) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES-1))) + EIGEN_MAX_ALIGN_BYTES); |
113 |
*(reinterpret_cast<void**>(aligned) - 1) = original; |
113 |
*(reinterpret_cast<void**>(aligned) - 1) = original; |
114 |
return aligned; |
114 |
return aligned; |
115 |
} |
115 |
} |
116 |
|
116 |
|
117 |
/** \internal Frees memory allocated with handmade_aligned_malloc */ |
117 |
/** \internal Frees memory allocated with handmade_aligned_malloc */ |
118 |
inline void handmade_aligned_free(void *ptr) |
118 |
inline void handmade_aligned_free(void *ptr) |
119 |
{ |
119 |
{ |
120 |
if (ptr) std::free(*(reinterpret_cast<void**>(ptr) - 1)); |
120 |
if (ptr) std::free(*(reinterpret_cast<void**>(ptr) - 1)); |
Lines 125-143
inline void handmade_aligned_free(void *
Link Here
|
125 |
* Since we know that our handmade version is based on std::realloc |
125 |
* Since we know that our handmade version is based on std::realloc |
126 |
* we can use std::realloc to implement efficient reallocation. |
126 |
* we can use std::realloc to implement efficient reallocation. |
127 |
*/ |
127 |
*/ |
128 |
inline void* handmade_aligned_realloc(void* ptr, std::size_t size, std::size_t = 0) |
128 |
inline void* handmade_aligned_realloc(void* ptr, std::size_t size, std::size_t = 0) |
129 |
{ |
129 |
{ |
130 |
if (ptr == 0) return handmade_aligned_malloc(size); |
130 |
if (ptr == 0) return handmade_aligned_malloc(size); |
131 |
void *original = *(reinterpret_cast<void**>(ptr) - 1); |
131 |
void *original = *(reinterpret_cast<void**>(ptr) - 1); |
132 |
std::ptrdiff_t previous_offset = static_cast<char *>(ptr)-static_cast<char *>(original); |
132 |
std::ptrdiff_t previous_offset = static_cast<char *>(ptr)-static_cast<char *>(original); |
133 |
original = std::realloc(original,size+EIGEN_ALIGN_BYTES); |
133 |
original = std::realloc(original,size+EIGEN_MAX_ALIGN_BYTES); |
134 |
if (original == 0) return 0; |
134 |
if (original == 0) return 0; |
135 |
void *aligned = reinterpret_cast<void*>((reinterpret_cast<std::size_t>(original) & ~(std::size_t(EIGEN_ALIGN_BYTES-1))) + EIGEN_ALIGN_BYTES); |
135 |
void *aligned = reinterpret_cast<void*>((reinterpret_cast<std::size_t>(original) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES-1))) + EIGEN_MAX_ALIGN_BYTES); |
136 |
void *previous_aligned = static_cast<char *>(original)+previous_offset; |
136 |
void *previous_aligned = static_cast<char *>(original)+previous_offset; |
137 |
if(aligned!=previous_aligned) |
137 |
if(aligned!=previous_aligned) |
138 |
std::memmove(aligned, previous_aligned, size); |
138 |
std::memmove(aligned, previous_aligned, size); |
139 |
|
139 |
|
140 |
*(reinterpret_cast<void**>(aligned) - 1) = original; |
140 |
*(reinterpret_cast<void**>(aligned) - 1) = original; |
141 |
return aligned; |
141 |
return aligned; |
142 |
} |
142 |
} |
143 |
|
143 |
|
Lines 213-252
EIGEN_DEVICE_FUNC inline void check_that
Link Here
|
213 |
/** \internal Allocates \a size bytes. The returned pointer is guaranteed to have 16 or 32 bytes alignment depending on the requirements. |
213 |
/** \internal Allocates \a size bytes. The returned pointer is guaranteed to have 16 or 32 bytes alignment depending on the requirements. |
214 |
* On allocation error, the returned pointer is null, and std::bad_alloc is thrown. |
214 |
* On allocation error, the returned pointer is null, and std::bad_alloc is thrown. |
215 |
*/ |
215 |
*/ |
216 |
EIGEN_DEVICE_FUNC inline void* aligned_malloc(size_t size) |
216 |
EIGEN_DEVICE_FUNC inline void* aligned_malloc(size_t size) |
217 |
{ |
217 |
{ |
218 |
check_that_malloc_is_allowed(); |
218 |
check_that_malloc_is_allowed(); |
219 |
|
219 |
|
220 |
void *result; |
220 |
void *result; |
221 |
#if !EIGEN_ALIGN |
221 |
#if EIGEN_MAX_ALIGN_BYTES==0 |
222 |
result = std::malloc(size); |
222 |
result = std::malloc(size); |
223 |
#elif EIGEN_MALLOC_ALREADY_ALIGNED |
223 |
#elif EIGEN_MALLOC_ALREADY_ALIGNED |
224 |
result = std::malloc(size); |
224 |
result = std::malloc(size); |
225 |
#elif EIGEN_HAS_POSIX_MEMALIGN |
225 |
#elif EIGEN_HAS_POSIX_MEMALIGN |
226 |
if(posix_memalign(&result, EIGEN_ALIGN_BYTES, size)) result = 0; |
226 |
if(posix_memalign(&result, EIGEN_MAX_ALIGN_BYTES, size)) result = 0; |
227 |
#elif EIGEN_HAS_MM_MALLOC |
227 |
#elif EIGEN_HAS_MM_MALLOC |
228 |
result = _mm_malloc(size, EIGEN_ALIGN_BYTES); |
228 |
result = _mm_malloc(size, EIGEN_MAX_ALIGN_BYTES); |
229 |
#elif EIGEN_OS_WIN_STRICT |
229 |
#elif EIGEN_OS_WIN_STRICT |
230 |
result = _aligned_malloc(size, EIGEN_ALIGN_BYTES); |
230 |
result = _aligned_malloc(size, EIGEN_MAX_ALIGN_BYTES); |
231 |
#else |
231 |
#else |
232 |
result = handmade_aligned_malloc(size); |
232 |
result = handmade_aligned_malloc(size); |
233 |
#endif |
233 |
#endif |
234 |
|
234 |
|
235 |
if(!result && size) |
235 |
if(!result && size) |
236 |
throw_std_bad_alloc(); |
236 |
throw_std_bad_alloc(); |
237 |
|
237 |
|
238 |
return result; |
238 |
return result; |
239 |
} |
239 |
} |
240 |
|
240 |
|
241 |
/** \internal Frees memory allocated with aligned_malloc. */ |
241 |
/** \internal Frees memory allocated with aligned_malloc. */ |
242 |
EIGEN_DEVICE_FUNC inline void aligned_free(void *ptr) |
242 |
EIGEN_DEVICE_FUNC inline void aligned_free(void *ptr) |
243 |
{ |
243 |
{ |
244 |
#if !EIGEN_ALIGN |
244 |
#if EIGEN_MAX_ALIGN_BYTES==0 |
245 |
std::free(ptr); |
245 |
std::free(ptr); |
246 |
#elif EIGEN_MALLOC_ALREADY_ALIGNED |
246 |
#elif EIGEN_MALLOC_ALREADY_ALIGNED |
247 |
std::free(ptr); |
247 |
std::free(ptr); |
248 |
#elif EIGEN_HAS_POSIX_MEMALIGN |
248 |
#elif EIGEN_HAS_POSIX_MEMALIGN |
249 |
std::free(ptr); |
249 |
std::free(ptr); |
250 |
#elif EIGEN_HAS_MM_MALLOC |
250 |
#elif EIGEN_HAS_MM_MALLOC |
251 |
_mm_free(ptr); |
251 |
_mm_free(ptr); |
252 |
#elif EIGEN_OS_WIN_STRICT |
252 |
#elif EIGEN_OS_WIN_STRICT |
Lines 261-293
EIGEN_DEVICE_FUNC inline void aligned_fr
Link Here
|
261 |
* \brief Reallocates an aligned block of memory. |
261 |
* \brief Reallocates an aligned block of memory. |
262 |
* \throws std::bad_alloc on allocation failure |
262 |
* \throws std::bad_alloc on allocation failure |
263 |
**/ |
263 |
**/ |
264 |
inline void* aligned_realloc(void *ptr, size_t new_size, size_t old_size) |
264 |
inline void* aligned_realloc(void *ptr, size_t new_size, size_t old_size) |
265 |
{ |
265 |
{ |
266 |
EIGEN_UNUSED_VARIABLE(old_size); |
266 |
EIGEN_UNUSED_VARIABLE(old_size); |
267 |
|
267 |
|
268 |
void *result; |
268 |
void *result; |
269 |
#if !EIGEN_ALIGN |
269 |
#if EIGEN_MAX_ALIGN_BYTES==0 |
270 |
result = std::realloc(ptr,new_size); |
270 |
result = std::realloc(ptr,new_size); |
271 |
#elif EIGEN_MALLOC_ALREADY_ALIGNED |
271 |
#elif EIGEN_MALLOC_ALREADY_ALIGNED |
272 |
result = std::realloc(ptr,new_size); |
272 |
result = std::realloc(ptr,new_size); |
273 |
#elif EIGEN_HAS_POSIX_MEMALIGN |
273 |
#elif EIGEN_HAS_POSIX_MEMALIGN |
274 |
result = generic_aligned_realloc(ptr,new_size,old_size); |
274 |
result = generic_aligned_realloc(ptr,new_size,old_size); |
275 |
#elif EIGEN_HAS_MM_MALLOC |
275 |
#elif EIGEN_HAS_MM_MALLOC |
276 |
// The defined(_mm_free) is just here to verify that this MSVC version |
276 |
// The defined(_mm_free) is just here to verify that this MSVC version |
277 |
// implements _mm_malloc/_mm_free based on the corresponding _aligned_ |
277 |
// implements _mm_malloc/_mm_free based on the corresponding _aligned_ |
278 |
// functions. This may not always be the case and we just try to be safe. |
278 |
// functions. This may not always be the case and we just try to be safe. |
279 |
#if EIGEN_OS_WIN_STRICT && defined(_mm_free) |
279 |
#if EIGEN_OS_WIN_STRICT && defined(_mm_free) |
280 |
result = _aligned_realloc(ptr,new_size,EIGEN_ALIGN_BYTES); |
280 |
result = _aligned_realloc(ptr,new_size,EIGEN_MAX_ALIGN_BYTES); |
281 |
#else |
281 |
#else |
282 |
result = generic_aligned_realloc(ptr,new_size,old_size); |
282 |
result = generic_aligned_realloc(ptr,new_size,old_size); |
283 |
#endif |
283 |
#endif |
284 |
#elif EIGEN_OS_WIN_STRICT |
284 |
#elif EIGEN_OS_WIN_STRICT |
285 |
result = _aligned_realloc(ptr,new_size,EIGEN_ALIGN_BYTES); |
285 |
result = _aligned_realloc(ptr,new_size,EIGEN_MAX_ALIGN_BYTES); |
286 |
#else |
286 |
#else |
287 |
result = handmade_aligned_realloc(ptr,new_size,old_size); |
287 |
result = handmade_aligned_realloc(ptr,new_size,old_size); |
288 |
#endif |
288 |
#endif |
289 |
|
289 |
|
290 |
if (!result && new_size) |
290 |
if (!result && new_size) |
291 |
throw_std_bad_alloc(); |
291 |
throw_std_bad_alloc(); |
292 |
|
292 |
|
293 |
return result; |
293 |
return result; |
Lines 686-702
template<typename T> void swap(scoped_ar
Link Here
|
686 |
* // use data[0] to data[size-1] |
686 |
* // use data[0] to data[size-1] |
687 |
* } |
687 |
* } |
688 |
* \endcode |
688 |
* \endcode |
689 |
* The underlying stack allocation function can controlled with the EIGEN_ALLOCA preprocessor token. |
689 |
* The underlying stack allocation function can controlled with the EIGEN_ALLOCA preprocessor token. |
690 |
*/ |
690 |
*/ |
691 |
#ifdef EIGEN_ALLOCA |
691 |
#ifdef EIGEN_ALLOCA |
692 |
// We always manually re-align the result of EIGEN_ALLOCA. |
692 |
// We always manually re-align the result of EIGEN_ALLOCA. |
693 |
// If alloca is already aligned, the compiler should be smart enough to optimize away the re-alignment. |
693 |
// If alloca is already aligned, the compiler should be smart enough to optimize away the re-alignment. |
694 |
#define EIGEN_ALIGNED_ALLOCA(SIZE) reinterpret_cast<void*>((reinterpret_cast<size_t>(EIGEN_ALLOCA(SIZE+EIGEN_ALIGN_BYTES-1)) + EIGEN_ALIGN_BYTES-1) & ~(size_t(EIGEN_ALIGN_BYTES-1))) |
694 |
#define EIGEN_ALIGNED_ALLOCA(SIZE) reinterpret_cast<void*>((reinterpret_cast<size_t>(EIGEN_ALLOCA(SIZE+EIGEN_MAX_ALIGN_BYTES-1)) + EIGEN_MAX_ALIGN_BYTES-1) & ~(size_t(EIGEN_MAX_ALIGN_BYTES-1))) |
695 |
|
695 |
|
696 |
#define ei_declare_aligned_stack_constructed_variable(TYPE,NAME,SIZE,BUFFER) \ |
696 |
#define ei_declare_aligned_stack_constructed_variable(TYPE,NAME,SIZE,BUFFER) \ |
697 |
Eigen::internal::check_size_for_overflow<TYPE>(SIZE); \ |
697 |
Eigen::internal::check_size_for_overflow<TYPE>(SIZE); \ |
698 |
TYPE* NAME = (BUFFER)!=0 ? (BUFFER) \ |
698 |
TYPE* NAME = (BUFFER)!=0 ? (BUFFER) \ |
699 |
: reinterpret_cast<TYPE*>( \ |
699 |
: reinterpret_cast<TYPE*>( \ |
700 |
(sizeof(TYPE)*SIZE<=EIGEN_STACK_ALLOCATION_LIMIT) ? EIGEN_ALIGNED_ALLOCA(sizeof(TYPE)*SIZE) \ |
700 |
(sizeof(TYPE)*SIZE<=EIGEN_STACK_ALLOCATION_LIMIT) ? EIGEN_ALIGNED_ALLOCA(sizeof(TYPE)*SIZE) \ |
701 |
: Eigen::internal::aligned_malloc(sizeof(TYPE)*SIZE) ); \ |
701 |
: Eigen::internal::aligned_malloc(sizeof(TYPE)*SIZE) ); \ |
702 |
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) |
702 |
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) |
Lines 710-726
template<typename T> void swap(scoped_ar
Link Here
|
710 |
|
710 |
|
711 |
#endif |
711 |
#endif |
712 |
|
712 |
|
713 |
|
713 |
|
714 |
/***************************************************************************** |
714 |
/***************************************************************************** |
715 |
*** Implementation of EIGEN_MAKE_ALIGNED_OPERATOR_NEW [_IF] *** |
715 |
*** Implementation of EIGEN_MAKE_ALIGNED_OPERATOR_NEW [_IF] *** |
716 |
*****************************************************************************/ |
716 |
*****************************************************************************/ |
717 |
|
717 |
|
718 |
#if EIGEN_ALIGN |
718 |
#if EIGEN_MAX_ALIGN_BYTES!=0 |
719 |
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ |
719 |
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ |
720 |
void* operator new(size_t size, const std::nothrow_t&) throw() { \ |
720 |
void* operator new(size_t size, const std::nothrow_t&) throw() { \ |
721 |
EIGEN_TRY { return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); } \ |
721 |
EIGEN_TRY { return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); } \ |
722 |
EIGEN_CATCH (...) { return 0; } \ |
722 |
EIGEN_CATCH (...) { return 0; } \ |
723 |
} |
723 |
} |
724 |
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \ |
724 |
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \ |
725 |
void *operator new(size_t size) { \ |
725 |
void *operator new(size_t size) { \ |
726 |
return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \ |
726 |
return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \ |
Lines 746-762
template<typename T> void swap(scoped_ar
Link Here
|
746 |
} \ |
746 |
} \ |
747 |
typedef void eigen_aligned_operator_new_marker_type; |
747 |
typedef void eigen_aligned_operator_new_marker_type; |
748 |
#else |
748 |
#else |
749 |
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) |
749 |
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) |
750 |
#endif |
750 |
#endif |
751 |
|
751 |
|
752 |
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(true) |
752 |
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(true) |
753 |
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar,Size) \ |
753 |
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar,Size) \ |
754 |
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(bool(((Size)!=Eigen::Dynamic) && ((sizeof(Scalar)*(Size))%EIGEN_ALIGN_BYTES==0))) |
754 |
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(bool(((Size)!=Eigen::Dynamic) && ((sizeof(Scalar)*(Size))%EIGEN_MAX_ALIGN_BYTES==0))) |
755 |
|
755 |
|
756 |
/****************************************************************************/ |
756 |
/****************************************************************************/ |
757 |
|
757 |
|
758 |
/** \class aligned_allocator |
758 |
/** \class aligned_allocator |
759 |
* \ingroup Core_Module |
759 |
* \ingroup Core_Module |
760 |
* |
760 |
* |
761 |
* \brief STL compatible allocator to use with with 16 byte aligned types |
761 |
* \brief STL compatible allocator to use with with 16 byte aligned types |
762 |
* |
762 |
* |