diff options
| author | milk4sale <53350507+milk4sale@users.noreply.github.com> | 2026-11-24 11:04:58 -0600 |
|---|---|---|
| committer | milk4sale <53350507+milk4sale@users.noreply.github.com> | 2026-11-24 11:04:58 -0600 |
| commit | 355c8c9c2da01a9898df5061d266ca1f5567cdc9 (patch) | |
| tree | e6a7a48be15c3500c607b2749278f5c0508e19c6 /docs/testing.md | |
| parent | 50407827cd2cb73313c585cdf3d3d40ed7918bae (diff) | |
tests: GPU readback for the binary64 roundings, v_trunc_f64, v_ceil_f64, v_rndne_f64 and v_floor_f64 (GPU-ROUND-F64)
The translator gives the four ops to the driver's double-precision Trunc, Ceil, RoundEven and Floor, and no
fixture in runtime/test/shaders ran them, so what a driver does with ties, the largest value below 0.5, values at
and above 2^52, signed zeros, subnormals, infinities and NaNs had never gone through the GPU suite.
cs_w32_round_f64 is memory-fed, like cs_w32_shift64 and cs_w32_cmp_f64: check.py seeds 64 inputs and each thread
loads one at run time and stores eight results: the four roundings, v_trunc_f64 with a neg source, v_ceil_f64 with
an abs source, a v_floor_f64 whose destination pair overlaps its source pair, and a v_rndne_f64 run with the odd
threads turned off, whose destination must keep the pair it held. The expected words come from Python floats
(exact IEEE-754, the result keeping its source's sign) and are checked against exact rational rounding in
tests/test_gpu_round_f64.py.
Two kinds of input are judged by what Vulkan lets a driver do, not by RDNA2: a NaN may come back as another NaN,
and a subnormal may be read as a zero of its sign, since the module declares no DenormPreserve for 64 bits. That is
what the fixture measured: on an RTX 4070 Ti a signalling NaN comes back quiet, and on llvmpipe the smallest
subnormals are also read as zero. The row in docs/design.md records both as an approximation. dump_test takes an
optional judge for such a readback.
No translator or runtime change.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'docs/testing.md')
| -rw-r--r-- | docs/testing.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/docs/testing.md b/docs/testing.md index eda140a9a..4d76e9f2e 100644 --- a/docs/testing.md +++ b/docs/testing.md | |||
| @@ -373,6 +373,30 @@ canonicalization at word 206, a NaN test that ignores the low dword at word 28, | |||
| 373 | dword at word 70, the raw result written to an inactive lane's VCC at word 2, `v_cmpx_` replacing EXEC at word 3, | 373 | dword at word 70, the raw result written to an inactive lane's VCC at word 2, `v_cmpx_` replacing EXEC at word 3, |
| 374 | `abs` ignored and `nlt` lowered as the negation of `le` at word 0. | 374 | `abs` ignored and `nlt` lowered as the negation of `le` at word 0. |
| 375 | 375 | ||
| 376 | `cs_w32_round_f64` checks `v_trunc_f64`, `v_ceil_f64`, `v_rndne_f64` and `v_floor_f64`, which the translator gives | ||
| 377 | to the driver's double-precision `Trunc`, `Ceil`, `RoundEven` and `Floor` (`shaderFloat64`). 64 inputs are loaded at | ||
| 378 | run time: signed zeros, the smallest subnormals and normals, values around 0.5 and 1 (the largest value below 0.5 | ||
| 379 | among them), ties from 0.5 to 5.5 and at 2^31 + 0.5, 2^51 + 0.5 and 2^52 - 0.5, integers from 2^52 to 2^63, 1e300, | ||
| 380 | the largest finite value, the infinities, and quiet and signalling NaNs. Each thread stores the four roundings, | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 386 | may be read as a zero of its sign, because the module does not declare `DenormPreserve` for 64 bits. All 1152 heap | ||
| 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`. | ||
| 389 | It needs `shaderFloat64`; a device without it reports a skip. | ||
| 390 | |||
| 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 | ||
| 392 | of the two signalling NaNs, which come back quiet with sign and payload kept (`0x7ff0000000000001` gives | ||
| 393 | `0x7ff8000000000001`). On llvmpipe (Mesa 26.2.6, LLVM 23.1.4) five more differ: the two smallest subnormals are read | ||
| 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 | ||
| 395 | of -1. Rules broken one at a time each failed the test on both devices: `rndne` lowered as `floor(x + 0.5)` (word | ||
| 396 | 20, the sign of -0), `trunc` or `ceil` lowered as `Floor`, the `neg` or the `abs` source modifier ignored (words 8 and | ||
| 397 | 26), the low result word taken from the high one (word 8), and the fixture without its `v_cmpx` (word 30). Replacing | ||
| 398 | `RoundEven` by GLSL `Round` changed nothing on either device: both send a tie to the even integer. | ||
| 399 | |||
| 376 | ## Wave64 pixel, vertex and geometry shaders (`w64_graphics.py`) | 400 | ## Wave64 pixel, vertex and geometry shaders (`w64_graphics.py`) |
| 377 | 401 | ||
| 378 | Graphics stages have no emulation: on a 32-wide subgroup a wave64 VS, PS or GS runs as two 32-lane halves, and the | 402 | Graphics stages have no emulation: on a 32-wide subgroup a wave64 VS, PS or GS runs as two 32-lane halves, and the |