aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-12-31 00:25:31 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-12-31 00:25:31 +0000
commitd671205755c3d9ee472eb1351d550d78f6d83454 (patch)
tree5d3783b20f246bc4a9db50d0f581d41cade169d7
parent3958e7f751f48b2750f3e296cb737e04aec00821 (diff)
fix the nomalloc test: it didn't catch the ei_stack_alloc in
cachefriendlyproduct, that should be banned as well as depending on the platform they can give a malloc, and they could happen even with (large enough) fixed size matrices. Corresponding fix in Product.h: cachefriendly is now only used for dynamic matrices -- fixedsize, no matter how large, doesn't use the cachefriendly product. We don't need to care (in my opinion) about performance for large fixed size, as large fixed size is a bad idea in the first place and it is more important to be able to guarantee clearly that fixed size never causes a malloc.
-rw-r--r--Eigen/src/Core/Product.h6
-rw-r--r--test/nomalloc.cpp6
2 files changed, 8 insertions, 4 deletions
diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h
index 6587ad3e0..77c18817d 100644
--- a/Eigen/src/Core/Product.h
+++ b/Eigen/src/Core/Product.h
@@ -89,9 +89,9 @@ template<typename Lhs, typename Rhs> struct ei_product_mode
? DiagonalProduct
: (Rhs::Flags & Lhs::Flags & SparseBit)
? SparseProduct
- : Lhs::MaxColsAtCompileTime >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
- && ( Lhs::MaxRowsAtCompileTime >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
- || Rhs::MaxColsAtCompileTime >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD )
+ : Lhs::MaxColsAtCompileTime == Dynamic
+ && ( Lhs::MaxRowsAtCompileTime == Dynamic
+ || Rhs::MaxColsAtCompileTime == Dynamic )
&& (!(Rhs::IsVectorAtCompileTime && (Lhs::Flags&RowMajorBit) && (!(Lhs::Flags&DirectAccessBit))))
&& (!(Lhs::IsVectorAtCompileTime && (!(Rhs::Flags&RowMajorBit)) && (!(Rhs::Flags&DirectAccessBit))))
&& (ei_is_same_type<typename Lhs::Scalar, typename Rhs::Scalar>::ret)
diff --git a/test/nomalloc.cpp b/test/nomalloc.cpp
index c1683206d..be4c35c48 100644
--- a/test/nomalloc.cpp
+++ b/test/nomalloc.cpp
@@ -25,8 +25,11 @@
// this hack is needed to make this file compiles with -pedantic (gcc)
#define throw(X)
-// discard vectorization since operator new is not called in that case
+// discard vectorization since the global operator new is not called in that case
#define EIGEN_DONT_VECTORIZE 1
+// discard stack allocation as that too bypasses the global operator new
+#define EIGEN_STACK_ALLOCATION_LIMIT 0
+
#include "main.h"
void* operator new[] (size_t n)
@@ -84,4 +87,5 @@ void test_nomalloc()
VERIFY_RAISES_ASSERT(MatrixXd dummy = MatrixXd::Random(3,3));
CALL_SUBTEST( nomalloc(Matrix<float, 1, 1>()) );
CALL_SUBTEST( nomalloc(Matrix4d()) );
+ CALL_SUBTEST( nomalloc(Matrix<float,32,32>()) );
}