diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-04-01 13:55:09 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-04-01 13:55:09 +0200 |
commit | 39dcd01b0ac8556d1d46d5d897bdefa82cf5d91c (patch) | |
tree | 170007b4914f95ccac26da8c7426345ca7d02184 | |
parent | 8481dc21eada115b20116b17826a761208602b02 (diff) |
bug #973: enable alignment of multiples of half-packet size (e.g., Vector6d with AVX)
-rw-r--r-- | Eigen/src/Core/DenseStorage.h | 10 | ||||
-rw-r--r-- | test/unalignedassert.cpp | 29 |
2 files changed, 33 insertions, 6 deletions
diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h index ab41641f4..8fcc83a5a 100644 --- a/Eigen/src/Core/DenseStorage.h +++ b/Eigen/src/Core/DenseStorage.h @@ -35,22 +35,22 @@ void check_static_allocation_size() } template<typename T, int Size, typename Packet = typename packet_traits<T>::type, - bool Match = bool((Size%unpacket_traits<Packet>::size)==0), - bool TryHalf = bool(int(unpacket_traits<Packet>::size) > Size) + bool Match = bool((Size%unpacket_traits<Packet>::size)==0), + bool TryHalf = bool(int(unpacket_traits<Packet>::size) > 1) && bool(int(unpacket_traits<Packet>::size) > int(unpacket_traits<typename unpacket_traits<Packet>::half>::size)) > struct compute_default_alignment { enum { value = 0 }; }; -template<typename T, int Size, typename Packet> -struct compute_default_alignment<T, Size, Packet, true, false> // Match +template<typename T, int Size, typename Packet, bool TryHalf> +struct compute_default_alignment<T, Size, Packet, true, TryHalf> // Match { enum { value = sizeof(T) * unpacket_traits<Packet>::size }; }; template<typename T, int Size, typename Packet> -struct compute_default_alignment<T, Size, Packet, false, true> +struct compute_default_alignment<T, Size, Packet, false, true> // Try-half { // current packet too large, try with an half-packet enum { value = compute_default_alignment<T, Size, typename unpacket_traits<Packet>::half>::value }; diff --git a/test/unalignedassert.cpp b/test/unalignedassert.cpp index 6f7b72167..9c6f0bc8f 100644 --- a/test/unalignedassert.cpp +++ b/test/unalignedassert.cpp @@ -9,7 +9,17 @@ #include "main.h" -typedef Matrix<float,8,1> Vector8f; +typedef Matrix<float, 6,1> Vector6f; +typedef Matrix<float, 8,1> Vector8f; +typedef Matrix<float, 12,1> Vector12f; + +typedef Matrix<double, 5,1> Vector5d; +typedef Matrix<double, 6,1> Vector6d; +typedef Matrix<double, 7,1> Vector7d; +typedef Matrix<double, 8,1> Vector8d; +typedef Matrix<double, 9,1> Vector9d; +typedef Matrix<double,10,1> Vector10d; +typedef Matrix<double,12,1> Vector12d; struct TestNew1 { @@ -85,6 +95,9 @@ void unalignedassert() construct_at_boundary<Vector2f>(4); construct_at_boundary<Vector3f>(4); construct_at_boundary<Vector4f>(16); + construct_at_boundary<Vector6f>(4); + construct_at_boundary<Vector8f>(EIGEN_ALIGN_BYTES); + construct_at_boundary<Vector12f>(16); construct_at_boundary<Matrix2f>(16); construct_at_boundary<Matrix3f>(4); construct_at_boundary<Matrix4f>(EIGEN_ALIGN_BYTES); @@ -92,6 +105,13 @@ void unalignedassert() construct_at_boundary<Vector2d>(16); construct_at_boundary<Vector3d>(4); construct_at_boundary<Vector4d>(EIGEN_ALIGN_BYTES); + construct_at_boundary<Vector5d>(4); + construct_at_boundary<Vector6d>(16); + construct_at_boundary<Vector7d>(4); + construct_at_boundary<Vector8d>(EIGEN_ALIGN_BYTES); + construct_at_boundary<Vector9d>(4); + construct_at_boundary<Vector10d>(16); + construct_at_boundary<Vector12d>(EIGEN_ALIGN_BYTES); construct_at_boundary<Matrix2d>(EIGEN_ALIGN_BYTES); construct_at_boundary<Matrix3d>(4); construct_at_boundary<Matrix4d>(EIGEN_ALIGN_BYTES); @@ -115,7 +135,14 @@ void unalignedassert() if(EIGEN_ALIGN_BYTES>=16) { VERIFY_RAISES_ASSERT(construct_at_boundary<Vector4f>(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector8f>(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector12f>(8)); VERIFY_RAISES_ASSERT(construct_at_boundary<Vector2d>(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector4d>(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector6d>(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector8d>(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector10d>(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary<Vector12d>(8)); VERIFY_RAISES_ASSERT(construct_at_boundary<Vector2cf>(8)); VERIFY_RAISES_ASSERT(construct_at_boundary<Vector4i>(8)); } |