mpn_sqrtrem{1,2} - rounding mode - erratum
Vincent Lefevre
vincent at vinc17.net
Sun Mar 26 00:50:32 UTC 2017
On 2017-03-26 00:54:50 +0100, Adrien Prost-Boucle wrote:
> > I tested with a function that repeatedly sets all rounding modes.
> > The result is: 995413 calls to fesetround() per second on my laptop
> > That's extremely slow given the speed of the sqrt function!
>
> Ooops there was a typo in my code: division by 4 instead of
> multiplication by 4 (the number of rounding modes).
> The actual speed is 15 million mode changes per second.
> This is still not enough anyway.
> But I didn't investigate how it's implemented in asm.
The number of calls per second is not the only problem. Changing
the rounding mode may have the effect to flush the floating-point
pipeline (though I don't know whether this matters here).
> > GMP should absolutely not play with FP rounding mode,
> > not even for some fringe configuration.
>
> OK, things will be simpler that way :-)
But note that if the inexact exception is trapped, the code will
no longer work. If the user thought that GMP would not use FP
(as this was currently the case?), he may have some surprises.
--
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the gmp-devel
mailing list