RFR: 8265768 [aarch64] Use glibc libm impl for dlog, dlog10, dexp iff 2.29 or greater on AArch64.

gregcawthorne github.com+73799211+gregcawthorne at openjdk.java.net
Tue Apr 27 11:14:35 UTC 2021


On Thu, 15 Apr 2021 08:33:47 GMT, gregcawthorne <github.com+73799211+gregcawthorne at openjdk.org> wrote:

> Glibc 2.29 onwards provides optimised versions of log,log10,exp.
> These functions have an accuracy of 0.9ulp or better in glibc
> 2.29.
> 
> Therefore this patch adds code to parse, store and check
> the runtime glibcs version in os_linux.cpp/hpp.
> This is then used to select the glibcs implementation of
> log, log10, exp at runtime for c1 and c2, iff we have
> glibc 2.29 or greater.
> 
> This will ensure OpenJDK can benefit from future improvements
> to glibc.
> 
> Glibc adheres to the ieee754 standard, unless stated otherwise
> in its spec.
> 
> As there are no stated exceptions in the current glibc spec
> for dlog, dlog10 and dexp, we can assume they currently follow
> ieee754 (which testing confirms). As such, future version of
> glibc are unlikely to lose this compliance with ieee754 in
> future.
> 
> W.r.t performance this patch sees ~15-30% performance improvements for
> log and log10, with ~50-80% performance improvements for exp for the
> common input ranged (which output real numbers). However for the NaN
> and inf output ranges we see a slow down of up to a factor of 2 for
> some functions and architectures.
> 
> Due to this being the uncommon case we assert that this is a
> worthwhile tradeoff.

>From speaking to Szabolcs, the current AOR exp and log implementations have a very low ulp error (iirc < 0.51 ulp). So incorrect roundings are in fact rare, but not impossible.

Therefore It seems glibc does not guarantee monotonicity.

This is reinforced in the standard (although some aspects of this such as the table of error for AArch64 do need updating):
https://www.gnu.org/software/libc/manual/html_node/Errors-in-Math-Functions.html
"The GNU C Library does not aim for functions to satisfy other properties of the underlying mathematical function, such as monotonicity, where not implied by the above goals"

So even if it the current implementations are monotonic it seems we can't guarantee them to remain that way in future glibc versions.

Greg.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3510


More information about the hotspot-dev mailing list