|Re: [eigen] eigen3: assertion on unaligned arrays|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [eigen] eigen3: assertion on unaligned arrays
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Wed, 1 Sep 2010 07:56:36 -0400
- Cc: Radu Bogdan Rusu <rusu@xxxxxxxxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=CDpPR7JLkmzZf/4yailCqU16zu2Q4MRs34k67kQA0LA=; b=khdQSev9CdpnB6d9biogusFaHHUFcYgZ57zd0JCAiMSyCoevYWL10TAybocYGT94pE 6vN2pFgU7vWERHRnMS89ZS+PzcZUvEMuRfebtoEV9KewyU+v1UhErLRdWQ2lLkAnfWxj h7muDIwasyszok5VqSkUj10sxG1YPvMsQdxx0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=oCBks9KSi3TeZZG19+GLy4xYWD2neahcaFNijsDIhARf/q9lr3KgCP0Yxj//8bI9wb +KIp9pYeefzthq4fZaVQXJWXQUP1/4kdg+/HWPyeSCFbyI7CBYN7GRXlqV9RpOdB774L 6AIm+tol2HS9FovCRko3IpB/s2mgtHxABhTZg=
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:
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,
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).
> 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.
>> 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
>>> all the einge2 procedures apply to eigen3 as well.
>>> | Radu Bogdan Rusu | http://rbrusu.com/
> | Radu Bogdan Rusu | http://rbrusu.com/