diff options
Diffstat (limited to 'docs/shader_validation.md')
| -rw-r--r-- | docs/shader_validation.md | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/docs/shader_validation.md b/docs/shader_validation.md index 1f6719176..5447785fd 100644 --- a/docs/shader_validation.md +++ b/docs/shader_validation.md | |||
| @@ -784,6 +784,49 @@ reset in the kernel log. | |||
| 784 | inputs is computed once and stored in its own half (`tests/test_f16_trans_sweep.py`). On a GPU the test checks | 784 | inputs is computed once and stored in its own half (`tests/test_f16_trans_sweep.py`). On a GPU the test checks |
| 785 | exp2 of integers and wave32 = wave64. | 785 | exp2 of integers and wave32 = wave64. |
| 786 | 786 | ||
| 787 | ### `v_fma_mix*` f16 rounding in nearest mode (`tools/fma_mix_probe.py`) | ||
| 788 | |||
| 789 | `docs/design.md` leaves one f16 question open. In round-to-nearest mode, does `v_fma_mixlo_f16` / `v_fma_mixhi_f16` | ||
| 790 | round the exact x · y + z once, straight to f16? Or does it round to f32 first and then narrow, which is what the | ||
| 791 | translator does (f32 `Fma`, then `f16_res`)? The RX 6800 word behind the toward-zero rule can't answer this. For | ||
| 792 | 1 · 2 - 2^-30 both readings give 0x4000 in nearest mode, and toward zero two truncations equal one. | ||
| 793 | |||
| 794 | The two readings only differ when the f32 rounding lands exactly on an f16 tie, or moves a value off one. The probe has | ||
| 795 | seven such inputs, each one f16 ulp apart under the two rules, plus one control: | ||
| 796 | - a tie just above and just below, for both signs; | ||
| 797 | - the subnormal tie at 2^-25; | ||
| 798 | - the overflow tie at 65520 (inf against 65504); | ||
| 799 | - a tie made by the product rather than by z; | ||
| 800 | - the same with f16 operands (`op_sel_hi:[1,1,1]`). | ||
| 801 | |||
| 802 | Every side reports which rule its words follow: | ||
| 803 | |||
| 804 | ``` | ||
| 805 | python -I tools/fma_mix_probe.py # the translator, on the CPU interpreter | ||
| 806 | python -I tools/fma_mix_probe.py --oracle hw # also the native instruction on an AMD GPU (hardware oracle) | ||
| 807 | python -I tools/fma_mix_probe.py --oracle vulkan --build runtime/build # also the translated shader on this GPU | ||
| 808 | ``` | ||
| 809 | |||
| 810 | The `hw` side is the measurement. It runs one wave32 lane per input, under the MODE inferred for the game: IEEE 0, | ||
| 811 | DX10_CLAMP 1, f32 denormals flushed, f16 denormals kept, nearest. The `vulkan` side only shows that a driver runs the | ||
| 812 | translator's sequence as written. Its operands come in user SGPRs, so the driver can't fold them. Exit 0 means every | ||
| 813 | side follows the same rule. Exit 1 means they differ, or a side follows neither rule. Exit 77 means a requested side | ||
| 814 | is unavailable. | ||
| 815 | |||
| 816 | `tests/test_fma_mix_probe.py` checks the expected words against a derivation written out by hand. It also checks that | ||
| 817 | the translator follows the double rule today, and that the compute shader gives the pixel shader's words on the | ||
| 818 | interpreter. If the hardware rounds once, the fix is to use `Gen.fma_mix_odd` in nearest mode as well. Round-to-odd at | ||
| 819 | f32 then narrows exactly. With that change the translator gives the single-rounded word on all seven inputs. | ||
| 820 | |||
| 821 | Results: | ||
| 822 | |||
| 823 | | GPU | Driver | `translator` | `vulkan` | `hw` | | ||
| 824 | |---|---|---|---|---| | ||
| 825 | | NVIDIA GeForce RTX 5060 (Blackwell), Windows 11 | 621.24 | double | double, 8 of 8 words | not AMD | | ||
| 826 | |||
| 827 | The `hw` column is still empty: the question needs an RDNA GPU. On the RTX 5060, a translator copy changed to use | ||
| 828 | `fma_mix_odd` in nearest mode gave the single-rounded word for all seven inputs on the `vulkan` side as well. | ||
| 829 | |||
| 787 | ## Coverage plan and cost | 830 | ## Coverage plan and cost |
| 788 | 831 | ||
| 789 | Start with straight-line scalar/vector ALU because it is deterministic, needs no descriptors and | 832 | Start with straight-line scalar/vector ALU because it is deterministic, needs no descriptors and |