From 8e0d548039f260db2eacb1e54e62e1acdbd4dd09 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 5 Mar 2008 13:18:19 +0000 Subject: * Fix a compilation issue with large fixed-size matrices: the unrollers were always instanciated. * the unrolling limits are configurable at compile time. --- Eigen/src/Core/Dot.h | 13 +++++++------ Eigen/src/Core/MatrixBase.h | 2 ++ Eigen/src/Core/OperatorEquals.h | 18 +++++++++++------- Eigen/src/Core/Product.h | 5 +++-- Eigen/src/Core/Trace.h | 13 ++++++++----- Eigen/src/Core/Util.h | 20 +++++++++++++++++--- 6 files changed, 48 insertions(+), 23 deletions(-) (limited to 'Eigen/src') diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index c3ca1e2ac..652514fa3 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -5,12 +5,12 @@ // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // Alternatively, you can redistribute it and/or // modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of +// published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY @@ -18,7 +18,7 @@ // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the // GNU General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public +// You should have received a copy of the GNU Lesser General Public // License and a copy of the GNU General Public License along with // Eigen. If not, see . @@ -60,7 +60,7 @@ struct DotUnroller /** \returns the dot product of *this with other. * * \only_for_vectors - * + * * \note If the scalar type is complex numbers, then this function returns the hermitian * (sesquilinear) dot product, linear in the first variable and anti-linear in the * second variable. @@ -77,8 +77,9 @@ Scalar MatrixBase::dot(const MatrixBase& Scalar res; if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic - && Traits::SizeAtCompileTime <= 16) - DotUnroller > ::run(*static_cast(this), other, res); else diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 09af4bd8d..f5a2ad178 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -49,6 +49,8 @@ cout << x.row(0) << endl; } * \endcode + * + * \nosubgrouping */ template class MatrixBase { diff --git a/Eigen/src/Core/OperatorEquals.h b/Eigen/src/Core/OperatorEquals.h index 6ff4402d4..bc1450127 100644 --- a/Eigen/src/Core/OperatorEquals.h +++ b/Eigen/src/Core/OperatorEquals.h @@ -6,12 +6,12 @@ // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // Alternatively, you can redistribute it and/or // modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of +// published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY @@ -19,7 +19,7 @@ // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the // GNU General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public +// You should have received a copy of the GNU Lesser General Public // License and a copy of the GNU General Public License along with // Eigen. If not, see . @@ -106,9 +106,12 @@ Derived& MatrixBase // copying a vector expression into a vector { 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 - ::run + ::run (*static_cast(this), *static_cast(&other)); else for(int i = 0; i < size(); i++) @@ -120,10 +123,11 @@ Derived& MatrixBase assert(rows() == other.rows() && cols() == other.cols()); if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic - && Traits::SizeAtCompileTime <= 25) + && Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL) { MatrixOperatorEqualsUnroller - ::run + ::run (*static_cast(this), *static_cast(&other)); } else diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 7ca68d76e..4d2db51bd 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -106,9 +106,10 @@ template class Product : NoOperatorEquals, Scalar res; if(EIGEN_UNROLLED_LOOPS && Lhs::Traits::ColsAtCompileTime != Dynamic - && Lhs::Traits::ColsAtCompileTime <= 16) + && Lhs::Traits::ColsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT) ProductUnroller + Lhs::Traits::ColsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Lhs::Traits::ColsAtCompileTime : Dynamic, + LhsRef, RhsRef> ::run(row, col, m_lhs, m_rhs, res); else { diff --git a/Eigen/src/Core/Trace.h b/Eigen/src/Core/Trace.h index 564801221..ff080c595 100644 --- a/Eigen/src/Core/Trace.h +++ b/Eigen/src/Core/Trace.h @@ -5,12 +5,12 @@ // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // Alternatively, you can redistribute it and/or // modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of +// published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY @@ -18,7 +18,7 @@ // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the // GNU General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public +// You should have received a copy of the GNU Lesser General Public // License and a copy of the GNU General Public License along with // Eigen. If not, see . @@ -61,8 +61,11 @@ Scalar MatrixBase::trace() const { assert(rows() == cols()); Scalar res; - if(EIGEN_UNROLLED_LOOPS && Traits::RowsAtCompileTime != Dynamic && Traits::RowsAtCompileTime <= 16) - TraceUnroller + if(EIGEN_UNROLLED_LOOPS + && Traits::RowsAtCompileTime != Dynamic + && Traits::RowsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT) + TraceUnroller ::run(*static_cast(this), res); else { diff --git a/Eigen/src/Core/Util.h b/Eigen/src/Core/Util.h index b11c27653..9d0aa07a0 100644 --- a/Eigen/src/Core/Util.h +++ b/Eigen/src/Core/Util.h @@ -5,12 +5,12 @@ // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 3 of the License, or (at your option) any later version. // // Alternatively, you can redistribute it and/or // modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of +// published by the Free Software Foundation; either version 2 of // the License, or (at your option) any later version. // // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY @@ -18,7 +18,7 @@ // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the // GNU General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public +// You should have received a copy of the GNU Lesser General Public // License and a copy of the GNU General Public License along with // Eigen. If not, see . @@ -31,6 +31,20 @@ #define EIGEN_UNROLLED_LOOPS (true) #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 #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER RowMajor #else -- cgit v1.2.3