mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 19:59:05 +08:00
let redux use the new ByOuterInner accessors
This commit is contained in:
parent
4927841cba
commit
814e40c72a
@ -40,7 +40,7 @@ struct ei_redux_traits
|
|||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
PacketSize = ei_packet_traits<typename Derived::Scalar>::size,
|
PacketSize = ei_packet_traits<typename Derived::Scalar>::size,
|
||||||
InnerMaxSize = int(Derived::Flags)&RowMajorBit
|
InnerMaxSize = int(Derived::IsRowMajor)
|
||||||
? Derived::MaxColsAtCompileTime
|
? Derived::MaxColsAtCompileTime
|
||||||
: Derived::MaxRowsAtCompileTime
|
: Derived::MaxRowsAtCompileTime
|
||||||
};
|
};
|
||||||
@ -100,15 +100,15 @@ template<typename Func, typename Derived, int Start>
|
|||||||
struct ei_redux_novec_unroller<Func, Derived, Start, 1>
|
struct ei_redux_novec_unroller<Func, Derived, Start, 1>
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
col = Start / Derived::RowsAtCompileTime,
|
outer = Start / Derived::InnerSizeAtCompileTime,
|
||||||
row = Start % Derived::RowsAtCompileTime
|
inner = Start % Derived::InnerSizeAtCompileTime
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef typename Derived::Scalar Scalar;
|
typedef typename Derived::Scalar Scalar;
|
||||||
|
|
||||||
EIGEN_STRONG_INLINE static Scalar run(const Derived &mat, const Func&)
|
EIGEN_STRONG_INLINE static Scalar run(const Derived &mat, const Func&)
|
||||||
{
|
{
|
||||||
return mat.coeff(row, col);
|
return mat.coeffByOuterInner(outer, inner);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -148,12 +148,8 @@ struct ei_redux_vec_unroller<Func, Derived, Start, 1>
|
|||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
index = Start * ei_packet_traits<typename Derived::Scalar>::size,
|
index = Start * ei_packet_traits<typename Derived::Scalar>::size,
|
||||||
row = int(Derived::Flags)&RowMajorBit
|
outer = index / int(Derived::InnerSizeAtCompileTime),
|
||||||
? index / int(Derived::ColsAtCompileTime)
|
inner = index % int(Derived::InnerSizeAtCompileTime),
|
||||||
: index % Derived::RowsAtCompileTime,
|
|
||||||
col = int(Derived::Flags)&RowMajorBit
|
|
||||||
? index % int(Derived::ColsAtCompileTime)
|
|
||||||
: index / Derived::RowsAtCompileTime,
|
|
||||||
alignment = (Derived::Flags & AlignedBit) ? Aligned : Unaligned
|
alignment = (Derived::Flags & AlignedBit) ? Aligned : Unaligned
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -162,7 +158,7 @@ struct ei_redux_vec_unroller<Func, Derived, Start, 1>
|
|||||||
|
|
||||||
EIGEN_STRONG_INLINE static PacketScalar run(const Derived &mat, const Func&)
|
EIGEN_STRONG_INLINE static PacketScalar run(const Derived &mat, const Func&)
|
||||||
{
|
{
|
||||||
return mat.template packet<alignment>(row, col);
|
return mat.template packetByOuterInner<alignment>(outer, inner);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -184,12 +180,12 @@ struct ei_redux_impl<Func, Derived, DefaultTraversal, NoUnrolling>
|
|||||||
{
|
{
|
||||||
ei_assert(mat.rows()>0 && mat.cols()>0 && "you are using a non initialized matrix");
|
ei_assert(mat.rows()>0 && mat.cols()>0 && "you are using a non initialized matrix");
|
||||||
Scalar res;
|
Scalar res;
|
||||||
res = mat.coeff(0, 0);
|
res = mat.coeffByOuterInner(0, 0);
|
||||||
for(int i = 1; i < mat.rows(); ++i)
|
for(int i = 1; i < mat.innerSize(); ++i)
|
||||||
res = func(res, mat.coeff(i, 0));
|
res = func(res, mat.coeffByOuterInner(0, i));
|
||||||
for(int j = 1; j < mat.cols(); ++j)
|
for(int i = 1; i < mat.outerSize(); ++i)
|
||||||
for(int i = 0; i < mat.rows(); ++i)
|
for(int j = 0; j < mat.innerSize(); ++j)
|
||||||
res = func(res, mat.coeff(i, j));
|
res = func(res, mat.coeffByOuterInner(i, j));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -253,8 +249,7 @@ struct ei_redux_impl<Func, Derived, SliceVectorizedTraversal, NoUnrolling>
|
|||||||
const int innerSize = mat.innerSize();
|
const int innerSize = mat.innerSize();
|
||||||
const int outerSize = mat.outerSize();
|
const int outerSize = mat.outerSize();
|
||||||
enum {
|
enum {
|
||||||
packetSize = ei_packet_traits<Scalar>::size,
|
packetSize = ei_packet_traits<Scalar>::size
|
||||||
isRowMajor = Derived::Flags&RowMajorBit?1:0
|
|
||||||
};
|
};
|
||||||
const int packetedInnerSize = ((innerSize)/packetSize)*packetSize;
|
const int packetedInnerSize = ((innerSize)/packetSize)*packetSize;
|
||||||
Scalar res;
|
Scalar res;
|
||||||
@ -263,13 +258,12 @@ struct ei_redux_impl<Func, Derived, SliceVectorizedTraversal, NoUnrolling>
|
|||||||
PacketScalar packet_res = mat.template packet<Unaligned>(0,0);
|
PacketScalar packet_res = mat.template packet<Unaligned>(0,0);
|
||||||
for(int j=0; j<outerSize; ++j)
|
for(int j=0; j<outerSize; ++j)
|
||||||
for(int i=0; i<packetedInnerSize; i+=int(packetSize))
|
for(int i=0; i<packetedInnerSize; i+=int(packetSize))
|
||||||
packet_res = func.packetOp(packet_res, mat.template packet<Unaligned>
|
packet_res = func.packetOp(packet_res, mat.template packetByOuterInner<Unaligned>(j,i));
|
||||||
(isRowMajor?j:i, isRowMajor?i:j));
|
|
||||||
|
|
||||||
res = func.predux(packet_res);
|
res = func.predux(packet_res);
|
||||||
for(int j=0; j<outerSize; ++j)
|
for(int j=0; j<outerSize; ++j)
|
||||||
for(int i=packetedInnerSize; i<innerSize; ++i)
|
for(int i=packetedInnerSize; i<innerSize; ++i)
|
||||||
res = func(res, mat.coeff(isRowMajor?j:i, isRowMajor?i:j));
|
res = func(res, mat.coeffByOuterInner(j,i));
|
||||||
}
|
}
|
||||||
else // too small to vectorize anything.
|
else // too small to vectorize anything.
|
||||||
// since this is dynamic-size hence inefficient anyway for such small sizes, don't try to optimize.
|
// since this is dynamic-size hence inefficient anyway for such small sizes, don't try to optimize.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user