mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 19:59:05 +08:00
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.
This commit is contained in:
parent
3958e7f751
commit
d671205755
@ -89,9 +89,9 @@ template<typename Lhs, typename Rhs> struct ei_product_mode
|
|||||||
? DiagonalProduct
|
? DiagonalProduct
|
||||||
: (Rhs::Flags & Lhs::Flags & SparseBit)
|
: (Rhs::Flags & Lhs::Flags & SparseBit)
|
||||||
? SparseProduct
|
? SparseProduct
|
||||||
: Lhs::MaxColsAtCompileTime >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
|
: Lhs::MaxColsAtCompileTime == Dynamic
|
||||||
&& ( Lhs::MaxRowsAtCompileTime >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
|
&& ( Lhs::MaxRowsAtCompileTime == Dynamic
|
||||||
|| Rhs::MaxColsAtCompileTime >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD )
|
|| Rhs::MaxColsAtCompileTime == Dynamic )
|
||||||
&& (!(Rhs::IsVectorAtCompileTime && (Lhs::Flags&RowMajorBit) && (!(Lhs::Flags&DirectAccessBit))))
|
&& (!(Rhs::IsVectorAtCompileTime && (Lhs::Flags&RowMajorBit) && (!(Lhs::Flags&DirectAccessBit))))
|
||||||
&& (!(Lhs::IsVectorAtCompileTime && (!(Rhs::Flags&RowMajorBit)) && (!(Rhs::Flags&DirectAccessBit))))
|
&& (!(Lhs::IsVectorAtCompileTime && (!(Rhs::Flags&RowMajorBit)) && (!(Rhs::Flags&DirectAccessBit))))
|
||||||
&& (ei_is_same_type<typename Lhs::Scalar, typename Rhs::Scalar>::ret)
|
&& (ei_is_same_type<typename Lhs::Scalar, typename Rhs::Scalar>::ret)
|
||||||
|
@ -25,8 +25,11 @@
|
|||||||
|
|
||||||
// this hack is needed to make this file compiles with -pedantic (gcc)
|
// this hack is needed to make this file compiles with -pedantic (gcc)
|
||||||
#define throw(X)
|
#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
|
#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"
|
#include "main.h"
|
||||||
|
|
||||||
void* operator new[] (size_t n)
|
void* operator new[] (size_t n)
|
||||||
@ -84,4 +87,5 @@ void test_nomalloc()
|
|||||||
VERIFY_RAISES_ASSERT(MatrixXd dummy = MatrixXd::Random(3,3));
|
VERIFY_RAISES_ASSERT(MatrixXd dummy = MatrixXd::Random(3,3));
|
||||||
CALL_SUBTEST( nomalloc(Matrix<float, 1, 1>()) );
|
CALL_SUBTEST( nomalloc(Matrix<float, 1, 1>()) );
|
||||||
CALL_SUBTEST( nomalloc(Matrix4d()) );
|
CALL_SUBTEST( nomalloc(Matrix4d()) );
|
||||||
|
CALL_SUBTEST( nomalloc(Matrix<float,32,32>()) );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user