[libre-riscv-dev] FP unit testing (was Re: [isa-dev] FP reciprocal sqrt extension proposal)
luke.leighton at gmail.com
Sun Jul 14 09:27:36 BST 2019
On Sunday, July 14, 2019 at 8:39:48 AM UTC+1, Jacob Lifshay wrote:
> > using bigfloat to perform the reciprocal-square-root in a much higher
> precision will cover the requirement to provide accurate FPSQRT. however
> the corner-cases (at the extreme limits of the exponent, and when the
> mantissa's MSB is zero) are going to be a bundle of fun.
> Note that mpfr has code to emulate fixed-size floating point numbers,
> including handling denormal numbers. It also has mostly (see caveats)
> the same special-case semantics (+-0, +-Inf, NaN) as IEEE 754, so that
> should make it a lot easier to use.
that's interesting. some IEEE754-like contexts are provided.
> MPFR is used in gcc to evaluate floating-point expressions at compile
> time, so it is well-tested and likely to be correct.
> mpfr does, however, have some notable caveats: see
under-normalisation not supported, because, obviously, with an
arbitrary-sized exponent you don't need to lose accuracy in the mantissa.
>>> from bigfloat import BigFloat
>>> b = BigFloat(1.0)
(False, '10', -1)
>>> b = BigFloat(52.39)
(False, '52390000000000000568434189', -24)
ah ha! perfect! that's exactly what we need. and there's a
"BigFloat.fromhex()" function as well, so it will be possible to transfer
numbers in and out of bigfloat, in order to perform conversions to (full)
IEEE754 FP16/32/64 format.
i am still puzzled as to how a *soft* FP rsqrt implementation may be
verified and found to be a correct implementation of the IEEE754 standard.
More information about the libre-riscv-dev