[libre-riscv-dev] div/mod algorithm written in python
Jacob Lifshay
programmerjake at gmail.com
Tue Jul 9 02:58:40 BST 2019
On Mon, Jul 8, 2019 at 4:34 PM Luke Kenneth Casson Leighton
<lkcl at lkcl.net> wrote:
>
> On Mon, Jul 8, 2019 at 10:23 PM Jacob Lifshay <programmerjake at gmail.com> wrote:
>
> > For verifying frsqrt, we could use the bigfloat library (python bindings to
> > mpfr).
>
> hmmm... a second (large) library as a major dependency... hmmm...
shouldn't be too much of a problem, since mpfr is a gcc dependency, so
should be on pretty much all systems.
>
> > It supports emulating different ieee 754-2008 fp formats. We will
> > have to remember that ieee 754-2008 defines sqrt(-0) to be -0 and rsqrt(-0)
> > to be -infinity (not +infinity).
>
> the reason for using sfpy is because softfloat has specifically been
> written to emulate risc-v (in full). all of the rounding modes,
> tininess, they're all there [except sfpy doesn't expose the tininess
> modes through the bindings yet] and all properly compatible.
I think mpfr allows changing all those settings at run-time, so making
it risc-v compatible shouldn't require modification of mpfr's source.
Additionally, mpfr is an arbitrary-precision fp library, so we can use
it to compute exact results (or at least to thousands of bits) and
verify that our operations generate the same results.
>
> using bigfloat is therefore a lot more work than it first appears.
that's true, however using an already existing and known to be correct
library to test rsqrt is better than having to write and verify a
custom modification to softfloat, since softfloat doesn't have a rsqrt
operation.
Jacob
More information about the libre-riscv-dev
mailing list