Repository navigation
pknorm_probe: v_cvt_pknorm_* give 0 for NaN on RDNA2, but round the exact product once (SHADER-339) - #2028
Merged
Conversation
…xact product once (SHADER-339) tools/pknorm_probe.py runs v_cvt_pknorm_i16_f32 / v_cvt_pknorm_u16_f32 through the translator on the CPU interpreter and, with --oracle hw, natively through tools/hw_oracle in wave32 and wave64 under five MODEs. On an RDNA2 iGPU (gfx1036) every NaN half (74 of 74: quiet, signalling, both signs, payloads, in S0 and S1) gives 0, as the translator assumes, whatever IEEE, DX10_CLAMP and the f32 denormal mode are. The rounding does not match: the hardware rounds the exact product x * 32767 (or 65535) once, while the translator rounds the f32 OpFMul product and then RoundEven, one off on 28 of 28 near-tie inputs in both directions. Recorded in docs/design.md and docs/shader_validation.md; the translator is not changed here. tests/test_pknorm_probe.py checks four near-tie words against a hand derivation and the translator side's double rounding and NaN zero.
2 tasks done
Merged
2 tasks done
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.
Claimed in the coordination issue as: SHADER-339 (#1902 (comment))
Depends on: #2067 (conflict only). #2067 removes the duplicate
v_cvt_pknorm_*row indocs/design.md, and this PR edits both copies the same way. Whichever merges second keeps one row, with this PR's text.What and why
docs/design.mdsaidv_cvt_pknorm_i16_f32/v_cvt_pknorm_u16_f32give 0 for a NaN, asv_cvt_i32_f32does, but that this was not measured on hardware. This PR measures it on RDNA2.tools/pknorm_probe.py(new, standard library only) runs both ops two ways:--oracle hw, natively throughtools/hw_oracle, in wave32 and wave64, under five MODEs: the game's (IEEE 0, DX10_CLAMP 1, f32 denormals flushed), then IEEE 1, DX10_CLAMP 0, both, and f32 denormals kept.Each NaN pattern is tested in S0 and in S1: quiet, quiet with a payload, signalling, both signs.
NaN: measured, the translator is right. Every NaN half gives 0, 74 of 74, in all ten runs.
Rounding: a new difference, not fixed here.
OpFMulproduct and thenRoundEven.0x38400180(exact product 1.5 - 1.4e-9) gives 1 on the hardware and 2 from the translator;0x3c004101(256.5 + 1.5e-5) gives 257 and 256.Changes:
docs/design.md: the pknorm row now records the measurement and the rounding difference. The row appears twice; both copies are updated the same way, and merging them is PROC-75.docs/shader_validation.md: a new section, "v_cvt_pknorm_*NaN and rounding on RDNA2", with the results table.I'll post the rounding fix as a
finding:on the board.Tested
rocm-sdk-core10.0.0.main4eb6155d.python -I tools/pknorm_probe.py --oracle hw: exit 1, as expected, because of the rounding difference. In all ten runs: NaN halves giving 0, 74 of 74; near ties equal to single rounding, 28 of 28 (translator 0 of 28); other words, 34 of 34.tests/test_pknorm_probe.py(new): four near-tie words derived by hand with exact arithmetic, case coverage, and the translator side's double rounding and NaN zero. OK withpython -Iand pytest.tests/semantic/test_alu_cvt_pknorm_f32.py: OK.test_fma_mix_probe,test_mode_round,test_values,test_valu_fuzzand others: OK.test_docs_design_rowsfails 3 times, the same onmainwithout this change (duplicate rows; PROC-75).AI-assisted.
Checklist
docs/design.md, with how it was confirmed. (No translator change; the existing row records the measurement.)