Jump to content
Excelsior Forums
lemming

Math calculations

Recommended Posts

First of all I have to say that this might not be a Defect Report at all.

However it felt to me that this is the most appropriate forum to post my question.

When running an application on the Sun JVM performing multiple trigonometric calculations the results differ when running the same code compiled to an executable using JET.

I wonder if this is the result from different JVM's.

Maybe this is the result of optimizing the cos / sin methods of the Math lib?

If so, can we switch this off?

I do not claim one JVM is better then the other, I just would like to have the same results for both JVM's.

I attached a Java class that I used to detect the differences, I ran the code once in Eclipse and then again using the compiled exectable. I performed both the runs on the same machine to be sure it is not a machine precision difference.

Thank in advance!

Greetings, Seb

ExeVsJarValidation.java

Share this post


Link to post
Share on other sites

Dear Seb,

Excelsior JET has passed the Sun JCK testsuite which includes a massive part of FP tests.

Therefore, the compiler does not optimize the FP code more than it's allowed by the Java specification.

Our vision is that the code must be correct and only then we may consider making it faster.

As for your example, we are ready to check it on our end.

Could you make it compilable with javac? In the current form, it has lots of (unresolved) dependencies when being compiled.

Thank you.

Share this post


Link to post
Share on other sites

Thank you for the quick reply. My apologies for attaching the code with the dependencies, I added a new version.

Some more info;

- we ran the code on jre1.6.0_04 and again as test on jre1.6.0_10

- we build the executable with JET v.6.4 Professional, Active Java SE Version 1.6.0_10 XDS link v.2.11.16

The example takes one argument from the command line which is the file name to write the test results to.

(Note the file will be overwritten if already exist!)

After running it from Eclipse and Excelsior we did a text compare on the two results files.

(I must say that the diffirences are very small)

Thank you for your time, it is very much appreciated.

Seb

ExeVsJarValidation.java

Share this post


Link to post
Share on other sites

Is anyone looking at this or should a send an email to the Excelsior Java Team?

(Sorry to post this, but the private message system seems to be disabled)

Share this post


Link to post
Share on other sites

Is anyone looking at this or should a send an email to the Excelsior Java Team?

It is better to send messages to the Excelsior Java Team if you need reply as soon as possible, because the forum has lower priority for monitoring.

I have just compiled your test program with javac, executed it on Sun JVM and got the following:

Starting validation test to try to find differences in JVM calculations

File name not set!

How should I proceed?

Share this post


Link to post
Share on other sites

It is better to send messages to the Excelsior Java Team if you need reply as soon as possible, because the forum has lower priority for monitoring.

Thanks, I'll try next time :)

I have just compiled your test program with javac, executed it on Sun JVM and got the following:

Starting validation test to try to find differences in JVM calculations

File name not set!

How should I proceed?

The example takes one argument from the command line which is the file name to write the test results to.

(Note that the file will be overwritten if already exist)

I run the test as executable and from Eclipse generating two different files and then did a text compare to check for

differences.

Thank for trying!

Share this post


Link to post
Share on other sites

I have reproduced the misbehavior. Thank you for the sample.

We will examine it and  if it is proved to be a bug we will try to fix it.

If you have an active Support Contract please contact Excelsior Java Team to get the hotfix for the problem.

Share this post


Link to post
Share on other sites

Hi,

As you can see in the Java SE API documentation, these 3 methods (Math.asin, Math.acos, Math.atan) need not produce the same results on different VM implementations.

The only constraint is: "The computed result must be within 1 ulp of the exact result.  Results must be semi-monotonic." (see http://java.sun.com/javase/6/docs/api/java/lang/Math.html#asin(double))

If you want to get the same bitwise results, you should use methods of java.lang.StrictMath instead.

I have investigated the differences between JET and Sun HotSpot, compared the results with high precision (112-bit mantissa) results obtained with HPAlib library (http://www.nongnu.org/hpalib/) and confirm that JET implementation of these methods is correct according to java.lang.Math specification.

Regards,

Pavel Pavlov.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×