Repository navigation
Shader tests: the legacy multiply-add's rounding case takes either rounding - #1335
Open
bihanikeshav wants to merge 1 commit into
Open
bihanikeshav wants to merge 1 commit into
bihanikeshav wants to merge 1 commit into
Conversation
…unding `legacy_mad_fuses_its_product_and_flushes_its_sources` asserted a single rounding on every hardware adapter. The instruction is lowered to DXIL `FMad`, whose fusing is the driver's choice: NVIDIA's Ada driver fuses it (pull request fxceless#961), but an RTX 5060 Laptop (Blackwell, driver 610.62) rounds the product first, as WARP does, and the test failed there (case 0: got 0x00000000, want 0xa8800000), turning `cargo test --workspace` red on that card. Case 0 now takes either correct answer (fused, or product rounded first) on every device and says which it got; any other value still fails. The flushing and zero-factor cases stay exact everywhere. The doc of `legacy_fmad` says the fusing is asked for, not promised. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
Problem
legacy_mad_fuses_its_product_and_flushes_its_sourcesfails on my RTX 5060 Laptop (Blackwell, driver 610.62):Case 0 checks that
v_mad_legacy_f32rounds once. We lower it to DXILFMad, and DXIL leaves fusing that op up to the driver. NVIDIA's Ada driver fuses it (#961 ran into that from the other side). This card's driver doesn't, so the product gets rounded to 1.0 before the add and the result is +0 instead of -2^-46. WARP does the same thing, which is why the test already skipped case 0 there. #1026 was only run on WARP, so the hardware branch of that assertion never saw a card like this one.Every other case passed here. Flushing subnormal sources and the zero-factor rule both work, and those are the parts that fixed the water reflections.
Change
0xa8800000) or product rounded first (0x00000000). It prints which one it got. Any other value still fails.legacy_fmadinlower.rsnow says the fusing is asked for, not promised.No change to the translator's output.
I didn't try to force a single rounding (doing the add in f64 with round-to-odd would work). It costs several double ops per instruction, doubles are slow on consumer NVIDIA cards, and I haven't seen this last-bit difference cause anything visible. Happy to look at it if someone has a case where it matters.
Tests
On the RTX 5060 Laptop, Windows 11:
cargo test -p victory-shader --locked: 222 passed, 0 failed, 4 ignored. Before this change: 221 passed, 1 failed.--nocaptureprintshardware: FMad not fused by this host (product rounded first)and the same for warp.cargo clippy -p victory-shader --all-targets --locked -- -D warningsand the--all-featuresrun are both clean.🤖 Generated with Claude Code