Re: [eigen] Decrease in performances

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


On 25.06.2012 19:01, Rhys Ulerich wrote:
I guess it can easily be replaced by 128bit integer multiplication. I
suggested that back then, but I guess it was ignored due to portability
concerns:
http://listengine.tuxfamily.org/lists.tuxfamily.org/eigen/2011/10/msg00041.html

For int32*int32 overflow detection on platforms lacking int128s, could
one use double*double operations and compare to
numeric_limits<int32>::max() since double can represent a seriously
wide range of integers exactly?

Well, for int32*int32 you only need int64 for the result.
I would rather suggest to implement a grid multiplication if 2*sizeof(size_t) is not available.

But you are right, casting to double and multiply would also be a valid fallback in general (caution needs to be paid when casting int64 to double) and should be faster than integer division (depending on the platform of course).

Yet another alternative might be to just check for the highest bit of both factors (__builtin_clz in gcc; _BitScanReverse in MSVC). If the sum is <= sizeof(size_t)*8-2, the integer multiplication should not overflow, otherwise at least a*b*sizeof(float) would overflow.

Christoph


--
----------------------------------------------
Dipl.-Inf. Christoph Hertzberg
Cartesium 0.049
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/