Re: [eigen] Decrease in performances

[ Thread Index | Date Index | More Archives ]

>>> 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:
> 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.

Implemented using __builtin_clz in the attached patch. Looks like it's
supported with recent gcc and clang compilers -- other compilers will
simply fall through to the less optimized code path. I didn't
implement a _BitScanReverse version, since (a) I don't have a Windows
machine to test on, and (b) searching suggested there was
_BitScanReverse and _BitScanReverse64, and I didn't know how to make
that play nicely with C++ templating. :)

The relevant test passes, and a back-of-the-envelope has convinced me
of the new code's correctness, but more eyeballs/brains are always


Attachment: avoid_integer_division.patch
Description: Binary data

Mail converted by MHonArc 2.6.19+