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

Alignment assertion with static fixed-size Eigen objects

Tags: None
(comma "," separated)
claurel
Registered Member
Posts
3
Karma
0
I'm seeing occasional alignment assertions from static fixed-size Eigen structures. For example, simply having the following line in the code:

static Quaterniond s_Orientation(1.0, 0.0, 0.0, 0.0);

This will (sometimes) trigger an alignment assertion during the initialization of static and global variables, before main() is entered. I only observer this problem with the MinGW compiler (a fairly recent version of g++, I believe 4.4). There are no problems with other compilers or with stack-allocated fixed-size Eigen objects.

Has anyone else seen this, and if so, can you suggest a workaround?

--Chris
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
MinGW... if I remember correctly we already had some issues with this compiler because it was not able to keep the stack aligned but I think this has been fixed with recent versions. The issue you described looks a bit different though... A workaround would be to avoid global variables which are not recommended anyway. For instance you could use a singleton. If you are using Eigen3, another workaround is to disable stack alignment (and consequently vectorization for small fixed size objects) or declare your global objects with the DontAlign template parameter.
claurel
Registered Member
Posts
3
Karma
0
This is a different issue than the stack alignment problem with early versions of MinGW. That disappeared when I switch from the MinGW 3.x version.

Switching off alignment for small sized fixed objects is something that I would like to avoid for performance reasons--my project uses them extensively. Singletons are an option, but they end up being fairly complicated solution when all I really want are a few quaternion and vector constants, e.g.

static Quaterniond EclipticToEMEJ2000 = Quaterniond(AngleAxisd(toRadians(J2000_OBLIQUITY), Vector3d::UnitX()));

This certainly seems like another bug with g++ on Windows. I was hoping for a magic compiler switch for MinGW :) I'll try and figure out some other workarounds.

--Chris


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft