Improve accuracy testing method#4
Open
jouae wants to merge 2 commits intoMax042004:mainfrom
Open
Conversation
The range1 should be [0.140625,pi/2], which is from 0x3E10 (0.140625) to 0x3FC9 (1.5703125, rounded pi/2) and the representable number is 441 not 450. Since the inf and -inf in BF16 are 0x7F80 and 0xFF80, the test range2 should be fixed as [pi/2,+largest], where +largest is the largest positive normal BF16, that is +largest=0x7F7F. Similarly, range3 should fixed as [-smallest, -largest], where -largest is the largest negative normal BF16, that is +largest=0xFF7F.
The current accuracy testing method is based on the sinf implementation
in glibc. This implementation, introduced by Wilco Dijkstra in
release 2.29 [1], reports:
Worst-case ULP is 0.5607, maximum relative error is 0.5303 * 2^-23
Use GNU MPFR (GNU Multiple Precision Floating-Point Reliable) [3], a
verified high-precision floating-point library, as the comparison
baseline—similar to the approach used in glibc benchtests.
This avoids relying on any particular standard library.
Reference:
[1] glibc - release 2.29 - s_sinf.c
[2] Gladman, B., Innocente, V., Mather, J., & Zimmermann, P. (2025).
Accuracy of mathematical functions in single, double, double
extended, and quadruple precision.
[3] https://www.mpfr.org/
Signed-off-by: jouae <oipc9801@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve testing method, including
For example, range1.log
The difference of output is as following:
Close issue #3
Reference:
[1] https://www.mpfr.org/