Re: [eigen] Signed or unsigned indexing

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


My experience is to always take Andrei's advices with a grain of salt:

- For the pointer/index difference, I have never been able to measure any difference in between the 2. I'll be glad to get a sample code where one can measure any difference.

- Once the war of signed/unsigned comes to an end, there is also the problem of 32/64 bits integers on a 64-bit machine. If you have bandwidth problems, or vectorized code, the choice is obvious: use 32-bits indices. But what should you do in other cases? One has to know that when if p is a pointer and k is a 32-bit integer, to get the address of p[k] one need to convert first k to a 64-bit integer. So, you might think that using 64-bit indices is better on x86-64. I even found a very contrived benchmark where it is indeed more efficient. But for almost every code, it just does not make any difference.
Andrei Alexandrescu claims that it is better to use 32 bits integers because Intel processors have more ports that can work on them, so it increases instruction level parallelism. I did not try too hard, but I have never been able to find a benchmark that shows a difference.

So be careful with Andrei. His claims are extremely difficult to check.

> On 20 Jan 2017, at 19:51, Martin Beeger <martin.beeger@xxxxxxxxx> wrote:
> 
> * Andrej Alexandrescu pointed out that whether using indices or pointers in algorithmic loops is faster seems to change every five years or so. That means, that using indices instead of pointers is a valid strategy and may increase your performance.




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