diff options
| author | Weslley Couto <weslleysanchez123@gmail.com> | 2026-11-22 16:34:15 -0300 |
|---|---|---|
| committer | Weslley Couto <weslleysanchez123@gmail.com> | 2026-11-22 16:34:15 -0300 |
| commit | 533d5533a629fdf2a51698e1ebe7a9e82a5ece14 (patch) | |
| tree | a542cdbdaf14b6266ac6bc6d6bca6cb69bed330a /docs/shader_validation.md | |
| parent | 49475796c226c8511b9470bf97a4daf57b8af323 (diff) | |
SHADER-340: measure RDNA1 mad/mac denormal flush and flush before omod
Diffstat (limited to 'docs/shader_validation.md')
| -rw-r--r-- | docs/shader_validation.md | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/docs/shader_validation.md b/docs/shader_validation.md index 90082a1cb..d7c07366e 100644 --- a/docs/shader_validation.md +++ b/docs/shader_validation.md | |||
| @@ -1167,6 +1167,31 @@ product once, to nearest even. Examples: | |||
| 1167 | The translator is not changed here. It needs the exact product: the product's rounding error is exact through `Fma` | 1167 | The translator is not changed here. It needs the exact product: the product's rounding error is exact through `Fma` |
| 1168 | (`Fma(x, s, -p)`), and only its sign matters on a tie. | 1168 | (`Fma(x, s, -p)`), and only its sign matters on a tie. |
| 1169 | 1169 | ||
| 1170 | ### `v_mad_f32`, `v_mac_f32`, `v_mad_legacy_f32` denormal flush on RDNA1 (`tools/mad_denorm_probe.py`, SHADER-340) | ||
| 1171 | |||
| 1172 | `docs/design.md` ("Denormal flush in `v_mad_f32`, `v_mac_f32`, `v_mad_legacy_f32`") had no hardware measurement: GFX10.3+ | ||
| 1173 | dropped these opcodes, and flushing only after `omod` (`div:2`/`mul:2`/`mul:4`) was an unverified assumption. The probe | ||
| 1174 | covers 48 cases across six groups: subnormal operands in each source slot (`input`, 15), normal operands with a subnormal | ||
| 1175 | product (`product`, 7), normal operands/products with a subnormal sum (`result`, 6), `omod`/`clamp` crossing the | ||
| 1176 | subnormal threshold (`omod`, 8), `v_mad_legacy_f32`'s `0 * anything -> +0` with subnormals (`legacy`, 5), and controls | ||
| 1177 | (`control`, 7). A `v_mul_f32(FLT_MIN, 0.5)` sanity kernel checks that `MODE.denorm32=3` actually keeps f32 denormals on | ||
| 1178 | the device (`0x00000000` with `denorm32=0`, `0x00400000` with `denorm32=3`). | ||
| 1179 | |||
| 1180 | ``` | ||
| 1181 | python -I tools/mad_denorm_probe.py # the translator, on the CPU interpreter | ||
| 1182 | python -I tools/mad_denorm_probe.py --oracle hw # also the native instruction on an AMD GPU | ||
| 1183 | ``` | ||
| 1184 | |||
| 1185 | Results (48 cases per run, wave32 and wave64 across 5 MODEs; `tests/test_mad_denorm_probe.py` checks the translator side): | ||
| 1186 | |||
| 1187 | | GPU | Driver | `game` / `dx10clamp0` / `denorm32_kept` | `ieee1` / `ieee1_dx10clamp0` (non-`omod` + `omod` ignored) | | ||
| 1188 | |---|---|---|---| | ||
| 1189 | | AMD Radeon RX 5600 XT (`gfx1010`, RDNA1), Windows, HIP backend (`amdhip64_6.dll`), AMD clang (`rocm-sdk-core 10.0.0`) | 32.0.21045.29003 | 48 of 48 (wave32 and wave64) | 48 of 48 (wave32 and wave64) | | ||
| 1190 | |||
| 1191 | Two findings from the RDNA1 measurement: | ||
| 1192 | - **Subnormal inputs, products, sums, and legacy rules flush regardless of `MODE.denorm32`** (40 of 40 non-`omod` cases match bit-for-bit across all 5 MODEs, including `denorm32=3`). Under `MODE.IEEE=1`, hardware ignores `mul:2`/`mul:4`/`div:2` (`FLT_MIN div:2` gives `FLT_MIN`, as for other f32 VALU ops). | ||
| 1193 | - **Hardware flushes both before and after `omod`.** Before SHADER-340, the translator flushed only after `clamp_mods`, so `(1.5*2^-126 - 2^-126) mul:2` gave `0x00800000` (`FLT_MIN`) and `mul:4` gave `0x01000000`, whereas the RX 5600 XT returns `+0` (`0x00000000`) in `game`, `dx10clamp0`, and `denorm32_kept`. `Gen.flush_f32_mods` now flushes the sum before `clamp_mods` and flushes again after it (`FLT_MIN div:2` → `+0`, `-FLT_MIN div:2` → `-0`), leaving non-modified `v_mad*`/`v_mac*` instructions byte-identical. | ||
| 1194 | |||
| 1170 | ### f16 output modifiers, clamp and `v_fma_mix*` operands on RDNA2 (SHADER-135) | 1195 | ### f16 output modifiers, clamp and `v_fma_mix*` operands on RDNA2 (SHADER-135) |
| 1171 | 1196 | ||
| 1172 | *Measured on an RDNA2 iGPU (gfx1036), AMD Windows driver 32.0.21044.64, HIP backend, AMD clang 23.0.0git, `main` | 1197 | *Measured on an RDNA2 iGPU (gfx1036), AMD Windows driver 32.0.21044.64, HIP backend, AMD clang 23.0.0git, `main` |