From 39dcd01b0ac8556d1d46d5d897bdefa82cf5d91c Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 1 Apr 2015 13:55:09 +0200 Subject: [PATCH] bug #973: enable alignment of multiples of half-packet size (e.g., Vector6d with AVX) --- Eigen/src/Core/DenseStorage.h | 10 +++++----- 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::type, - bool Match = bool((Size%unpacket_traits::size)==0), - bool TryHalf = bool(int(unpacket_traits::size) > Size) + bool Match = bool((Size%unpacket_traits::size)==0), + bool TryHalf = bool(int(unpacket_traits::size) > 1) && bool(int(unpacket_traits::size) > int(unpacket_traits::half>::size)) > struct compute_default_alignment { enum { value = 0 }; }; -template -struct compute_default_alignment // Match +template +struct compute_default_alignment // Match { enum { value = sizeof(T) * unpacket_traits::size }; }; template -struct compute_default_alignment +struct compute_default_alignment // Try-half { // current packet too large, try with an half-packet enum { value = compute_default_alignment::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 Vector8f; +typedef Matrix Vector6f; +typedef Matrix Vector8f; +typedef Matrix Vector12f; + +typedef Matrix Vector5d; +typedef Matrix Vector6d; +typedef Matrix Vector7d; +typedef Matrix Vector8d; +typedef Matrix Vector9d; +typedef Matrix Vector10d; +typedef Matrix Vector12d; struct TestNew1 { @@ -85,6 +95,9 @@ void unalignedassert() construct_at_boundary(4); construct_at_boundary(4); construct_at_boundary(16); + construct_at_boundary(4); + construct_at_boundary(EIGEN_ALIGN_BYTES); + construct_at_boundary(16); construct_at_boundary(16); construct_at_boundary(4); construct_at_boundary(EIGEN_ALIGN_BYTES); @@ -92,6 +105,13 @@ void unalignedassert() construct_at_boundary(16); construct_at_boundary(4); construct_at_boundary(EIGEN_ALIGN_BYTES); + construct_at_boundary(4); + construct_at_boundary(16); + construct_at_boundary(4); + construct_at_boundary(EIGEN_ALIGN_BYTES); + construct_at_boundary(4); + construct_at_boundary(16); + construct_at_boundary(EIGEN_ALIGN_BYTES); construct_at_boundary(EIGEN_ALIGN_BYTES); construct_at_boundary(4); construct_at_boundary(EIGEN_ALIGN_BYTES); @@ -115,7 +135,14 @@ void unalignedassert() if(EIGEN_ALIGN_BYTES>=16) { VERIFY_RAISES_ASSERT(construct_at_boundary(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary(8)); VERIFY_RAISES_ASSERT(construct_at_boundary(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary(8)); + VERIFY_RAISES_ASSERT(construct_at_boundary(8)); VERIFY_RAISES_ASSERT(construct_at_boundary(8)); VERIFY_RAISES_ASSERT(construct_at_boundary(8)); }