Re: [eigen] Indexes: why signed instead of unsigned?

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


2010/5/17 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:
>
>
> On Mon, May 17, 2010 at 5:07 AM, leon zadorin <leonleon77@xxxxxxxxx> wrote:
>>
>> 'mul' being magnitude of times slower for 64 bits ints
>
> same here. I believe Benoit did not notice any speed difference because his
> CPU is more recent that ours.

Oh right, this is on a Core i7.

*starts up big motorbike*

> Anyway this benchmark does not represent
> typical use cases of sizes & indexes. In theory the compiler should not have
> to issue integer multiplication inside inner loops but simply increments
> some registers. I verified that for simple expressions. Unfortunately for a
> more complex one involving more complex addressing like:
>
> c.block(1,12,50,89) += a.block(7,3,50,89) + b.block(70,35,50,89);
>
> it seems that GCC fails at generating good code and issue 3 imull in the
> most inner vectorized loop. The non vectorized loops (to deal with
> boundaries or when vectorization is disabled) are fine though... ahhhh
> compiler weirdnesses....

argh, this is pretty bad! Hm though... for large enough blocks, this
operation is totally memory-bound anyway. But then I guess the same
phenomenon will happens in CPU-bound loops, bad bad bad...!

One more reason why the LinearAccessBit is important, when it's present.

If nothing else works, we could specialize the loops also in the
DirectAccessBit case and write them by manually incrementing pointers.

> Anyway, the change Benoit is doing is the necessary step to offer more
> flexibility, then we can bench real world expressions, and finally make a
> decision for the default index/size type of Matrix. According to the result
> of the benchs, I see two options:
> 1) always use ptrdiff_t
> 2) default is int + one Matrix's Option to use int64

I was going to do:

3) Default is ptrdiff_t
   + make it easy to override this global default by a macro e.g.
EIGEN_USE_INT_INDICES
   + later if you want we can add a Matrix option to use int.

Benoit

>
>
> gael
>



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