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

UnalignedArrayAssert

Tags: None
(comma "," separated)
dlbaz
Registered Member
Posts
5
Karma
0

UnalignedArrayAssert

Thu Dec 09, 2010 1:05 pm
I'm getting this assert which sends me to this site http://eigen.tuxfamily.org/dox/Unaligne ... ssert.html

I'm using Eigen 2.0.

I tried to find the case that was similar to mine but there was not one exactly like it that I could see.

I found it to be asserting on

Code: Select all
   mModelList.push_back( newModel );


Where mModelList is:

Code: Select all
std::list<Model> mModelList;


and Model is a class with code like follows:

Code: Select all
class Model{

   Eigen::Matrix4f mObjectCoordMatrix;
   Eigen::Matrix4f mWorldCoordMatrix;

public:
   EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
   Model();
   virtual ~Model();
};


The code only started asseting when I added the Matrix4f into model.

If anyone knows how to fix this alignment issue it'll be much help.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: UnalignedArrayAssert

Thu Dec 09, 2010 1:13 pm
This is a tough one, because the culprit is the libstdc++98 design. certain std containers have a resize method that takes an optional value_type by value instead of taking it by reference, causing it to be copied on the stack losing alignment properties. This is getting fixed in c++0x.

In Eigen 2.0, we only provide a work-around for std::vector. In Eigen 3, we also provide a work-around for std::list and std::deque: just do #include <Eigen/StdList> and make sure to use Eigen::aligned_allocator as your allocator for std::list, which will select our partial template specialization with the fix.

So either move to Eigen 3 or borrow the Eigen/StdList file from it (you may have to tweak it to work with Eigen 2)


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

Re: UnalignedArrayAssert

Sun Dec 12, 2010 12:21 am
Thanks bjacob, that fixed that problem. I upgraded to Eigen 3, placed in that header file, and declared my list as.

Code: Select all
std::list<Model, Eigen::aligned_allocator<Model> > mModelList;



I'm getting the same problem on my std::hash_map.

Error occurs here:

Code: Select all
hashMeshPool[ objFileName ] = newModel;


So I changed the declaration of hashMeshPool to the following:
Code: Select all
std::hash_map< std::string, Model, std::less<std::string>, Eigen::aligned_allocator< std::pair<std::string, Model> > > hashMeshPool;


I'm not too familar with this std::less but it just seems like you give it a class with comparision function. Is there such thing as std::less<std::string> or do I have to create my own comparision class to give less?

I'm getting a few errors like

Error 3 error C2039: 'bucket_size' : is not a member of 'std::less<_Ty>' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xhash 180
Error 4 error C2065: 'bucket_size' : undeclared identifier C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xhash 180
Error 10 error C2039: 'bucket_size' : is not a member of 'std::less<_Ty>' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xhash 180
Error 11 error C2065: 'bucket_size' : undeclared identifier C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xhash 180
Error 14 error C2039: 'bucket_size' : is not a member of 'std::less<_Ty>' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xhash 180
Error 15 error C2065: 'bucket_size' : undeclared identifier C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xhash 180
Error 20 error C2039: 'bucket_size' : is not a member of 'std::less<_Ty>' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xhash 180


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient