aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Eigen/Core4
-rw-r--r--Eigen/src/Core/util/Macros.h13
-rw-r--r--Eigen/src/Core/util/Memory.h8
-rw-r--r--test/dynalloc.cpp2
-rw-r--r--test/unalignedassert.cpp6
5 files changed, 22 insertions, 11 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); \
diff --git a/test/dynalloc.cpp b/test/dynalloc.cpp
index c0fcdde3d..df87ff563 100644
--- a/test/dynalloc.cpp
+++ b/test/dynalloc.cpp
@@ -24,7 +24,7 @@
#include "main.h"
-#if EIGEN_ARCH_WANTS_ALIGNMENT
+#if EIGEN_ALIGN
#define ALIGNMENT 16
#else
#define ALIGNMENT 1
diff --git a/test/unalignedassert.cpp b/test/unalignedassert.cpp
index 9447ea85c..44404e4a5 100644
--- a/test/unalignedassert.cpp
+++ b/test/unalignedassert.cpp
@@ -92,7 +92,7 @@ void check_unalignedassert_good()
delete[] y;
}
-#if EIGEN_ARCH_WANTS_ALIGNMENT
+#if EIGEN_ALIGN
template<typename T>
void check_unalignedassert_bad()
{
@@ -109,7 +109,7 @@ void unalignedassert()
check_unalignedassert_good<Good1>();
check_unalignedassert_good<Good2>();
check_unalignedassert_good<Good3>();
-#if EIGEN_ARCH_WANTS_ALIGNMENT
+#if EIGEN_ALIGN
VERIFY_RAISES_ASSERT(check_unalignedassert_bad<Bad4>());
VERIFY_RAISES_ASSERT(check_unalignedassert_bad<Bad5>());
VERIFY_RAISES_ASSERT(check_unalignedassert_bad<Bad6>());
@@ -120,7 +120,7 @@ void unalignedassert()
check_unalignedassert_good<Good9>();
check_unalignedassert_good<Depends<true> >();
-#if EIGEN_ARCH_WANTS_ALIGNMENT
+#if EIGEN_ALIGN
VERIFY_RAISES_ASSERT(check_unalignedassert_bad<Depends<false> >());
#endif
}