diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2009-05-03 13:50:56 +0000 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2009-05-03 13:50:56 +0000 |
commit | 95bda5e6ab6c2bdad322bd772dc7fb9e14ca7d78 (patch) | |
tree | 4fd1e6492007da0c938b5a7fa31d1b69eb088fd5 /Eigen | |
parent | facee57b8d0f8343cb9b7d7db3ad5e454bc80915 (diff) |
let the user disable alignment altogether by #defining EIGEN_DONT_ALIGN.
Until now, the user had to edit the source code to do that.
Internally, add EIGEN_ALIGN that takes into account both EIGEN_DONT_ALIGN.and
EIGEN_ARCH_WANTS_ALIGNMENT. From now on, only EIGEN_ALIGN should be used to
test whether we want to align.
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/Core | 4 | ||||
-rw-r--r-- | Eigen/src/Core/util/Macros.h | 13 | ||||
-rw-r--r-- | Eigen/src/Core/util/Memory.h | 8 |
3 files changed, 18 insertions, 7 deletions
diff --git a/Eigen/Core b/Eigen/Core index 904c6089b..ecade0128 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -27,6 +27,10 @@ #define EIGEN_SSE2_BUT_NOT_OLD_GCC #endif +#ifdef EIGEN_DONT_ALIGN + #define EIGEN_DONT_VECTORIZE +#endif + #ifndef EIGEN_DONT_VECTORIZE #if defined (EIGEN_SSE2_BUT_NOT_OLD_GCC) || defined(EIGEN_SSE2_ON_MSVC_2008_OR_LATER) #define EIGEN_VECTORIZE diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 55d0f2649..d3b94ebb3 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -44,16 +44,23 @@ #if (!defined(__GNUC__)) || defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__ia64__) #define EIGEN_ARCH_WANTS_ALIGNMENT 1 #else + #define EIGEN_ARCH_WANTS_ALIGNMENT 0 +#endif + +// EIGEN_ALIGN is the true test whether we want to align or not. It takes into account both the user choice to explicitly disable +// alignment (EIGEN_DONT_ALIGN) and the architecture config (EIGEN_ARCH_WANTS_ALIGNMENT). Henceforth, only EIGEN_ALIGN should be used. +#if EIGEN_ARCH_WANTS_ALIGNMENT && !defined(EIGEN_DONT_ALIGN) + #define EIGEN_ALIGN 1 +#else + #define EIGEN_ALIGN 0 #ifdef EIGEN_VECTORIZE #error Vectorization enabled, but the architecture is not listed among those for which we require 16 byte alignment. If you added vectorization for another architecture, you also need to edit this list. #endif - #define EIGEN_ARCH_WANTS_ALIGNMENT 0 #ifndef EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT #define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT #endif #endif - #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION RowMajor #else @@ -180,7 +187,7 @@ using Eigen::ei_cos; * If we made alignment depend on whether or not EIGEN_VECTORIZE is defined, it would be impossible to link * vectorized and non-vectorized code. */ -#if !EIGEN_ARCH_WANTS_ALIGNMENT +#if !EIGEN_ALIGN #define EIGEN_ALIGN_128 #elif (defined __GNUC__) #define EIGEN_ALIGN_128 __attribute__((aligned(16))) diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 934ccee4e..7309f69ed 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -74,11 +74,11 @@ inline void* ei_aligned_malloc(size_t size) #endif void *result; - #if EIGEN_HAS_POSIX_MEMALIGN && EIGEN_ARCH_WANTS_ALIGNMENT && !EIGEN_MALLOC_ALREADY_ALIGNED + #if EIGEN_HAS_POSIX_MEMALIGN && EIGEN_ALIGN && !EIGEN_MALLOC_ALREADY_ALIGNED if(posix_memalign(&result, 16, size)) result = 0; #else - #if !EIGEN_ARCH_WANTS_ALIGNMENT + #if !EIGEN_ALIGN result = malloc(size); #elif EIGEN_MALLOC_ALREADY_ALIGNED result = malloc(size); @@ -138,7 +138,7 @@ template<typename T, bool Align> inline T* ei_conditional_aligned_new(size_t siz */ inline void ei_aligned_free(void *ptr) { - #if !EIGEN_ARCH_WANTS_ALIGNMENT + #if !EIGEN_ALIGN free(ptr); #elif EIGEN_MALLOC_ALREADY_ALIGNED free(ptr); @@ -232,7 +232,7 @@ inline static int ei_alignmentOffset(const Scalar* ptr, int maxOffset) ei_aligned_stack_free(PTR,sizeof(TYPE)*SIZE);} while(0) -#if EIGEN_ARCH_WANTS_ALIGNMENT +#if EIGEN_ALIGN #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \ void *operator new(size_t size) throw() { \ return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \ |