Re: [eigen] eigen3: assertion on unaligned arrays

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


2010/8/31 Radu Bogdan Rusu <rusu@xxxxxxxxxxxxxxxx>:
> Thanks Benoit. Is there something that can be done in the near future
> regarding this or are we waiting for newer gcc revisions, etc?

If this is really a big concern to you, consider defining
EIGEN_DONT_ALIGN_STATICALLY. This will get you rid of it. You will
lost vectorization of fixed-size operations, but will retain
vectorization of dynamic-size operations. However, it is
ABI-incompatible with the default.

Other than that, it all depends on what is causing you trouble with
unaligned arrays. In this page, we detail 4 possible causes:
http://eigen.tuxfamily.org/dox-devel/TopicUnalignedArrayAssert.html

The situation is different depending on which of these 4 case you fall into.

Cause 1: Structures having Eigen objects as members

 -> The underlying problem is that C++98 doesn't have any support for
specifying non-default alignment for a data type. The solution should
eventually come from C++0x's "alignas" keyword. Although the spec
proposal says that it does not require anything on heap allocation,
compiler implementers would be foolish to not let it control heap
allocation too. So this will be fixed in C++0x. Unfortunately,
according to
http://gcc.gnu.org/gcc-4.6/cxx0x_status.html
This "alignas" is still not supported in gcc's c++0x mode.

Cause 2: STL Containers

 -> The underlying problem is that in C++98's STL, most containers
have a resize() method where the optional second argument (the element
to initialize new entries as) is passed by value. This is fixed in
C++0x, where they are passed by reference. I don't know, perhaps GCC's
C++0x mode is already fixed in that respect.

Cause 3: Passing Eigen objects by value

 -> this is pointless anyway.

Cause 4: Compiler making a wrong assumption on stack alignment (for
instance GCC on Windows)

 -> this should have been fixed in GCC 4.5  (it was a GCC bug).


Cheers,
Benoit

>
> Cheers,
> Radu.
>
> On 08/31/2010 03:05 PM, Benoit Jacob wrote:
>>
>> Not much.
>>
>> As you mention on your wiki, EIGEN_ALIGN_128 renamed to EIGEN_ALIGN16.
>>
>> Also, there now is EIGEN_DONT_ALIGN_STATICALLY. It is enough to fix
>> unaligned array asserts, but retains vectorization for heap-allocated
>> objects. That's explained on the dox page.
>>
>> Cheers,
>> Benoit
>>
>> 2010/8/31 Radu Bogdan Rusu<rusu@xxxxxxxxxxxxxxxx>:
>>>
>>> Just wondering if anything has changed from eigen2 to eigen3 in terms of
>>> assertion on unaligned arrays
>>> (http://eigen.tuxfamily.org/dox-devel/UnalignedArrayAssert.html), or
>>> whether
>>> all the einge2 procedures apply to eigen3 as well.
>>>
>>> Thanks,
>>> Radu.
>>> --
>>> | Radu Bogdan Rusu | http://rbrusu.com/
>>>
>>>
>>>
>>
>>
>
> --
> | Radu Bogdan Rusu | http://rbrusu.com/
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/