This forum has been archived. All content is frozen. Please use KDE Discuss instead.

A.transpose() * v fails?

Tags: None
(comma "," separated)
EamonNerbonne
Registered Member
Posts
36
Karma
0

A.transpose() * v fails?

Mon Oct 19, 2009 3:15 pm
Hi, first time poster here!

I've been a gleeful user of Eigen's lovely API (to think I used to manually do these things...), and I've encountered what looks like a bug:

I'm using VS.NET 2008 (CL.exe version 15.00.30729.01 for x64)

I'm seeing some odd vectorization-related errors (alignment is OK):

Matrix2d A(Matrix2d::Identity());//value irrelevant
Vector2d v;
v << 3,5;//irrelevant
cout << "align(A):" << long long(&A) % 16 << endl; //0
cout << "Trying: A^T * v\n";
Vector2d w1 = A.transpose() * v; //error here with vectorization on x64
cout << w1 << endl;

An access violation occurs on the second-to-last line, but only on x64 mode with vectorization enabled. If I run either under x86 OR #define EIGEN_DONT_VECTORIZE, the code executes just fine. Memory addresses seem to be aligned just fine; and in debug mode (without NDEBUG defined), no assertions trigger.

Replacing Matrix2d with a MatrixXd also circumvents the error.

Is this a bug or am I missing something and it just happens to work on x86 or without vectorization?
EamonNerbonne
Registered Member
Posts
36
Karma
0

Re: A.transpose() * v fails?

Mon Oct 19, 2009 3:24 pm
...and I can't help but saying that I'm absolutely in love with your library! I'd been trying various other options, but so far, this is only option that actually seems to perform reasonably on small matrices and larger ones - and you've a brilliantly simple API to boot! Great work!
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: A.transpose() * v fails?

Mon Oct 19, 2009 3:31 pm
Thanks for the kind words. Can you run your program in a debugger, with full debug info, to get a backtrace and paste it here? Also, which version of Eigen are you using? Can you try if the development branch works?


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
EamonNerbonne
Registered Member
Posts
36
Karma
0

Re: A.transpose() * v fails?

Tue Oct 20, 2009 12:30 pm
I tried using the dev-branch eigen code (via bitbucket's default.tar.bz2). This has no impact on the presence of the error.

Well, the debugger won't help much - the stack dump is just 2 deep, namely some OS-scaffolding and the main() function - looks like whereever the bug is, is in inlined code.

If I turn off optimization (but leave on NDEBUG), the error does not occur. (Edit: this also means I can't turn off inlining - even with minimize-size optimization and inlining set to "only manually marked functions" no more informative stack frames are generated)

I also just tried compiling it with the new beta of VS.NET 2010; using the 10.0 toolchain the error does not occur (so that's good news!)

In short, this problem only occurs with the 9.0 version (or perhaps earlier) of Visual studio, with an x64 target, with vectorization (NDEBUG and not EIGEN_DONT_VECTORIZE), and with optimizations (/O1 /O2 or /Ox; all crash) on. If you change any of these, the transpose+ multiplication works fine. (Incidentally, the .transpose() is also necessary, and both .transpose and .transpose().eval() cause the crash - but .transpose() not followed by a multiplication does not crash).

I think I'll just switch to VS.NET 2010 or turn off vectorization and be done with it, but the error seems reproducible in those limited set of occurences where it occurs. The limited test case is an extraction from a larger program which triggered the same problem but where Matrix2d was heap-allocated rather than stack allocated, so that's likely not relevant either.

Last edited by EamonNerbonne on Tue Oct 20, 2009 12:37 pm, edited 1 time in total.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: A.transpose() * v fails?

Tue Oct 20, 2009 12:37 pm
OK, it seems you found a real bad bug, but I can't reproduce it here with GCC. That can only be fixed by someone who has the same Visual Studio as you. So it might be a little while until that gets done.

Meanwhile, the best thing that you can do to ensure that we can't forget about it, is to open a bug report here, http://bitbucket.org/eigen/eigen2/issues/

Just paste what you already wrote. Thanks!


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
EamonNerbonne
Registered Member
Posts
36
Karma
0

Re: A.transpose() * v fails?

Tue Oct 20, 2009 12:54 pm
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: A.transpose() * v fails?

Tue Oct 20, 2009 12:57 pm
Yep, got it! Thanks.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]