Disabling DomainError (in sqrt())?

https://groups.google.com/a/groups.riscv.org/g/isa-dev/c/SLprSJzpgCQ/m/WdvNwTd0DAAJ

The operation implemented by frsqrt.* is a correctly-rounded implementation of the IEEE 754-2008 rSqrt operation
[…]
The instruction can be considerably faster if it’s required to be within 1-ulp than if it’s required to be correctly rounded.

At least there seems to be “the IEEE 754-2008 rSqrt operation” (just not sure if it’s only a recommendation).

Would it be allowed to convert 1/sqrt(x) to use the more accurate @fastmath method (which seems to be a win-win, also faster), by default? I’m not sure the standard would require it rather in function form, but I do see at least at least one libm has it (are they standardized, I mean the number of functions)?)

https://www.ibm.com/docs/en/aix/7.2?topic=r-rsqrt-subroutine

We’re about to get rid of libm in Julia, but I’m not sure it has rsqrt, or we were ok with dropping it since not used since not required.

There’s of course no requirement to include less accurate versions in Julia Base, I just thought easily possible. But more accurate should be welcome? [Though I don’t just want to get rid of LinuearAlgebra from the sysimage, I kind of want all floating-point gone too, since not required by Julia iseelf/the compiler…]

If you have a series of ops, here sqrt, then /, I believe each must be correctly rounded, meaning to one ULP, does that mean both to 2 ULPs? I’m not sure it applies always, but in this case?

rsqrt is important enough to be in standards and in hardware, but I suppose sqrt(1/x) isn’t too common. I guess it could however also be made more accurate (and faster?). I’m just trying to learn from the conversation.

Of some interest:

rsqrt is a recommendation in older IEEE, and one of the functions we “need” to implement in Julia and “should define”:

In addition to Base.sqrt_llvm there’s Base.sqrt_llvm_fast, and we “should” implement rootn(x, n) not just sqrt, so I’m not sure we should add at least the more accurate versions to your package, though maybe the less accurate and faster versions.

1 Like