Sujet : Faster div or 1/sqrt approximations (was: Continuations)
De : tkoenig (at) *nospam* netcologne.de (Thomas Koenig)
Groupes : comp.archDate : 19. Jul 2024, 21:25:51
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v7ei4f$34uc2$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : slrn/1.0.3 (Linux)
MitchAlsup1 <
mitchalsup@aol.com> schrieb:
I, personally, have found many Newton-Raphson iterators that converge
faster using 1/SQRT(x) than using the SQRT(x) equivalent.
I can well believe that.
It is interesting to see what different architectures offer for
faster reciprocals.
POWER has fre and fres (double and single version) for approximate
divisin, which are accurate to 1/256. These operations are quite
fast, 4 to 7 cycles on POWER9, with up to 4 instructions per cycle
so obviously fully pipelined. With 1/256 accuracy, this could
actually be the original Quake algorithm (or its modification)
with a single Newton step, but this is of course much better in
hardware where exponent handling can be much simplified (and
done only once).
x86_64 has rcpss, accurate to 1/6144, with (looking at the
instruction tables) 6 for newer architectures, with a throuhtput
of 1/4. So, if your business depends on calculating many inaccurate
square roots, fast, buy a POWER :-)
Other architectures I have tried don't seem to have it.
Does it make sense? Well, if you want to calculate lots of Arrhenius
equations, you don't need full accuracy and (like in Mitch's case)
exp has become as fast as division, then it could actually make a
lot of sense. It is still possible to add Newton steps afterwards,
which is what gcc does if you add -mrecip -ffast-math.