mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
- cleaner use of OpenMP (no code duplication anymore)
using a macro and _Pragma. - use OpenMP also in cacheOptimalProduct and in the vectorized paths as well - kill the vector assignment unroller. implement in operator= the logic for assigning a row-vector in a col-vector. - CMakeLists support for building tests/examples with -fopenmp and/or -msse2 - updates in bench/, especially replace identity() by ones() which prevents underflows from perturbing bench results.
This commit is contained in:
@@ -283,64 +283,70 @@ void Product<Lhs,Rhs,EvalMode>::_cacheOptimalEval(DestDerived& res) const
|
||||
#ifdef EIGEN_VECTORIZE
|
||||
if( (Flags & VectorizableBit) && (!(Lhs::Flags & RowMajorBit)) )
|
||||
{
|
||||
for(int k=0; k<m_rhs.cols(); k++)
|
||||
{
|
||||
int j=0;
|
||||
for(; j<cols4; j+=4)
|
||||
{
|
||||
const typename ei_packet_traits<Scalar>::type tmp0 = ei_pset1(m_rhs.coeff(j+0,k));
|
||||
const typename ei_packet_traits<Scalar>::type tmp1 = ei_pset1(m_rhs.coeff(j+1,k));
|
||||
const typename ei_packet_traits<Scalar>::type tmp2 = ei_pset1(m_rhs.coeff(j+2,k));
|
||||
const typename ei_packet_traits<Scalar>::type tmp3 = ei_pset1(m_rhs.coeff(j+3,k));
|
||||
for (int i=0; i<m_lhs.rows(); i+=ei_packet_traits<Scalar>::size)
|
||||
{
|
||||
res.writePacketCoeff(i,k,
|
||||
ei_padd(
|
||||
res.packetCoeff(i,k),
|
||||
ei_padd(
|
||||
ei_padd(
|
||||
ei_pmul(tmp0, m_lhs.packetCoeff(i,j)),
|
||||
ei_pmul(tmp1, m_lhs.packetCoeff(i,j+1))),
|
||||
ei_padd(
|
||||
ei_pmul(tmp2, m_lhs.packetCoeff(i,j+2)),
|
||||
ei_pmul(tmp3, m_lhs.packetCoeff(i,j+3))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
#define EIGEN_THE_PARALLELIZABLE_LOOP \
|
||||
for(int k=0; k<this->cols(); k++) \
|
||||
{ \
|
||||
int j=0; \
|
||||
for(; j<cols4; j+=4) \
|
||||
{ \
|
||||
const typename ei_packet_traits<Scalar>::type tmp0 = ei_pset1(m_rhs.coeff(j+0,k)); \
|
||||
const typename ei_packet_traits<Scalar>::type tmp1 = ei_pset1(m_rhs.coeff(j+1,k)); \
|
||||
const typename ei_packet_traits<Scalar>::type tmp2 = ei_pset1(m_rhs.coeff(j+2,k)); \
|
||||
const typename ei_packet_traits<Scalar>::type tmp3 = ei_pset1(m_rhs.coeff(j+3,k)); \
|
||||
for (int i=0; i<this->rows(); i+=ei_packet_traits<Scalar>::size) \
|
||||
{ \
|
||||
res.writePacketCoeff(i,k,\
|
||||
ei_padd( \
|
||||
res.packetCoeff(i,k), \
|
||||
ei_padd( \
|
||||
ei_padd( \
|
||||
ei_pmul(tmp0, m_lhs.packetCoeff(i,j)), \
|
||||
ei_pmul(tmp1, m_lhs.packetCoeff(i,j+1))), \
|
||||
ei_padd( \
|
||||
ei_pmul(tmp2, m_lhs.packetCoeff(i,j+2)), \
|
||||
ei_pmul(tmp3, m_lhs.packetCoeff(i,j+3)) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
); \
|
||||
} \
|
||||
} \
|
||||
for(; j<m_lhs.cols(); ++j) \
|
||||
{ \
|
||||
const typename ei_packet_traits<Scalar>::type tmp = ei_pset1(m_rhs.coeff(j,k)); \
|
||||
for (int i=0; i<this->rows(); ++i) \
|
||||
res.writePacketCoeff(i,k,ei_pmul(tmp, m_lhs.packetCoeff(i,j))); \
|
||||
} \
|
||||
}
|
||||
for(; j<m_lhs.cols(); ++j)
|
||||
{
|
||||
const typename ei_packet_traits<Scalar>::type tmp = ei_pset1(m_rhs.coeff(j,k));
|
||||
for (int i=0; i<m_lhs.rows(); ++i)
|
||||
res.writePacketCoeff(i,k,ei_pmul(tmp, m_lhs.packetCoeff(i,j)));
|
||||
}
|
||||
}
|
||||
EIGEN_RUN_PARALLELIZABLE_LOOP(Flags & DestDerived::Flags & LargeBit)
|
||||
#undef EIGEN_THE_PARALLELIZABLE_LOOP
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif // EIGEN_VECTORIZE
|
||||
{
|
||||
for(int k=0; k<m_rhs.cols(); ++k)
|
||||
{
|
||||
int j=0;
|
||||
for(; j<cols4; j+=4)
|
||||
{
|
||||
const Scalar tmp0 = m_rhs.coeff(j ,k);
|
||||
const Scalar tmp1 = m_rhs.coeff(j+1,k);
|
||||
const Scalar tmp2 = m_rhs.coeff(j+2,k);
|
||||
const Scalar tmp3 = m_rhs.coeff(j+3,k);
|
||||
for (int i=0; i<m_lhs.rows(); ++i)
|
||||
res.coeffRef(i,k) += tmp0 * m_lhs.coeff(i,j) + tmp1 * m_lhs.coeff(i,j+1)
|
||||
+ tmp2 * m_lhs.coeff(i,j+2) + tmp3 * m_lhs.coeff(i,j+3);
|
||||
#define EIGEN_THE_PARALLELIZABLE_LOOP \
|
||||
for(int k=0; k<this->cols(); ++k) \
|
||||
{ \
|
||||
int j=0; \
|
||||
for(; j<cols4; j+=4) \
|
||||
{ \
|
||||
const Scalar tmp0 = m_rhs.coeff(j ,k); \
|
||||
const Scalar tmp1 = m_rhs.coeff(j+1,k); \
|
||||
const Scalar tmp2 = m_rhs.coeff(j+2,k); \
|
||||
const Scalar tmp3 = m_rhs.coeff(j+3,k); \
|
||||
for (int i=0; i<this->rows(); ++i) \
|
||||
res.coeffRef(i,k) += tmp0 * m_lhs.coeff(i,j) + tmp1 * m_lhs.coeff(i,j+1) \
|
||||
+ tmp2 * m_lhs.coeff(i,j+2) + tmp3 * m_lhs.coeff(i,j+3); \
|
||||
} \
|
||||
for(; j<m_lhs.cols(); ++j) \
|
||||
{ \
|
||||
const Scalar tmp = m_rhs.coeff(j,k); \
|
||||
for (int i=0; i<this->rows(); ++i) \
|
||||
res.coeffRef(i,k) += tmp * m_lhs.coeff(i,j); \
|
||||
} \
|
||||
}
|
||||
for(; j<m_lhs.cols(); ++j)
|
||||
{
|
||||
const Scalar tmp = m_rhs.coeff(j,k);
|
||||
for (int i=0; i<m_lhs.rows(); ++i)
|
||||
res.coeffRef(i,k) += tmp * m_lhs.coeff(i,j);
|
||||
}
|
||||
}
|
||||
EIGEN_RUN_PARALLELIZABLE_LOOP(Flags & DestDerived::Flags & LargeBit)
|
||||
#undef EIGEN_THE_PARALLELIZABLE_LOOP
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user