Registered Member
|
I'm using Eigen 2.0.6 with sse2 . The compiler is icc 10.1 for windows.
There is an exception throwed: Access violation reading location 0xcdcdcdd1 when D* dd = new D; So what's wrong with the code below?
Last edited by lastsnow on Wed Oct 14, 2009 3:56 pm, edited 1 time in total.
|
Registered Member
|
I can't reproduce your issue, i even checked that all objects are created at aligned locations. Please provide a readily compilable program and specify your compiler version. Please also paste a full back-trace.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Moderator
|
your code looks ok, and since here I cannot reproduce your issue we'll need more information: Can you run your test under a debugger and post a complete backtrace ? and/or if you are running linux try to run it with valgrind. What happens if you disable SSE, or if you try with a different compiler ?
|
Registered Member
|
Thanks for your reply.
I just tried gcc 4.4 under linux.It seems ok. The code will have problem when using intel compiler(10.1.013 ) under windows.It's weired that I cannot always reproduce the problem(memory not aligned ?). I will try it under different circumtance to find out what's going on. I will capture more data if I encounter this problem again. |
Registered Member
|
BTW, this is really inconvenient for struct D to use the macro EIGEN_MAKE_ALIGNED_OPERATOR_NEW, if other class or struct wrap a D member,the macro must write there.This intrusive way makes me uncomfortable.
What about do something like this in matrixstorage.h, I have tried it. But the cost is obvious: extra 16 bytes storage.
|
Registered Member
|
And also a runtime computation. Two good reasons why we can't do that. If you don't like that you can: - disable vectorization/alignment (define EIGEN_DONT_ALIGN) or - wait for the next C++ standard which finally provides good alignment support.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
Is the alignment enabled by default ?
vs2005 compile the following code without define EIGEN_DONT_ALIGN std::vector<transform_t> v; will generate this error: error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned I think no alignment should be the default option. |
Registered Member
|
On VS 2005, we don't vectorize. So alignment is useless indeed. But, if we want to preserve ABI compatibility, we still need to align. If you are sure that VS 2005 doesn't have the same C++ ABI as VS 2008 anyway, then I'm OK to disable alignment on VS 2005.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
I assume patching the vector file of the STL is considered to have side-effects and should be avoided?
It solved the Compile error error "C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned" for me but I don't feel good with that solution. Orignial vector (VS2010)
Modification
Do I break lots of things with that? I use latest Eigen 2.x with the Eigen STL allocators. Inspiration came from that thread: http://ompf.org/forum/viewtopic.php?f=11&t=686 There is also source code for an aligned vector, but somehow I'd rather use the STL. Or should I switch to Qvector of Qt? |
Registered Member
|
We have corrected these STL issues and provide classes
Eigen/StdDeque Eigen/StdList Eigen/StdVector - Hauke |
Registered Member
|
Thank you very much. I removed all the hand-written calls of the Eigen allocator and included the Eigen::StdVector.
The only remaining problem is now an error when I try to push_back() an Eigen::MatrixXd into a std::vector:
Is the error on my side here? Am I using it wrongly or is it a side-effect? Using MSVC10 on WinXP. |
Registered Member
|
Could you please provide a self-contained example?
I am unable to reproduce the error. Besides that, std::vector should not be specialized for MatrixXd. It does not required special handling since it is not stack but heap aligned. You seem to trigger the rvalue reference push_back method, i.e. you must call something like this
but even here, I fail to reproduce the problem. Regards, Hauke |
Registered Member
|
Thank you for your answer. Here is a short example that triggers the error.
If I understand correctly that means that I should not use Eigen::StdVector at all for MatrixXd? But why did I get compile errors about something not being aligned then? The error pointed me to the Eigen documentation site and that was why I started to use the aligned allocator in the first place. |
Registered Member
|
Let me start by answering your last question. You got the error, because the std::vector is storing stack matrices (vectors) and these are stack aligned. They are allocated on the stack since they are declared as fixed size types.
In the loop on the other hand side, you are pushing MatrixXd and not VectorType. This causes the MatrixXd to be converted into VectorType and in turn it causes a call to the rvalue push_back method. Not a problem at all, if your std::vector were correctly declared or specialized. When you want to use our special implementation of std::vector, you either need to specialize by putting the following convenience macro in your code (assuming you have the typedef as above)
or, you need to specify the std::vector as
In any case, we need to make sure to use our special aligned_allocator. Besides the falsely declared std::vector you have a useless conversion in your code which you can improve by this code
Regards, Hauke |
Registered Member
|
Thank you very much!
I was assuming that a MatrixXd is the same as a hand-declared Matrix<...>. But I think I was confused because in another part of the code I have MatrixXd with sizes known only at runtime. That's also why I have that useless conversion in my code. But I'm seeing clearer now I can't find EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION anywhere in the Eigen2 source. I think I have to use Eigen3 for that? And is Eigen3 stable enough to do the change now? (I don't use very advanced features of Eigen so far). Regards, vernal |
Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient