Re: [eigen] Support for true Array |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Support for true Array
- From: Rohit Garg <rpg.314@xxxxxxxxx>
- Date: Wed, 25 Nov 2009 19:00:46 +0530
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=gVWponb8MEjHpZjws+5FeTpLr+HNn6v7DW/YbcaS2Bs=; b=OZycvh9l0+Z7MLmGw6Wmqf4BN0c0Vag1SdRHeFen5/XTH8t7xylGFn5XyrGzv4d2OE 5wiCYKXdpjxxG8FSFkFly1I3vsPyvG9W5gAFgM6w9ce19M3jutSFltdpZ9djl9pifrJS oZaCWHsWCkCXv879jm1/BgRd/pq/Xy0pR3Hnw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=nsewV+GcFIeBvPIZEeofuzHfW3IN4g4wZ3i6fs5zKq2gOF0UDyumZSEtF5XciP0jEe dcci4msqbt0kCe+NiTvPwAqy+Y6KKHKmHLs+hqsnoqBIA3gW1r8hPQayxlCtbc1rqsLs ChLOyhbwKT20KwyZVTM9rcoXvAg0c54hIhjLY=
On Wed, Nov 25, 2009 at 6:18 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> 2009/11/25 Rohit Garg <rpg.314@xxxxxxxxx>:
>> 1) Are there any other benefits to having an array class apart from
>> getting rid of .cwise() to do element wise multiplications?
>
> Well, that in itself is already a big advantage, as many people would
> like to use Eigen's xpr templates and vectorization on plain arrays,
> using only cwise ops.
>
> But to answer your question, there is another benefit, as we mentioned
> above: such an Array class could be used as Scalar type, so a
> Matrix<Array...,3,1> would behave like an array of Vector3's but each
> scalar operation would become an array operation. So if you are
> interested in SIMD on Vector3's and you have a large number of them,
> this approach allows you to get it!
>
>> 2) I haven't understood how this would help the quaternion class and
>> the related things.
>
> Currently the question is: how to add xpr templates to Quaternion and
> eventually DualQuaternion without rewriting all the xpr classes? Gael
> had to solve the same problem for Array and his solution was to have a
> class that has an array interface but can wrap an arbitrary xpr. Then
> the operator+ between arrays can just return a usual 'sum' xpr, but
> wrapper like that in an array interface! Thus, only operators/methods
> need to be rewritten for Array, but the underlying xpr classes that
> they return don't have to be rewritten.
>
> Then I thought: why not do the same in Quaternion? We could have a
> QuaternionWrapper class that wraps any MatrixBase for its array of 4
> coefficients; then the operator+ between quaternions returns a
> QuaternionWrapper<ordinary sum xpr>....
>
>> 3) A million Vector3f's would still not be vectorized as they are not
>> a multiple of packet size, or will they? Is there a possibility to
>> automagically handle the SOA form instead of the usual AOS form with
>> this proposal?
>
> Yes, this is exactly what I meant. (Dont quite remember what AOS
> stands for but that seems to be it).
Array Of Structures - AoS
===================
struct float2{
float x,y};
float2 arr[N];
Structure Of Arrays - SoA
===================
struct float2
{
float x[N],y[N];}
SOA form has *big* advantages for simd ops over aos.
>
> This is about creating an Array class that can be used as a scalar
> type, and on which the arithmetic ops are vectorized. So when you have
> Matrix<Array,3,1> u,v,w;
> and you do:
> u = v+w;
> this expands (thanks to Eigen xpr templates and unrollers) to:
> u[0] = v[0]+w[0];
> u[1] = v[1]+w[1];
> u[2] = v[2]+w[2];
> Each of these 3 lines is now an operation on Array objects and expands
> to a vectorized loop doing the addition.
>
> Benoit
>
>
>
--
Rohit Garg
http://rpg-314.blogspot.com/
Senior Undergraduate
Department of Physics
Indian Institute of Technology
Bombay