Re: [eigen] Issues regarding Quaternion-alignment and const Maps

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


On Fri, Jul 23, 2010 at 1:57 AM, Christoph Hertzberg
<chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Christoph Hertzberg wrote:
>>
>> Gael Guennebaud wrote:
>>>
>>> On Wed, Jul 7, 2010 at 9:56 AM, Christoph Hertzberg
>>> <chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>>>>
>>>> Hi,
>>>>
>>>> first of all great work, everyone!
>>>>
>>>> I have two issues with Eigen2, which I'm not sure Eigen3 has solved/will
>>>> solve (I did look at the new source, but might have overlooked
>>>> something).
>>>>
>>>> First, I guess there is no (easy) possibility to have an not-aligned
>>>> quaternion (without disabling alignment globally).
>>>> For ordanary matrices there is a Eigen::DontAlign option, which I
>>>> haven't
>>>> found for Quaternions. And currently I don't see a very lot of gain in
>>>> vectorization of Quaternions, especially (quaternion * vector3) is not
>>>> vectorized, and (quaternion * quaternion) only for float (at least in
>>>> Eigen2).
>>>
>>> With Eigen3 you can map unaligned data as a Quaternion, but that's
>>> less convenient. So you would like a DontAlign option, e.g.:
>>>
>>> Quaternion<double,DontAlign>
>>>
>>> Then we should also add such an option to Translation and Transform.
>>>
>>> Why not.
>>
>> I implemented it for Quaternions. Once I dug through all the code it
>> wasn't even that hard ...
>>
>> I'm not entirely sure if
>>
>>  typedef Quaternion<_Scalar, PacketAccess> PlainObject;
>>
>> in struct ei_traits<Quaternion<_Scalar, _PacketAccess> >
>>
>> actually needs to have the same PacketAccess (as far as I looked, it was
>> not used anywhere ...)
>>
>>
>> Patch is attached.

first of all thank you for the patch.

> Hm, everything I tried was running, but I didn't actually look at the
> generated assembler. Using this patch it never generates SSE optimized
> multiplication ...

Yes, if such a small object is not aligned then we don't vectorize at
all because the required unaligned loads would kill the performance.

> Seems like I misunderstood PacketAccess vs Options.
> If I see it correct now, I have to name the template parameter Options,
> and make the enum PacketAccess within the traits be Unaligned or Aligned
> depending on DontAlign being set in Options of Quaternion.
> Before I make the next patch, could someone confirm this?

Yes you are right, the idea is to have a more general Options template
parameter just like for Matrix, pass it to the Matrix<> type defining
the Coefficients type, and then appropriately set PacketAccess to
Unaligned or Aligned.

> And another question: Do I have to make sure, that no Options besides
> DontAlign can be set?

would be nice. For instance you could add a protected
check_template_param() containing a static assertion in Quaternion
that would be called by each constructor.

gael

>
> Christoph
>
> --
> ----------------------------------------------
> Dipl.-Inf. Christoph Hertzberg
> Cartesium 0.051
> Universität Bremen
> Enrique-Schmidt-Straße 5
> 28359 Bremen
>
> Tel: (+49) 421-218-64252
> ----------------------------------------------
>
>
>



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