mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-13 04:09:10 +08:00
* Fix a compilation issue with large fixed-size matrices: the unrollers were always instanciated.
* the unrolling limits are configurable at compile time.
This commit is contained in:
parent
861c6f4c9b
commit
8e0d548039
@ -77,8 +77,9 @@ Scalar MatrixBase<Scalar, Derived>::dot(const MatrixBase<Scalar, OtherDerived>&
|
|||||||
Scalar res;
|
Scalar res;
|
||||||
if(EIGEN_UNROLLED_LOOPS
|
if(EIGEN_UNROLLED_LOOPS
|
||||||
&& Traits::SizeAtCompileTime != Dynamic
|
&& Traits::SizeAtCompileTime != Dynamic
|
||||||
&& Traits::SizeAtCompileTime <= 16)
|
&& Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||||
DotUnroller<Traits::SizeAtCompileTime-1, Traits::SizeAtCompileTime,
|
DotUnroller<Traits::SizeAtCompileTime-1,
|
||||||
|
Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Traits::SizeAtCompileTime : Dynamic,
|
||||||
Derived, MatrixBase<Scalar, OtherDerived> >
|
Derived, MatrixBase<Scalar, OtherDerived> >
|
||||||
::run(*static_cast<const Derived*>(this), other, res);
|
::run(*static_cast<const Derived*>(this), other, res);
|
||||||
else
|
else
|
||||||
|
@ -49,6 +49,8 @@
|
|||||||
cout << x.row(0) << endl;
|
cout << x.row(0) << endl;
|
||||||
}
|
}
|
||||||
* \endcode
|
* \endcode
|
||||||
|
*
|
||||||
|
* \nosubgrouping
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived> class MatrixBase
|
template<typename Scalar, typename Derived> class MatrixBase
|
||||||
{
|
{
|
||||||
|
@ -106,9 +106,12 @@ Derived& MatrixBase<Scalar, Derived>
|
|||||||
// copying a vector expression into a vector
|
// copying a vector expression into a vector
|
||||||
{
|
{
|
||||||
assert(size() == other.size());
|
assert(size() == other.size());
|
||||||
if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic && Traits::SizeAtCompileTime <= 25)
|
if(EIGEN_UNROLLED_LOOPS
|
||||||
|
&& Traits::SizeAtCompileTime != Dynamic
|
||||||
|
&& Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL)
|
||||||
VectorOperatorEqualsUnroller
|
VectorOperatorEqualsUnroller
|
||||||
<Derived, OtherDerived, Traits::SizeAtCompileTime>::run
|
<Derived, OtherDerived,
|
||||||
|
Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL ? Traits::SizeAtCompileTime : Dynamic>::run
|
||||||
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
||||||
else
|
else
|
||||||
for(int i = 0; i < size(); i++)
|
for(int i = 0; i < size(); i++)
|
||||||
@ -120,10 +123,11 @@ Derived& MatrixBase<Scalar, Derived>
|
|||||||
assert(rows() == other.rows() && cols() == other.cols());
|
assert(rows() == other.rows() && cols() == other.cols());
|
||||||
if(EIGEN_UNROLLED_LOOPS
|
if(EIGEN_UNROLLED_LOOPS
|
||||||
&& Traits::SizeAtCompileTime != Dynamic
|
&& Traits::SizeAtCompileTime != Dynamic
|
||||||
&& Traits::SizeAtCompileTime <= 25)
|
&& Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL)
|
||||||
{
|
{
|
||||||
MatrixOperatorEqualsUnroller
|
MatrixOperatorEqualsUnroller
|
||||||
<Derived, OtherDerived, Traits::SizeAtCompileTime>::run
|
<Derived, OtherDerived,
|
||||||
|
Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL ? Traits::SizeAtCompileTime : Dynamic>::run
|
||||||
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -106,9 +106,10 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
|||||||
Scalar res;
|
Scalar res;
|
||||||
if(EIGEN_UNROLLED_LOOPS
|
if(EIGEN_UNROLLED_LOOPS
|
||||||
&& Lhs::Traits::ColsAtCompileTime != Dynamic
|
&& Lhs::Traits::ColsAtCompileTime != Dynamic
|
||||||
&& Lhs::Traits::ColsAtCompileTime <= 16)
|
&& Lhs::Traits::ColsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||||
ProductUnroller<Lhs::Traits::ColsAtCompileTime-1,
|
ProductUnroller<Lhs::Traits::ColsAtCompileTime-1,
|
||||||
Lhs::Traits::ColsAtCompileTime, LhsRef, RhsRef>
|
Lhs::Traits::ColsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Lhs::Traits::ColsAtCompileTime : Dynamic,
|
||||||
|
LhsRef, RhsRef>
|
||||||
::run(row, col, m_lhs, m_rhs, res);
|
::run(row, col, m_lhs, m_rhs, res);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -61,8 +61,11 @@ Scalar MatrixBase<Scalar, Derived>::trace() const
|
|||||||
{
|
{
|
||||||
assert(rows() == cols());
|
assert(rows() == cols());
|
||||||
Scalar res;
|
Scalar res;
|
||||||
if(EIGEN_UNROLLED_LOOPS && Traits::RowsAtCompileTime != Dynamic && Traits::RowsAtCompileTime <= 16)
|
if(EIGEN_UNROLLED_LOOPS
|
||||||
TraceUnroller<Traits::RowsAtCompileTime-1, Traits::RowsAtCompileTime, Derived>
|
&& Traits::RowsAtCompileTime != Dynamic
|
||||||
|
&& Traits::RowsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||||
|
TraceUnroller<Traits::RowsAtCompileTime-1,
|
||||||
|
Traits::RowsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Traits::RowsAtCompileTime : Dynamic, Derived>
|
||||||
::run(*static_cast<const Derived*>(this), res);
|
::run(*static_cast<const Derived*>(this), res);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -31,6 +31,20 @@
|
|||||||
#define EIGEN_UNROLLED_LOOPS (true)
|
#define EIGEN_UNROLLED_LOOPS (true)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** Defines the maximal loop size (i.e., the matrix size NxM) to enable
|
||||||
|
* meta unrolling of operator=.
|
||||||
|
*/
|
||||||
|
#ifndef EIGEN_UNROLLING_LIMIT_OPEQUAL
|
||||||
|
#define EIGEN_UNROLLING_LIMIT_OPEQUAL 25
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Defines the maximal loop size to enable meta unrolling
|
||||||
|
* of the matrix product, dot product and trace.
|
||||||
|
*/
|
||||||
|
#ifndef EIGEN_UNROLLING_LIMIT_PRODUCT
|
||||||
|
#define EIGEN_UNROLLING_LIMIT_PRODUCT 16
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
|
#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
|
||||||
#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER RowMajor
|
#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER RowMajor
|
||||||
#else
|
#else
|
||||||
|
@ -104,6 +104,8 @@ void EigenTest::testAdjoint()
|
|||||||
adjoint(MatrixXi(8, 12));
|
adjoint(MatrixXi(8, 12));
|
||||||
adjoint(MatrixXcd(20, 20));
|
adjoint(MatrixXcd(20, 20));
|
||||||
}
|
}
|
||||||
|
// test a large matrix only once
|
||||||
|
adjoint(Matrix<float, 100, 100>());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Eigen
|
} // namespace Eigen
|
||||||
|
@ -89,6 +89,7 @@ void EigenTest::testBasicStuff()
|
|||||||
basicStuff(MatrixXcf(3, 3));
|
basicStuff(MatrixXcf(3, 3));
|
||||||
basicStuff(MatrixXi(8, 12));
|
basicStuff(MatrixXi(8, 12));
|
||||||
basicStuff(MatrixXcd(20, 20));
|
basicStuff(MatrixXcd(20, 20));
|
||||||
|
basicStuff(Matrix<float, 100, 100>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,9 @@ void EigenTest::testProduct()
|
|||||||
product(MatrixXi(8, 12));
|
product(MatrixXi(8, 12));
|
||||||
product(MatrixXcd(20, 20));
|
product(MatrixXcd(20, 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test a large matrix only once
|
||||||
|
product(Matrix<float, 100, 100>());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Eigen
|
} // namespace Eigen
|
||||||
|
Loading…
x
Reference in New Issue
Block a user