[JBS] {New} (JDK-8170430) x86 pow() stub from Intel libm is inconsistent with pow() from fdlib

Volker Simonis volker.simonis at gmail.com
Wed Nov 30 17:35:18 UTC 2016


what is the actual problem here? Is it the fact that Math.pow()
returns different results depending on whether it is executed in
interpreted or in JIT-compiled mode?

Or in other words - do we insist on having the same results from the
Math functions while promoting from Interpreted to C1 and finally C2?
The API-doc for Math says: "Unlike some of the numeric methods of
class StrictMath, all implementations of the equivalent functions of
class Math are not defined to return the bit-for-bit same results.
This relaxation permits better-performing implementations where strict
reproducibility is not required." But I'm not sure if this implies
that Math.FUNC(constant_value) always has to return the bit-for-bit
same result no matter how often we call it?

The problem is that by default the Java implementation of the Math
functions call the StrictMath version. So if the interpreter does no
optimizations, it will get the exact StrictMath (i.e. fdlibm) results.
But when the Math methods are compiled, they may be intrinisfied, in
which case they are allowed to return less exact values. A further
complication is that the interpreter may optimize himself and either
use  optimized assembler stubs for a function (e.g.
StubRoutines::_dsin()) or uses leaf-calls into HotSpots internal
C++-Implementation of the functions (e.g. SharedRuntime::dsin()).

So what does "strict reproducibility is not required" for Math
functions actually mean? Is it OK for a program like this:

while(true) {
  if (Math.FUNC(val) == XXX) System.out.println("YES");
  else System.out.println("NO");

to print both, "YES" and "NO"?

Thank you and best regards,

On Wed, Nov 30, 2016 at 2:34 AM, Vladimir Kozlov
<vladimir.kozlov at oracle.com> wrote:
> Thank you, Vivek
> I will sponsor it.
> Do you think it is hard to fix stubs code even in some next release?
> Thanks,
> Vladimir
> On 11/29/16 5:26 PM, Deshpande, Vivek R wrote:
>> Hi
>> I have bug fix  for avx512 8170430.
>> http://cr.openjdk.java.net/~vdeshpande/8170430/webrev.00/
>> I have also updated the JBS entry.
>> https://bugs.openjdk.java.net/browse/JDK-8170430
>> I have tested it with other libm stubs too along with pow.
>> Would you please review and sponsor it.
>> Regards,
>> Vivek

More information about the hotspot-compiler-dev mailing list