New user self-registration is currently disabled. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 1012 - Map<>.noalias() = A * B triggers memory allocation
Map<>.noalias() = A * B triggers memory allocation
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Core - expression templates
3.2
All Other UNIX-like
: Normal Wrong Result
Assigned To: Nobody
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-05-06 04:04 UTC by Chris Dyer
Modified: 2015-05-06 11:30 UTC (History)
3 users (show)



Attachments

Description Chris Dyer 2015-05-06 04:04:34 UTC
It seems that noalias() doesn't behave properly with Map<>ed matrices. (However, while this is broken in the current release -- 3.2.4 -- it appears to have been corrected in the development repository, so I'm working around it by using this.)

Here is some repro code:

#define EIGEN_NO_MALLOC
#include <Eigen/Eigen>
#include <cstdlib>

int main() {
  using namespace Eigen;
  float* a = (float*)malloc(10 * 10 * sizeof(float));
  float* b = (float*)malloc(10 * 10 * sizeof(float));
  float* c = (float*)malloc(10 * 10 * sizeof(float));
  Map<MatrixXf> ma(a, 10, 10);
  Map<MatrixXf> mb(b, 10, 10);
  Map<MatrixXf> mc(c, 10, 10);
  mc.noalias() = ma * mb;    // fails with 3.2.4, succeeds with dev
  mc.noalias() += ma * mb;   // fails with 3.2.4, succeeds with dev
}

Here is my compiler info:
$ g++ --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
Comment 1 Christoph Hertzberg 2015-05-06 11:30:45 UTC
This appears to be a duplicate of Bug 729. I manually backported the fix here:
https://bitbucket.org/eigen/eigen/commits/a16528a7f459

Note You need to log in before you can comment on or make changes to this bug.