diff --git a/Eigen/src/Core/AssignEvaluator.h b/Eigen/src/Core/AssignEvaluator.h index 574f945d5..9dbf2c063 100644 --- a/Eigen/src/Core/AssignEvaluator.h +++ b/Eigen/src/Core/AssignEvaluator.h @@ -30,12 +30,12 @@ struct copy_using_evaluator_traits typedef typename DstEvaluator::XprType Dst; typedef typename Dst::Scalar DstScalar; // TODO recursively find best packet size - typedef typename packet_traits::type DstPacket; + typedef typename packet_traits::type PacketType; enum { DstFlags = DstEvaluator::Flags, SrcFlags = SrcEvaluator::Flags, - RequiredAlignment = unpacket_traits::alignment + RequiredAlignment = unpacket_traits::alignment }; public: @@ -230,6 +230,7 @@ struct copy_using_evaluator_innervec_CompleteUnrolling // FIXME: this is not very clean, perhaps this information should be provided by the kernel? typedef typename Kernel::DstEvaluatorType DstEvaluatorType; typedef typename DstEvaluatorType::XprType DstXprType; + typedef typename Kernel::PacketType PacketType; enum { outer = Index / DstXprType::InnerSizeAtCompileTime, @@ -239,8 +240,8 @@ struct copy_using_evaluator_innervec_CompleteUnrolling EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel) { - kernel.template assignPacketByOuterInner(outer, inner); - enum { NextIndex = Index + packet_traits::size }; + kernel.template assignPacketByOuterInner(outer, inner); + enum { NextIndex = Index + unpacket_traits::size }; copy_using_evaluator_innervec_CompleteUnrolling::run(kernel); } }; @@ -254,10 +255,11 @@ struct copy_using_evaluator_innervec_CompleteUnrolling template struct copy_using_evaluator_innervec_InnerUnrolling { + typedef typename Kernel::PacketType PacketType; EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel, Index outer) { - kernel.template assignPacketByOuterInner(outer, Index_); - enum { NextIndex = Index_ + packet_traits::size }; + kernel.template assignPacketByOuterInner(outer, Index_); + enum { NextIndex = Index_ + unpacket_traits::size }; copy_using_evaluator_innervec_InnerUnrolling::run(kernel, outer); } }; @@ -366,13 +368,13 @@ struct dense_assignment_loop { const Index size = kernel.size(); typedef typename Kernel::Scalar Scalar; - typedef packet_traits PacketTraits; + typedef typename Kernel::PacketType PacketType; enum { requestedAlignment = Kernel::AssignmentTraits::RequiredAlignment, - packetSize = PacketTraits::size, + packetSize = unpacket_traits::size, dstIsAligned = int(Kernel::AssignmentTraits::DstAlignment)>=int(requestedAlignment), - dstAlignment = PacketTraits::AlignedOnScalar ? int(requestedAlignment) - : int(Kernel::AssignmentTraits::DstAlignment), + dstAlignment = packet_traits::AlignedOnScalar ? int(requestedAlignment) + : int(Kernel::AssignmentTraits::DstAlignment), srcAlignment = Kernel::AssignmentTraits::JointAlignment }; const Index alignedStart = dstIsAligned ? 0 : internal::first_aligned(&kernel.dstEvaluator().coeffRef(0), size); @@ -381,7 +383,7 @@ struct dense_assignment_loop unaligned_dense_assignment_loop::run(kernel, 0, alignedStart); for(Index index = alignedStart; index < alignedEnd; index += packetSize) - kernel.template assignPacket(index); + kernel.template assignPacket(index); unaligned_dense_assignment_loop<>::run(kernel, alignedEnd, size); } @@ -411,14 +413,15 @@ struct dense_assignment_loop struct dense_assignment_loop { + typedef typename Kernel::PacketType PacketType; EIGEN_DEVICE_FUNC static inline void run(Kernel &kernel) { const Index innerSize = kernel.innerSize(); const Index outerSize = kernel.outerSize(); - const Index packetSize = packet_traits::size; + const Index packetSize = unpacket_traits::size; for(Index outer = 0; outer < outerSize; ++outer) for(Index inner = 0; inner < innerSize; inner+=packetSize) - kernel.template assignPacketByOuterInner(outer, inner); + kernel.template assignPacketByOuterInner(outer, inner); } }; @@ -480,11 +483,11 @@ struct dense_assignment_loop EIGEN_DEVICE_FUNC static inline void run(Kernel &kernel) { typedef typename Kernel::Scalar Scalar; - typedef packet_traits PacketTraits; + typedef typename Kernel::PacketType PacketType; enum { - packetSize = PacketTraits::size, + packetSize = unpacket_traits::size, requestedAlignment = int(Kernel::AssignmentTraits::RequiredAlignment), - alignable = PacketTraits::AlignedOnScalar || int(Kernel::AssignmentTraits::DstAlignment)>=sizeof(Scalar), + alignable = packet_traits::AlignedOnScalar || int(Kernel::AssignmentTraits::DstAlignment)>=sizeof(Scalar), dstIsAligned = int(Kernel::AssignmentTraits::DstAlignment)>=int(requestedAlignment), dstAlignment = alignable ? int(requestedAlignment) : int(Kernel::AssignmentTraits::DstAlignment) @@ -510,7 +513,7 @@ struct dense_assignment_loop // do the vectorizable part of the assignment for(Index inner = alignedStart; inner(outer, inner); + kernel.template assignPacketByOuterInner(outer, inner); // do the non-vectorizable part of the assignment for(Index inner = alignedEnd; inner AssignmentTraits; + typedef typename AssignmentTraits::PacketType PacketType; EIGEN_DEVICE_FUNC generic_dense_assignment_kernel(DstEvaluatorType &dst, const SrcEvaluatorType &src, const Functor &func, DstXprType& dstExpr) @@ -588,24 +592,24 @@ public: } - template + template EIGEN_DEVICE_FUNC void assignPacket(Index row, Index col) { - m_functor.template assignPacket(&m_dst.coeffRef(row,col), m_src.template packet(row,col)); + m_functor.template assignPacket(&m_dst.coeffRef(row,col), m_src.template packet(row,col)); } - template + template EIGEN_DEVICE_FUNC void assignPacket(Index index) { - m_functor.template assignPacket(&m_dst.coeffRef(index), m_src.template packet(index)); + m_functor.template assignPacket(&m_dst.coeffRef(index), m_src.template packet(index)); } - template + template EIGEN_DEVICE_FUNC void assignPacketByOuterInner(Index outer, Index inner) { Index row = rowIndexByOuterInner(outer, inner); Index col = colIndexByOuterInner(outer, inner); - assignPacket(row, col); + assignPacket(row, col); } EIGEN_DEVICE_FUNC static Index rowIndexByOuterInner(Index outer, Index inner) diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index a599a6a69..26df269a0 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h @@ -131,8 +131,6 @@ struct evaluator > typedef PlainObjectBase PlainObjectType; typedef typename PlainObjectType::Scalar Scalar; typedef typename PlainObjectType::CoeffReturnType CoeffReturnType; - typedef typename PlainObjectType::PacketScalar PacketScalar; - typedef typename PlainObjectType::PacketReturnType PacketReturnType; enum { IsRowMajor = PlainObjectType::IsRowMajor, @@ -182,36 +180,36 @@ struct evaluator > return const_cast(m_data)[index]; } - template - PacketReturnType packet(Index row, Index col) const + template + PacketType packet(Index row, Index col) const { if (IsRowMajor) - return ploadt(m_data + row * m_outerStride.value() + col); + return ploadt(m_data + row * m_outerStride.value() + col); else - return ploadt(m_data + row + col * m_outerStride.value()); + return ploadt(m_data + row + col * m_outerStride.value()); } - template - PacketReturnType packet(Index index) const + template + PacketType packet(Index index) const { - return ploadt(m_data + index); + return ploadt(m_data + index); } - template - void writePacket(Index row, Index col, const PacketScalar& x) + template + void writePacket(Index row, Index col, const PacketType& x) { if (IsRowMajor) - return pstoret + return pstoret (const_cast(m_data) + row * m_outerStride.value() + col, x); else - return pstoret + return pstoret (const_cast(m_data) + row + col * m_outerStride.value(), x); } - template - void writePacket(Index index, const PacketScalar& x) + template + void writePacket(Index index, const PacketType& x) { - return pstoret(const_cast(m_data) + index, x); + return pstoret(const_cast(m_data) + index, x); } protected: @@ -267,8 +265,6 @@ struct unary_evaluator, IndexBased> typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; - typedef typename XprType::PacketReturnType PacketReturnType; EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index row, Index col) const { @@ -290,28 +286,28 @@ struct unary_evaluator, IndexBased> return m_argImpl.coeffRef(index); } - template - PacketReturnType packet(Index row, Index col) const + template + PacketType packet(Index row, Index col) const { - return m_argImpl.template packet(col, row); + return m_argImpl.template packet(col, row); } - template - PacketReturnType packet(Index index) const + template + PacketType packet(Index index) const { - return m_argImpl.template packet(index); + return m_argImpl.template packet(index); } - template - void writePacket(Index row, Index col, const PacketScalar& x) + template + void writePacket(Index row, Index col, const PacketType& x) { - m_argImpl.template writePacket(col, row, x); + m_argImpl.template writePacket(col, row, x); } - template - void writePacket(Index index, const PacketScalar& x) + template + void writePacket(Index index, const PacketType& x) { - m_argImpl.template writePacket(index, x); + m_argImpl.template writePacket(index, x); } protected: @@ -345,7 +341,6 @@ struct evaluator > { } typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index row, Index col) const { @@ -357,16 +352,16 @@ struct evaluator > return m_functor(index); } - template - PacketScalar packet(Index row, Index col) const + template + PacketType packet(Index row, Index col) const { - return m_functor.packetOp(row, col); + return m_functor.template packetOp(row, col); } - template - PacketScalar packet(Index index) const + template + PacketType packet(Index index) const { - return m_functor.packetOp(index); + return m_functor.template packetOp(index); } protected: @@ -395,7 +390,6 @@ struct unary_evaluator, IndexBased > { } typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index row, Index col) const { @@ -407,16 +401,16 @@ struct unary_evaluator, IndexBased > return m_functor(m_argImpl.coeff(index)); } - template - PacketScalar packet(Index row, Index col) const + template + PacketType packet(Index row, Index col) const { - return m_functor.packetOp(m_argImpl.template packet(row, col)); + return m_functor.packetOp(m_argImpl.template packet(row, col)); } - template - PacketScalar packet(Index index) const + template + PacketType packet(Index index) const { - return m_functor.packetOp(m_argImpl.template packet(index)); + return m_functor.packetOp(m_argImpl.template packet(index)); } protected: @@ -469,7 +463,6 @@ struct binary_evaluator, IndexBased, IndexBase { } typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index row, Index col) const { @@ -481,18 +474,18 @@ struct binary_evaluator, IndexBased, IndexBase return m_functor(m_lhsImpl.coeff(index), m_rhsImpl.coeff(index)); } - template - PacketScalar packet(Index row, Index col) const + template + PacketType packet(Index row, Index col) const { - return m_functor.packetOp(m_lhsImpl.template packet(row, col), - m_rhsImpl.template packet(row, col)); + return m_functor.packetOp(m_lhsImpl.template packet(row, col), + m_rhsImpl.template packet(row, col)); } - template - PacketScalar packet(Index index) const + template + PacketType packet(Index index) const { - return m_functor.packetOp(m_lhsImpl.template packet(index), - m_rhsImpl.template packet(index)); + return m_functor.packetOp(m_lhsImpl.template packet(index), + m_rhsImpl.template packet(index)); } protected: @@ -564,8 +557,6 @@ struct mapbase_evaluator : evaluator_base typedef typename XprType::PointerType PointerType; typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; - typedef typename XprType::PacketReturnType PacketReturnType; enum { IsRowMajor = XprType::RowsAtCompileTime, @@ -601,30 +592,30 @@ struct mapbase_evaluator : evaluator_base return m_data[index * m_xpr.innerStride()]; } - template - PacketReturnType packet(Index row, Index col) const + template + PacketType packet(Index row, Index col) const { PointerType ptr = m_data + row * m_xpr.rowStride() + col * m_xpr.colStride(); - return internal::ploadt(ptr); + return internal::ploadt(ptr); } - template - PacketReturnType packet(Index index) const + template + PacketType packet(Index index) const { - return internal::ploadt(m_data + index * m_xpr.innerStride()); + return internal::ploadt(m_data + index * m_xpr.innerStride()); } - template - void writePacket(Index row, Index col, const PacketScalar& x) + template + void writePacket(Index row, Index col, const PacketType& x) { PointerType ptr = m_data + row * m_xpr.rowStride() + col * m_xpr.colStride(); - return internal::pstoret(ptr, x); + return internal::pstoret(ptr, x); } - template - void writePacket(Index index, const PacketScalar& x) + template + void writePacket(Index index, const PacketType& x) { - internal::pstoret(m_data + index * m_xpr.innerStride(), x); + internal::pstoret(m_data + index * m_xpr.innerStride(), x); } protected: @@ -770,8 +761,6 @@ struct unary_evaluator, IndexBa typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; - typedef typename XprType::PacketReturnType PacketReturnType; enum { RowsAtCompileTime = XprType::RowsAtCompileTime @@ -797,31 +786,31 @@ struct unary_evaluator, IndexBa return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0); } - template - PacketReturnType packet(Index row, Index col) const + template + PacketType packet(Index row, Index col) const { - return m_argImpl.template packet(m_startRow.value() + row, m_startCol.value() + col); + return m_argImpl.template packet(m_startRow.value() + row, m_startCol.value() + col); } - template - PacketReturnType packet(Index index) const + template + PacketType packet(Index index) const { - return packet(RowsAtCompileTime == 1 ? 0 : index, - RowsAtCompileTime == 1 ? index : 0); + return packet(RowsAtCompileTime == 1 ? 0 : index, + RowsAtCompileTime == 1 ? index : 0); } - template - void writePacket(Index row, Index col, const PacketScalar& x) + template + void writePacket(Index row, Index col, const PacketType& x) { - return m_argImpl.template writePacket(m_startRow.value() + row, m_startCol.value() + col, x); + return m_argImpl.template writePacket(m_startRow.value() + row, m_startCol.value() + col, x); } - template - void writePacket(Index index, const PacketScalar& x) + template + void writePacket(Index index, const PacketType& x) { - return writePacket(RowsAtCompileTime == 1 ? 0 : index, - RowsAtCompileTime == 1 ? index : 0, - x); + return writePacket(RowsAtCompileTime == 1 ? 0 : index, + RowsAtCompileTime == 1 ? index : 0, + x); } protected: @@ -908,7 +897,6 @@ struct unary_evaluator > { typedef Replicate XprType; typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketReturnType PacketReturnType; enum { Factor = (RowFactor==Dynamic || ColFactor==Dynamic) ? Dynamic : RowFactor*ColFactor }; @@ -953,8 +941,8 @@ struct unary_evaluator > return m_argImpl.coeff(actual_index); } - template - PacketReturnType packet(Index row, Index col) const + template + PacketType packet(Index row, Index col) const { const Index actual_row = internal::traits::RowsAtCompileTime==1 ? 0 : RowFactor==1 ? row @@ -963,17 +951,17 @@ struct unary_evaluator > : ColFactor==1 ? col : col % m_cols.value(); - return m_argImpl.template packet(actual_row, actual_col); + return m_argImpl.template packet(actual_row, actual_col); } - template - PacketReturnType packet(Index index) const + template + PacketType packet(Index index) const { const Index actual_index = internal::traits::RowsAtCompileTime==1 ? (ColFactor==1 ? index : index%m_cols.value()) : (RowFactor==1 ? index : index%m_rows.value()); - return m_argImpl.template packet(actual_index); + return m_argImpl.template packet(actual_index); } protected: @@ -1050,8 +1038,6 @@ struct evaluator_wrapper_base typedef typename ArgType::Scalar Scalar; typedef typename ArgType::CoeffReturnType CoeffReturnType; - typedef typename ArgType::PacketScalar PacketScalar; - typedef typename ArgType::PacketReturnType PacketReturnType; EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index row, Index col) const { @@ -1073,26 +1059,26 @@ struct evaluator_wrapper_base return m_argImpl.coeffRef(index); } - template - PacketReturnType packet(Index row, Index col) const + template + PacketType packet(Index row, Index col) const { - return m_argImpl.template packet(row, col); + return m_argImpl.template packet(row, col); } - template - PacketReturnType packet(Index index) const + template + PacketType packet(Index index) const { - return m_argImpl.template packet(index); + return m_argImpl.template packet(index); } - template - void writePacket(Index row, Index col, const PacketScalar& x) + template + void writePacket(Index row, Index col, const PacketType& x) { m_argImpl.template writePacket(row, col, x); } - template - void writePacket(Index index, const PacketScalar& x) + template + void writePacket(Index index, const PacketType& x) { m_argImpl.template writePacket(index, x); } @@ -1127,7 +1113,7 @@ struct unary_evaluator > // -------------------- Reverse -------------------- // defined in Reverse.h: -template struct reverse_packet_cond; +template struct reverse_packet_cond; template struct unary_evaluator > @@ -1136,17 +1122,12 @@ struct unary_evaluator > typedef Reverse XprType; typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; - typedef typename XprType::PacketReturnType PacketReturnType; enum { - PacketSize = internal::packet_traits::size, IsRowMajor = XprType::IsRowMajor, IsColMajor = !IsRowMajor, ReverseRow = (Direction == Vertical) || (Direction == BothDirections), ReverseCol = (Direction == Horizontal) || (Direction == BothDirections), - OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1, - OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1, ReversePacket = (Direction == BothDirections) || ((Direction == Vertical) && IsColMajor) || ((Direction == Horizontal) && IsRowMajor), @@ -1163,7 +1144,6 @@ struct unary_evaluator > Alignment = 0 // FIXME in some rare cases, Alignment could be preserved, like a Vector4f. }; - typedef internal::reverse_packet_cond reverse_packet; EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& reverse) : m_argImpl(reverse.nestedExpression()), @@ -1193,32 +1173,47 @@ struct unary_evaluator > return m_argImpl.coeffRef(m_rows.value() * m_cols.value() - index - 1); } - template - PacketScalar packet(Index row, Index col) const + template + PacketType packet(Index row, Index col) const { - return reverse_packet::run(m_argImpl.template packet( + enum { + PacketSize = unpacket_traits::size, + OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1, + OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1 + }; + typedef internal::reverse_packet_cond reverse_packet; + return reverse_packet::run(m_argImpl.template packet( ReverseRow ? m_rows.value() - row - OffsetRow : row, ReverseCol ? m_cols.value() - col - OffsetCol : col)); } - template - PacketScalar packet(Index index) const + template + PacketType packet(Index index) const { - return preverse(m_argImpl.template packet(m_rows.value() * m_cols.value() - index - PacketSize)); + enum { PacketSize = unpacket_traits::size }; + return preverse(m_argImpl.template packet(m_rows.value() * m_cols.value() - index - PacketSize)); } - template - void writePacket(Index row, Index col, const PacketScalar& x) + template + void writePacket(Index row, Index col, const PacketType& x) { + // FIXME we could factorize some code with packet(i,j) + enum { + PacketSize = unpacket_traits::size, + OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1, + OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1 + }; + typedef internal::reverse_packet_cond reverse_packet; m_argImpl.template writePacket( ReverseRow ? m_rows.value() - row - OffsetRow : row, ReverseCol ? m_cols.value() - col - OffsetCol : col, reverse_packet::run(x)); } - template - void writePacket(Index index, const PacketScalar& x) + template + void writePacket(Index index, const PacketType& x) { + enum { PacketSize = unpacket_traits::size }; m_argImpl.template writePacket (m_rows.value() * m_cols.value() - index - PacketSize, preverse(x)); } diff --git a/Eigen/src/Core/DenseCoeffsBase.h b/Eigen/src/Core/DenseCoeffsBase.h index d7ccb3b6f..81b0d6017 100644 --- a/Eigen/src/Core/DenseCoeffsBase.h +++ b/Eigen/src/Core/DenseCoeffsBase.h @@ -216,8 +216,9 @@ class DenseCoeffsBase : public EigenBase template EIGEN_STRONG_INLINE PacketReturnType packet(Index row, Index col) const { + typedef typename internal::packet_traits::type DefaultPacketType; eigen_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); - return typename internal::evaluator::type(derived()).template packet(row,col); + return typename internal::evaluator::type(derived()).template packet(row,col); } @@ -242,8 +243,9 @@ class DenseCoeffsBase : public EigenBase template EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const { + typedef typename internal::packet_traits::type DefaultPacketType; eigen_internal_assert(index >= 0 && index < size()); - return typename internal::evaluator::type(derived()).template packet(index); + return typename internal::evaluator::type(derived()).template packet(index); } protected: diff --git a/Eigen/src/Core/Diagonal.h b/Eigen/src/Core/Diagonal.h index c79891ae1..fa3176266 100644 --- a/Eigen/src/Core/Diagonal.h +++ b/Eigen/src/Core/Diagonal.h @@ -170,7 +170,7 @@ template class Diagonal EIGEN_STRONG_INLINE Index rowOffset() const { return m_index.value()>0 ? 0 : -m_index.value(); } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index colOffset() const { return m_index.value()>0 ? m_index.value() : 0; } - // trigger a compile time error is someone try to call packet + // trigger a compile-time error if someone try to call packet template typename MatrixType::PacketReturnType packet(Index) const; template typename MatrixType::PacketReturnType packet(Index,Index) const; }; diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index b24d54ef9..f2c188631 100755 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -491,13 +491,13 @@ struct product_evaluator, ProductTag, DenseShape, return (m_lhs.row(row).transpose().cwiseProduct( m_rhs.col(col) )).sum(); } - template - const PacketReturnType packet(Index row, Index col) const + template + const PacketType packet(Index row, Index col) const { - PacketScalar res; + PacketType res; typedef etor_product_packet_impl PacketImpl; + LhsEtorType, RhsEtorType, PacketType, LoadMode> PacketImpl; PacketImpl::run(row, col, m_lhsImpl, m_rhsImpl, m_innerDim, res); return res; @@ -539,7 +539,7 @@ struct etor_product_packet_impl::run(row, col, lhs, rhs, innerDim, res); - res = pmadd(pset1(lhs.coeff(row, UnrollingIndex-1)), rhs.template packet(UnrollingIndex-1, col), res); + res = pmadd(pset1(lhs.coeff(row, UnrollingIndex-1)), rhs.template packet(UnrollingIndex-1, col), res); } }; @@ -549,7 +549,7 @@ struct etor_product_packet_impl::run(row, col, lhs, rhs, innerDim, res); - res = pmadd(lhs.template packet(row, UnrollingIndex-1), pset1(rhs.coeff(UnrollingIndex-1, col)), res); + res = pmadd(lhs.template packet(row, UnrollingIndex-1), pset1(rhs.coeff(UnrollingIndex-1, col)), res); } }; @@ -558,7 +558,7 @@ struct etor_product_packet_impl { static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, Packet &res) { - res = pmul(pset1(lhs.coeff(row, 0)),rhs.template packet(0, col)); + res = pmul(pset1(lhs.coeff(row, 0)),rhs.template packet(0, col)); } }; @@ -567,7 +567,7 @@ struct etor_product_packet_impl { static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, Packet &res) { - res = pmul(lhs.template packet(row, 0), pset1(rhs.coeff(0, col))); + res = pmul(lhs.template packet(row, 0), pset1(rhs.coeff(0, col))); } }; @@ -596,7 +596,7 @@ struct etor_product_packet_impl { res = pset1(0); for(Index i = 0; i < innerDim; ++i) - res = pmadd(pset1(lhs.coeff(row, i)), rhs.template packet(i, col), res); + res = pmadd(pset1(lhs.coeff(row, i)), rhs.template packet(i, col), res); } }; @@ -607,7 +607,7 @@ struct etor_product_packet_impl { res = pset1(0); for(Index i = 0; i < innerDim; ++i) - res = pmadd(lhs.template packet(row, i), pset1(rhs.coeff(i, col)), res); + res = pmadd(lhs.template packet(row, i), pset1(rhs.coeff(i, col)), res); } }; @@ -691,7 +691,6 @@ struct diagonal_product_evaluator_base : evaluator_base { typedef typename scalar_product_traits::ReturnType Scalar; - typedef typename internal::packet_traits::type PacketScalar; public: enum { CoeffReadCost = NumTraits::MulCost + evaluator::CoeffReadCost + evaluator::CoeffReadCost, @@ -721,22 +720,22 @@ public: } protected: - template - EIGEN_STRONG_INLINE PacketScalar packet_impl(Index row, Index col, Index id, internal::true_type) const + template + EIGEN_STRONG_INLINE PacketType packet_impl(Index row, Index col, Index id, internal::true_type) const { - return internal::pmul(m_matImpl.template packet(row, col), - internal::pset1(m_diagImpl.coeff(id))); + return internal::pmul(m_matImpl.template packet(row, col), + internal::pset1(m_diagImpl.coeff(id))); } - template - EIGEN_STRONG_INLINE PacketScalar packet_impl(Index row, Index col, Index id, internal::false_type) const + template + EIGEN_STRONG_INLINE PacketType packet_impl(Index row, Index col, Index id, internal::false_type) const { enum { InnerSize = (MatrixType::Flags & RowMajorBit) ? MatrixType::ColsAtCompileTime : MatrixType::RowsAtCompileTime, DiagonalPacketLoadMode = EIGEN_PLAIN_ENUM_MIN(LoadMode,((InnerSize%16) == 0) ? int(Aligned16) : int(evaluator::Alignment)) // FIXME hardcoded 16!! }; - return internal::pmul(m_matImpl.template packet(row, col), - m_diagImpl.template packet(id)); + return internal::pmul(m_matImpl.template packet(row, col), + m_diagImpl.template packet(id)); } typename evaluator::nestedType m_diagImpl; @@ -753,7 +752,6 @@ struct product_evaluator, ProductTag, DiagonalSha using Base::m_matImpl; using Base::coeff; typedef typename Base::Scalar Scalar; - typedef typename Base::PacketScalar PacketScalar; typedef Product XprType; typedef typename XprType::PlainObject PlainObject; @@ -773,19 +771,19 @@ struct product_evaluator, ProductTag, DiagonalSha } #ifndef __CUDACC__ - template - EIGEN_STRONG_INLINE PacketScalar packet(Index row, Index col) const + template + EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const { // FIXME: NVCC used to complain about the template keyword, but we have to check whether this is still the case. // See also similar calls below. - return this->template packet_impl(row,col, row, + return this->template packet_impl(row,col, row, typename internal::conditional::type()); } - template - EIGEN_STRONG_INLINE PacketScalar packet(Index idx) const + template + EIGEN_STRONG_INLINE PacketType packet(Index idx) const { - return packet(int(StorageOrder)==ColMajor?idx:0,int(StorageOrder)==ColMajor?0:idx); + return packet(int(StorageOrder)==ColMajor?idx:0,int(StorageOrder)==ColMajor?0:idx); } #endif }; @@ -800,7 +798,6 @@ struct product_evaluator, ProductTag, DenseShape, using Base::m_matImpl; using Base::coeff; typedef typename Base::Scalar Scalar; - typedef typename Base::PacketScalar PacketScalar; typedef Product XprType; typedef typename XprType::PlainObject PlainObject; @@ -818,17 +815,17 @@ struct product_evaluator, ProductTag, DenseShape, } #ifndef __CUDACC__ - template - EIGEN_STRONG_INLINE PacketScalar packet(Index row, Index col) const + template + EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const { - return this->template packet_impl(row,col, col, + return this->template packet_impl(row,col, col, typename internal::conditional::type()); } - template - EIGEN_STRONG_INLINE PacketScalar packet(Index idx) const + template + EIGEN_STRONG_INLINE PacketType packet(Index idx) const { - return packet(int(StorageOrder)==ColMajor?idx:0,int(StorageOrder)==ColMajor?0:idx); + return packet(int(StorageOrder)==ColMajor?idx:0,int(StorageOrder)==ColMajor?0:idx); } #endif }; diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h index 942f51d51..67ce3113e 100644 --- a/Eigen/src/Core/Redux.h +++ b/Eigen/src/Core/Redux.h @@ -173,7 +173,7 @@ struct redux_vec_unroller static EIGEN_STRONG_INLINE PacketScalar run(const Derived &mat, const Func&) { - return mat.template packetByOuterInner(outer, inner); + return mat.template packetByOuterInner(outer, inner); } }; @@ -235,19 +235,19 @@ struct redux_impl Scalar res; if(alignedSize) { - PacketScalar packet_res0 = mat.template packet(alignedStart); + PacketScalar packet_res0 = mat.template packet(alignedStart); if(alignedSize>packetSize) // we have at least two packets to partly unroll the loop { - PacketScalar packet_res1 = mat.template packet(alignedStart+packetSize); + PacketScalar packet_res1 = mat.template packet(alignedStart+packetSize); for(Index index = alignedStart + 2*packetSize; index < alignedEnd2; index += 2*packetSize) { - packet_res0 = func.packetOp(packet_res0, mat.template packet(index)); - packet_res1 = func.packetOp(packet_res1, mat.template packet(index+packetSize)); + packet_res0 = func.packetOp(packet_res0, mat.template packet(index)); + packet_res1 = func.packetOp(packet_res1, mat.template packet(index+packetSize)); } packet_res0 = func.packetOp(packet_res0,packet_res1); if(alignedEnd>alignedEnd2) - packet_res0 = func.packetOp(packet_res0, mat.template packet(alignedEnd2)); + packet_res0 = func.packetOp(packet_res0, mat.template packet(alignedEnd2)); } res = func.predux(packet_res0); @@ -273,7 +273,7 @@ template struct redux_impl { typedef typename Derived::Scalar Scalar; - typedef typename packet_traits::type PacketScalar; + typedef typename packet_traits::type PacketType; EIGEN_DEVICE_FUNC static Scalar run(const Derived &mat, const Func& func) { @@ -287,10 +287,10 @@ struct redux_impl Scalar res; if(packetedInnerSize) { - PacketScalar packet_res = mat.template packet(0,0); + PacketType packet_res = mat.template packet(0,0); for(Index j=0; j(j,i)); + packet_res = func.packetOp(packet_res, mat.template packetByOuterInner(j,i)); res = func.predux(packet_res); for(Index j=0; j + template PacketReturnType packet(Index row, Index col) const - { return m_evaluator.template packet(row, col); } + { return m_evaluator.template packet(row, col); } - template + template PacketReturnType packet(Index index) const - { return m_evaluator.template packet(index); } + { return m_evaluator.template packet(index); } EIGEN_DEVICE_FUNC CoeffReturnType coeffByOuterInner(Index outer, Index inner) const { return m_evaluator.coeff(IsRowMajor ? outer : inner, IsRowMajor ? inner : outer); } - template + template PacketReturnType packetByOuterInner(Index outer, Index inner) const - { return m_evaluator.template packet(IsRowMajor ? outer : inner, IsRowMajor ? inner : outer); } + { return m_evaluator.template packet(IsRowMajor ? outer : inner, IsRowMajor ? inner : outer); } const XprType & nestedExpression() const { return m_xpr; } diff --git a/Eigen/src/Core/Reverse.h b/Eigen/src/Core/Reverse.h index 8e7f6e927..d7c380c78 100644 --- a/Eigen/src/Core/Reverse.h +++ b/Eigen/src/Core/Reverse.h @@ -48,14 +48,14 @@ struct traits > }; }; -template struct reverse_packet_cond +template struct reverse_packet_cond { - static inline PacketScalar run(const PacketScalar& x) { return preverse(x); } + static inline PacketType run(const PacketType& x) { return preverse(x); } }; -template struct reverse_packet_cond +template struct reverse_packet_cond { - static inline PacketScalar run(const PacketScalar& x) { return x; } + static inline PacketType run(const PacketType& x) { return x; } }; } // end namespace internal diff --git a/Eigen/src/Core/Swap.h b/Eigen/src/Core/Swap.h index 3880f7b78..d70200918 100644 --- a/Eigen/src/Core/Swap.h +++ b/Eigen/src/Core/Swap.h @@ -21,7 +21,6 @@ class generic_dense_assignment_kernel, BuiltIn> Base; - typedef typename DstEvaluatorTypeT::PacketScalar PacketScalar; using Base::m_dst; using Base::m_src; using Base::m_functor; @@ -35,29 +34,29 @@ public: : Base(dst, src, func, dstExpr) {} - template + template void assignPacket(Index row, Index col) { - PacketScalar tmp = m_src.template packet(row,col); - const_cast(m_src).template writePacket(row,col, m_dst.template packet(row,col)); + PacketType tmp = m_src.template packet(row,col); + const_cast(m_src).template writePacket(row,col, m_dst.template packet(row,col)); m_dst.template writePacket(row,col,tmp); } - template + template void assignPacket(Index index) { - PacketScalar tmp = m_src.template packet(index); - const_cast(m_src).template writePacket(index, m_dst.template packet(index)); + PacketType tmp = m_src.template packet(index); + const_cast(m_src).template writePacket(index, m_dst.template packet(index)); m_dst.template writePacket(index,tmp); } // TODO find a simple way not to have to copy/paste this function from generic_dense_assignment_kernel, by simple I mean no CRTP (Gael) - template + template void assignPacketByOuterInner(Index outer, Index inner) { Index row = Base::rowIndexByOuterInner(outer, inner); Index col = Base::colIndexByOuterInner(outer, inner); - assignPacket(row, col); + assignPacket(row, col); } }; diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h index bf03ea818..351630e57 100644 --- a/Eigen/src/Core/TriangularMatrix.h +++ b/Eigen/src/Core/TriangularMatrix.h @@ -36,10 +36,14 @@ template class TriangularBase : public EigenBase MaxColsAtCompileTime = internal::traits::MaxColsAtCompileTime, SizeAtCompileTime = (internal::size_at_compile_time::RowsAtCompileTime, - internal::traits::ColsAtCompileTime>::ret) - /**< This is equal to the number of coefficients, i.e. the number of + internal::traits::ColsAtCompileTime>::ret), + /**< This is equal to the number of coefficients, i.e. the number of * rows times the number of columns, or to \a Dynamic if this is not * known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */ + + MaxSizeAtCompileTime = (internal::size_at_compile_time::MaxRowsAtCompileTime, + internal::traits::MaxColsAtCompileTime>::ret) + }; typedef typename internal::traits::Scalar Scalar; typedef typename internal::traits::StorageKind StorageKind; diff --git a/Eigen/src/Core/functors/NullaryFunctors.h b/Eigen/src/Core/functors/NullaryFunctors.h index 2362b3a7f..76a3445ce 100644 --- a/Eigen/src/Core/functors/NullaryFunctors.h +++ b/Eigen/src/Core/functors/NullaryFunctors.h @@ -16,13 +16,12 @@ namespace internal { template struct scalar_constant_op { - typedef typename packet_traits::type Packet; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_constant_op(const scalar_constant_op& other) : m_other(other.m_other) { } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_constant_op(const Scalar& other) : m_other(other) { } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (Index, Index = 0) const { return m_other; } - template - EIGEN_STRONG_INLINE const Packet packetOp(Index, Index = 0) const { return internal::pset1(m_other); } + template + EIGEN_STRONG_INLINE const PacketType packetOp(Index, Index = 0) const { return internal::pset1(m_other); } const Scalar m_other; }; template @@ -39,7 +38,7 @@ template struct functor_traits > { enum { Cost = NumTraits::AddCost, PacketAccess = false, IsRepeatable = true }; }; -template struct linspaced_op_impl; +template struct linspaced_op_impl; // linear access for packet ops: // 1) initialization @@ -49,11 +48,9 @@ template struct linspaced_op_impl; // // TODO: Perhaps it's better to initialize lazily (so not in the constructor but in packetOp) // in order to avoid the padd() in operator() ? -template -struct linspaced_op_impl +template +struct linspaced_op_impl { - typedef typename packet_traits::type Packet; - linspaced_op_impl(const Scalar& low, const Scalar& step) : m_low(low), m_step(step), m_packetStep(pset1(packet_traits::size*step)), @@ -78,11 +75,9 @@ struct linspaced_op_impl // random access for packet ops: // 1) each step // [low, ..., low] + ( [step, ..., step] * ( [i, ..., i] + [0, ..., size] ) ) -template -struct linspaced_op_impl +template +struct linspaced_op_impl { - typedef typename packet_traits::type Packet; - linspaced_op_impl(const Scalar& low, const Scalar& step) : m_low(low), m_step(step), m_lowPacket(pset1(m_low)), m_stepPacket(pset1(m_step)), m_interPacket(plset(0)) {} @@ -111,7 +106,6 @@ template struct functor_traits< linspaced_o { enum { Cost = 1, PacketAccess = packet_traits::HasSetLinear, IsRepeatable = true }; }; template struct linspaced_op { - typedef typename packet_traits::type Packet; linspaced_op(const Scalar& low, const Scalar& high, Index num_steps) : impl((num_steps==1 ? high : low), (num_steps==1 ? Scalar() : (high-low)/Scalar(num_steps-1))) {} template @@ -126,12 +120,12 @@ template struct linspaced_op return impl(col + row); } - template + template EIGEN_STRONG_INLINE const Packet packetOp(Index i) const { return impl.packetOp(i); } // We need this function when assigning e.g. a RowVectorXd to a MatrixXd since // there row==0 and col is used for the actual iteration. - template + template EIGEN_STRONG_INLINE const Packet packetOp(Index row, Index col) const { eigen_assert(col==0 || row==0); @@ -141,7 +135,8 @@ template struct linspaced_op // This proxy object handles the actual required temporaries, the different // implementations (random vs. sequential access) as well as the // correct piping to size 2/4 packet operations. - const linspaced_op_impl impl; + // TODO find a way to make the packet type configurable + const linspaced_op_impl::type,RandomAccess> impl; }; // all functors allow linear access, except scalar_identity_op. So we fix here a quick meta