mpn_sqrtrem{1,2}
Torbjörn Granlund
tg at gmplib.org
Fri Mar 17 10:12:23 UTC 2017
"Marco Bodrato" <bodrato at mail.dm.unipi.it> writes:
But it can be useful on some platform. Say mpn/x86_64 ? or
mpn/x86_64/fast{sse,avx} ?
When it's know to be supported and for CPUs where it is kmown to run
well, sure.
We should never use the old x86 FPU stack with 80-bit FP registers.
> is not predicatble enough. Even if we do it just for IEEE 754, we can
> not control the rounding mode. That means that e.g., sqrt(2)^2 will be
> greater that 2 sometimes, less than 2 sometimes.
All the algorithms I see implemented in GMP for sqrt give the wrong result
sometimes... that's why they all have a final check with possible
correction by 1. I'm sure that also this "sometimes" can be correctly
handled :-)
Testing needs to involve manipulating the rounding mode if the used
instructions change their behaviour according to such a mode.
It might be worth noticing that some recent CPUs have fast integer
division, using up to 4-bit SRT and early-out, meaning that a 64-bit
division takes from about 4 to about 20 cycles. There, one might be
able to write basecase code using plain old integer divide.
--
Torbjörn
Please encrypt, key id 0xC8601622
More information about the gmp-devel
mailing list