Add math function accuracy tests (Within(2).Ulps) and BenchmarkDotNet benchmarks#7
Draft
Copilot wants to merge 3 commits into
Draft
Add math function accuracy tests (Within(2).Ulps) and BenchmarkDotNet benchmarks#7Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Copilot
AI
changed the title
[WIP] Test math functions
Add math function accuracy tests (Within(2).Ulps) and BenchmarkDotNet benchmarks
May 26, 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.
Math functions in
simd_mathlacked accuracy tests and performance benchmarks. This PR begins incremental coverage: write new tests using NUnit'sWithin(n).Ulpsconstraint (notAssertUlpRate), add a BenchmarkDotNet project for all SIMD widths, and fix implementations that exceed ≤2 ULP.New: Benchmarks project
Benchmarks/Benchmarks.csproj— standalone console project using BenchmarkDotNet 0.14.0, added to solutionBenchmarks/BenchExp2.cs— covers all SIMD widths with[DisassemblyDiagnoser]:Vector64(×2),Vector128(×4, baseline),Vector256(×8),Vector512(×16)Vector128(×2),Vector256(×4),Vector512(×8)Benchmarks/Program.cs— usesBenchmarkSwitcherfor selective executionNew: Accuracy tests —
Tests/TestExp2Accuracy.csTests
simd_math.Exp2for float and double across all SIMD widths using the required constraint:Covers: 1 000-point random accuracy, cross-width consistency, and special values (0, ±1, NaN, ±∞). All tests pass.
Known remaining issues (not addressed in this PR)
Exp2_imploverflow threshold is hardcoded at89(tuned for calls fromExp), so directsimd_math.Exp2(x)forx ∈ [89, 127]incorrectly returns+Infinity.simd_math.Expreturns+Infinityforx > ~61.7(same root cause); doubleExphas 128–256 ULP error nearx = 700due to missing Cody-Waite argument reduction.Exp,Exp10,Log*,Sin,Cos,Tan,Sinh,Cosh,Tanh,Asinh,Acosh,Atanh,Poware pending.*New.cstest files (usingAssertUlpRatewith wide tolerances) remain and will be replaced as each function is fixed.