diff options
| author | milk4sale <53350507+milk4sale@users.noreply.github.com> | 2026-11-24 11:15:37 -0600 |
|---|---|---|
| committer | milk4sale <53350507+milk4sale@users.noreply.github.com> | 2026-11-24 11:15:37 -0600 |
| commit | 26d010b41dc042bc36698f673ad588a1e6d04f07 (patch) | |
| tree | e1c0ddb2ee6fb475b69d13b614e544103e32a7dc /docs/testing.md | |
| parent | 355c8c9c2da01a9898df5061d266ca1f5567cdc9 (diff) | |
rdna2spirv: the binary64 roundings keep a NaN's bits and round a subnormal without the driver (SHADER-ROUND-F64-SPECIALS)
v_trunc_f64, v_ceil_f64, v_rndne_f64 and v_floor_f64 hand their source to the driver's double-precision Trunc,
Ceil, RoundEven and Floor. Vulkan lets a driver return any NaN for a NaN operand and, with no DenormPreserve for
64 bits, read a subnormal as zero, and cs_w32_round_f64 measured both: a signalling NaN came back quiet on an RTX
4070 Ti (NVIDIA 620.70.06) and on llvmpipe, and llvmpipe read the smallest subnormals as zero, so v_ceil_f64 of the
positive one gave +0. RDNA2 returns a NaN unchanged and keeps subnormals: that ceil is 1.
The two kinds of source are now selected with integer ops on the words, after the source modifiers and before the
output ones. A NaN's words pass through. A subnormal gives a zero of its sign, or 1 with its sign where the op
rounds that sign away from zero (ceil of a positive one, floor of a negative one). Every other source still takes
the driver's result.
cs_w32_round_f64 now compares all 1152 words exactly, on both devices. tests/semantic/test_f64_round.py runs the
four ops under a model of a driver that quiets a NaN and reads a subnormal as zero; without the change that class
fails for the signalling NaNs and for ceil and floor of a subnormal. The row in docs/design.md describes the rule
and how it was confirmed.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'docs/testing.md')
| -rw-r--r-- | docs/testing.md | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/docs/testing.md b/docs/testing.md index 4d76e9f2e..b0ae7a170 100644 --- a/docs/testing.md +++ b/docs/testing.md | |||
| @@ -381,21 +381,25 @@ the largest finite value, the infinities, and quiet and signalling NaNs. Each th | |||
| 381 | `v_trunc_f64` with a `neg` source, `v_ceil_f64` with an `abs` source, a `v_floor_f64` whose destination pair overlaps | 381 | `v_trunc_f64` with a `neg` source, `v_ceil_f64` with an `abs` source, a `v_floor_f64` whose destination pair overlaps |
| 382 | its source pair, and a `v_rndne_f64` run with the odd threads turned off, whose destination must keep the pair it | 382 | its source pair, and a `v_rndne_f64` run with the odd threads turned off, whose destination must keep the pair it |
| 383 | held. The expected words come from Python (`round_f64` in `check.py`: exact IEEE-754, the result keeping its | 383 | held. The expected words come from Python (`round_f64` in `check.py`: exact IEEE-754, the result keeping its |
| 384 | source's sign), and `tests/test_gpu_round_f64.py` checks that oracle against exact rational rounding. Two kinds of | 384 | source's sign), and `tests/test_gpu_round_f64.py` checks that oracle against exact rational rounding. All 1152 heap |
| 385 | input are judged by what Vulkan lets a driver do, not by RDNA2: a NaN may come back as another NaN, and a subnormal | 385 | words are compared exactly, the 128 unchanged input words included: a NaN and a subnormal are rounded by the |
| 386 | may be read as a zero of its sign, because the module does not declare `DenormPreserve` for 64 bits. All 1152 heap | 386 | translated code with integer ops and not by the driver, as the row in [design.md](design.md) says. Run it alone with |
| 387 | words are judged, the 128 unchanged input words included. Run it alone with | ||
| 388 | `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_round_f64 --require-pass`. | 387 | `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_round_f64 --require-pass`. |
| 389 | It needs `shaderFloat64`; a device without it reports a skip. | 388 | It needs `shaderFloat64`; a device without it reports a skip. |
| 390 | 389 | ||
| 391 | Measured: on an RTX 4070 Ti (NVIDIA 620.70.06, Linux) 497 of the 512 results are RDNA2's, and the other 15 are those | 390 | Measured: on an RTX 4070 Ti (NVIDIA 620.70.06, Linux) and on llvmpipe (Mesa 26.2.6, LLVM 23.1.4) all 1152 words |
| 392 | of the two signalling NaNs, which come back quiet with sign and payload kept (`0x7ff0000000000001` gives | 391 | match. While those two kinds of input still went to the driver's function, 15 of the 512 results differed on the |
| 393 | `0x7ff8000000000001`). On llvmpipe (Mesa 26.2.6, LLVM 23.1.4) five more differ: the two smallest subnormals are read | 392 | 4070 Ti, those of the two signalling NaNs, which came back quiet with sign and payload kept (`0x7ff0000000000001` |
| 394 | as zero, so `v_ceil_f64` of the positive one gives +0 instead of 1 and `v_floor_f64` of the negative one -0 instead | 393 | gave `0x7ff8000000000001`), and five more on llvmpipe, which read the two smallest subnormals as zero (`v_ceil_f64` |
| 395 | of -1. Rules broken one at a time each failed the test on both devices: `rndne` lowered as `floor(x + 0.5)` (word | 394 | of the positive one gave +0 instead of 1, `v_floor_f64` of the negative one -0 instead of -1). Rules broken one at a |
| 396 | 20, the sign of -0), `trunc` or `ceil` lowered as `Floor`, the `neg` or the `abs` source modifier ignored (words 8 and | 395 | time each failed the test on both devices: a NaN left to the driver (word 784), the NaN and subnormal tests ignoring |
| 397 | 26), the low result word taken from the high one (word 8), and the fixture without its `v_cmpx` (word 30). Replacing | 396 | the low dword, `v_ceil_f64` or `v_floor_f64` lifting the subnormal of the wrong sign (words 34 and 38), a subnormal's |
| 398 | `RoundEven` by GLSL `Round` changed nothing on either device: both send a tie to the even integer. | 397 | result losing its sign (word 40), a NaN's low word dropped (word 784), `rndne` lowered as `floor(x + 0.5)` (word 20, |
| 398 | the sign of -0), `trunc` or `ceil` lowered as `Floor`, the `neg` or the `abs` source modifier ignored (words 8 and | ||
| 399 | 26), the two result words swapped (word 8), and the fixture without its `v_cmpx` (word 30). Two changes are not | ||
| 400 | caught everywhere: a subnormal left to the driver fails on llvmpipe (word 34) and passes on the 4070 Ti, which keeps | ||
| 401 | binary64 denormals, and `RoundEven` replaced by GLSL `Round` changes nothing on either device, since both send a tie | ||
| 402 | to the even integer. | ||
| 399 | 403 | ||
| 400 | ## Wave64 pixel, vertex and geometry shaders (`w64_graphics.py`) | 404 | ## Wave64 pixel, vertex and geometry shaders (`w64_graphics.py`) |
| 401 | 405 | ||