Small, dynamic sized, scaled products cause a temporary (with unnecessary heap allocation)
@chhtz
Submitted by Christoph HertzbergAssigned to Nobody
Link to original bugzilla bug (#1562)
Version: 3.4 (development)
Description
As reported here
https://stackoverflow.com/questions/51043842/call-eigen-gemm-over-externally-allocated-data
when evaluating a small, dynamic sized, scaled product, will cause a temporary (thus heap allocation).
To check, compile this snippet with -D EIGEN_NO_MALLOC
float aDat[] = {1, 2, 3, 4};
float bDat[] = {1, 2, 3, 4};
float cDat[] = {1, 2, 3, 4};
Map<Matrix<Scalar, -1, -1>, Unaligned> a(aDat.data(), 2, 2);
Map<Matrix<Scalar, -1, -1>, Unaligned> b(bDat.data(), 2, 2);
Map<Matrix<Scalar, -1, -1>, Unaligned> c(cDat.data(), 2, 2);
//Ok
c.noalias() += a * b;
//Assertion `false && "heap allocation is forbidden.....
c.noalias() += 2 * a * b;
I assume it is possible to implement lazyproduct::addTo
in a way that it does not require a temporary, or if a temporary is needed for performance reasons, allocate it on the stack.
Edited by Eigen Bugzilla