From 1f5024332e47f295c991c3781d57d0466d41a9c8 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 6 Aug 2015 15:31:07 +0200 Subject: First part of a big refactoring of alignment control to enable the handling of arbitrarily aligned buffers. It includes: - AlignedBit flag is deprecated. Alignment is now specified by the evaluator through the 'Alignment' enum, e.g., evaluator::Alignment. Its value is in Bytes. - Add several enums to specify alignment: Aligned8, Aligned16, Aligned32, Aligned64, Aligned128. AlignedMax corresponds to EIGEN_MAX_ALIGN_BYTES. Such enums are used to define the above Alignment value, and as the 'Options' template parameter of Map<> and Ref<>. - The Aligned enum is now deprecated. It is now an alias for Aligned16. - Currently, traits>, traits>, traits>, traits>, and traits> also expose the Alignment enum. --- Eigen/src/Core/Redux.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Eigen/src/Core/Redux.h') diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h index fea4e2895..0c25223aa 100644 --- a/Eigen/src/Core/Redux.h +++ b/Eigen/src/Core/Redux.h @@ -165,7 +165,7 @@ struct redux_vec_unroller index = Start * packet_traits::size, outer = index / int(Derived::InnerSizeAtCompileTime), inner = index % int(Derived::InnerSizeAtCompileTime), - alignment = (Derived::Flags & AlignedBit) ? Aligned : Unaligned + alignment = Derived::Alignment }; typedef typename Derived::Scalar Scalar; @@ -222,10 +222,10 @@ struct redux_impl const Index size = mat.size(); const Index packetSize = packet_traits::size; - const Index alignedStart = internal::first_aligned(mat); + const Index alignedStart = internal::first_aligned(mat.nestedExpression()); enum { - alignment = (bool(Derived::Flags & DirectAccessBit) && bool(packet_traits::AlignedOnScalar)) || bool(Derived::Flags & AlignedBit) - ? Aligned : Unaligned + alignment0 = (bool(Derived::Flags & DirectAccessBit) && bool(packet_traits::AlignedOnScalar)) ? int(sizeof(Scalar)*packetSize) : int(Unaligned), // FIXME take into account alignment requirement + alignment = EIGEN_PLAIN_ENUM_MAX(alignment0, Derived::Alignment) }; const Index alignedSize2 = ((size-alignedStart)/(2*packetSize))*(2*packetSize); const Index alignedSize = ((size-alignedStart)/(packetSize))*(packetSize); @@ -352,7 +352,8 @@ public: IsRowMajor = XprType::IsRowMajor, SizeAtCompileTime = XprType::SizeAtCompileTime, InnerSizeAtCompileTime = XprType::InnerSizeAtCompileTime, - CoeffReadCost = evaluator::CoeffReadCost + CoeffReadCost = evaluator::CoeffReadCost, + Alignment = evaluator::Alignment }; EIGEN_DEVICE_FUNC Index rows() const { return m_xpr.rows(); } @@ -385,6 +386,8 @@ public: PacketReturnType packetByOuterInner(Index outer, Index inner) const { return m_evaluator.template packet(IsRowMajor ? outer : inner, IsRowMajor ? inner : outer); } + const XprType & nestedExpression() const { return m_xpr; } + protected: typename internal::evaluator::nestedType m_evaluator; const XprType &m_xpr; -- cgit v1.2.3