-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not work on Apple M1 CPU #5
Comments
Sorry to hear you are having issues. I will see if I can work through them...
So, max and min have a slightly ... chequered history in IEEE-754. They are not in 1985/1989 at all, which meant that people implemented various different things. For example, in C, whether you pick C99 (ISO-9899:1999 specifically) adds the
( Appendix F is the binding between the C standard and IEEE-754 ) which has the following to say:
So, in ISO-9899:1999, The next revision of IEEE-754 in 2008 adds (5.3.1) the following:
So, in IEEE-754:2008 ISO-9899:2011 is exactly the same as ISO-9899:1999 in this regard and still binds to IEEE-754:1989. The SMT-LIB 2.* floating-point is based on IEEE-754:2009 and says:
So During the discussions in updating IEEE-754, it was discussed that the semantics for max and min in IEEE-754:2008 are a mistake. This includes a fairly comprehensive survey of what people actually do. https://754r.ucbtest.org/minutes/2017-01-19-minutes.txt In IEEE-754:2019
So So that is the standard point of view, but what about what SymFPU implements? The encoding Line 202 in c3acaf6
fixes symfpu/applications/implementations.h Line 119 in c3acaf6
symfpu/applications/implementations.h Line 779 in c3acaf6
So, my guess as to what is going on:
HTH and sorry for the rant. I'm aiming a new SymFPU version for September and will try to fix as much of this as possible. |
I have only a tiny bit to add to Martin's excellent answer, just to illustrate the point, which is the behaviour on Intel (when using the built-in min/max) generally gives you the first parameter back in the case of +/- 0 (i.e. |
Actually, one more thing to add: if you do want a 3rd extremely independent test oracle that very precisely follows IEEE-754:2008 consider looking at https://github.com/florianschanda/PyMPF which we wrote to validate all this; specifically because it'll throw you an exception if you enter an area where the answer is unspecified. |
Thanks for the feedback. Here's more detail on what's going on:
The minNum(x,y) and maxNum(x,y) operations follow the IEEE 754-2008 standard and return the numerical operand when one operand is numerical and the other a quiet NaN. Apart from this additional handling of a single quiet NaN the result is then identical to min(x,y) and max(x,y). The min(x,y) and max(x,y) operations return a quiet NaN when either x or y is NaN |
It also fails on my intel machine (with the same behavior for max/min when one argument is |
The code does not compile on MacOS but that can be fixed.
But after fixing the compilation issues, the test fails for max and min.
The reference implementation does this:
The computed values don't agree with this. I'm not sure who is right.
Here are some of the failed tests (for min):
The compiler is clang++:
and here are the compilation flags I used:
But it looks like
-ffp-model=strict
is ignored by this compiler.The text was updated successfully, but these errors were encountered: