[HIP] Add f64 math accuracy test for exp, exp2, exp10#370
Open
[HIP] Add f64 math accuracy test for exp, exp2, exp10#370
Conversation
Add an E2E test that verifies GPU exp/exp2/exp10 results are within 1 ULP of host-computed references for f64 inputs. Tests 2316 values covering special cases, the full [-700, 700] range, and small values near zero. This ensures that changes to math lowering (e.g. switching from OCML library calls to compiler builtins) maintain accuracy.
arsenm
reviewed
Mar 16, 2026
arsenm
left a comment
There was a problem hiding this comment.
This isn't that comprehensive or pluggable for other functions
arsenm
reviewed
Mar 20, 2026
arsenm
reviewed
Mar 20, 2026
- Template ulp_distance, compute_exp kernel, and test_func over T - Add IntRep trait to map float types to same-size integers for ULP - Add special inputs: inf, -inf, NaN, denorm_min, min, max - Use type-appropriate ranges: f32 [-87,87], f64 [-700,700] - Use std::copy instead of memcpy for array assembly - Add comment explaining the ULP integer-subtraction technique
b7fcee3 to
1915521
Compare
arsenm
approved these changes
Mar 25, 2026
arsenm
left a comment
There was a problem hiding this comment.
This could do a lot more but it's better than nothing
| return 0.0; | ||
| using I = typename IntRep<T>::type; | ||
| I ai, bi; | ||
| memcpy(&ai, &a, sizeof(T)); |
There was a problem hiding this comment.
Would be better to implement this with ilogb like OpenCL conformance
jplehr
approved these changes
Mar 30, 2026
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.
Add an E2E test that verifies GPU
exp/exp2/exp10results are within 1 ULP of host-computed references for f64 inputs. Tests 2316 values covering special cases (0, denormals, large values), the full [-700, 700] range, and small values near zero.This ensures that changes to math lowering (e.g. switching from OCML library calls to compiler builtins as in llvm/llvm-project#185947) maintain numerical accuracy.
Tested on gfx1100: all 2316 test points pass for all three functions with worst case exactly 1 ULP.