feat(EDyadic.Arith): exact add/sub/mul on EDyadic#788
Open
bollu wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
VeIR Benchmarks
Details
| Benchmark suite | Current: 5c33170 | Previous: eb0390c | Ratio |
|---|---|---|---|
add-fold-worklist/create |
1805000 ns (± 91057) |
2198000 ns (± 109413) |
0.82 |
add-fold-worklist/rewrite |
3431000 ns (± 87765) |
3733000 ns (± 84672) |
0.92 |
add-fold-worklist-local/create |
1821000 ns (± 60108) |
2191000 ns (± 99246) |
0.83 |
add-fold-worklist-local/rewrite |
2783000 ns (± 47752) |
3011000 ns (± 27372) |
0.92 |
add-zero-worklist/create |
1893000 ns (± 94118) |
2140500 ns (± 109777) |
0.88 |
add-zero-worklist/rewrite |
2153500 ns (± 36908) |
2383000 ns (± 53970) |
0.90 |
add-zero-reuse-worklist/create |
1526000 ns (± 29107) |
1798000 ns (± 63295) |
0.85 |
add-zero-reuse-worklist/rewrite |
1779000 ns (± 33279) |
1965000 ns (± 30368) |
0.91 |
mul-two-worklist/create |
1851000 ns (± 73840) |
2191000 ns (± 103104) |
0.84 |
mul-two-worklist/rewrite |
4815000 ns (± 157071) |
5176000 ns (± 80037) |
0.93 |
add-fold-forwards/create |
1816000 ns (± 104679) |
2174500 ns (± 97824) |
0.84 |
add-fold-forwards/rewrite |
2678000 ns (± 101787) |
2967500 ns (± 35897) |
0.90 |
add-zero-forwards/create |
1789000 ns (± 89446) |
2115000 ns (± 33441) |
0.85 |
add-zero-forwards/rewrite |
1749000 ns (± 61942) |
1903000 ns (± 16300) |
0.92 |
add-zero-reuse-forwards/create |
1532000 ns (± 63113) |
1832000 ns (± 91568) |
0.84 |
add-zero-reuse-forwards/rewrite |
1508000 ns (± 63859) |
1555000 ns (± 50375) |
0.97 |
mul-two-forwards/create |
1829000 ns (± 33144) |
2126000 ns (± 70864) |
0.86 |
mul-two-forwards/rewrite |
3245000 ns (± 118008) |
3520000 ns (± 48872) |
0.92 |
add-zero-reuse-first/create |
1521000 ns (± 60986) |
1827500 ns (± 94828) |
0.83 |
add-zero-reuse-first/rewrite |
10000 ns (± 2149) |
8000 ns (± 1592) |
1.25 |
add-zero-lots-of-reuse-first/create |
1524500 ns (± 52960) |
1773000 ns (± 69739) |
0.86 |
add-zero-lots-of-reuse-first/rewrite |
807000 ns (± 60488) |
759000 ns (± 9407) |
1.06 |
This comment was automatically generated by workflow using github-action-benchmark.
8f251b4 to
25cc785
Compare
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.
What
Adds exact (unbounded) arithmetic on
EDyadic:EDyadic.add,EDyadic.sub,EDyadic.mulwithAdd/Sub/Mulinstances. Dyadics are closed under +/−/×, so these are computed exactly with no rounding.add: common scaleK := max ka kb, numeratorna·2^(K-ka) + nb·2^(K-kb), rebuilt viaDyadic.ofIntWithPrec; exact cancellation collapses to a (provisional) zero.sub a b := add a (-b).mul:ofIntWithPrec (na*nb) (ka+kb).∞ + (−∞) = NaN;∞ * 0 = NaN; sign rules incl. signed zeros.Tests in
UnitTest/FP/EDyadic/Arith.leancheck exact values and special cases.Note on the sign of an additive zero
This layer is mode-free, so it does not decide the sign of an additive zero (
x + (−x), or mixed-sign zero operands). Per IEEE-754 §6.3 that sign is mode-dependent (+0exceptRTN→−0), and a zero value no longer records its operands — soaddreturns a provisional zero and the mode-awareEDyadic.addRound(in theedyadicfloat-opsPR, #791) assigns the correct sign.mul's zero sign is the mode-independent xor and is set here.Stack
Part of
full-precision-floats-edyadic(patch 1/6). Base:round-edyadic-fastfloat(#787).🤖 Generated with Claude Code