Repository navigation
Tests: float rounding ops and fract's clamp below 1.0 on the GPU - #655
acaracargo wants to merge 1 commit into
Conversation
v_floor, v_ceil, v_trunc, v_rndne and v_fract in f32 and f16 had no edge-value GPU test (v_fract_f32 only for +-inf / NaN, xcl-dev#68). 16 inputs each: halves of both signs (rndne to the even neighbour), the sign of a zero result, infinities, NaN, values past the last fraction bit, and fract of a small negative value, which the ISA clamps to the largest value below 1.0 (0x3F7FFFFF / 0x3BFF). v_fract_f16 passes today only because the default f16 result goes through the legacy f32tof16, which rounds toward zero: x - floor(x) for x = -2^-14 is 1 - 2^-14 in f32, and rounding that to nearest gives 1.0. With to_f16_expr changed to round to nearest (the default-mode fix xcl-dev#111 asks for), v_fract_f16(-6.1e-5) returns 0x3c00 and this test fails, so the fract clamp has to move after the f16 rounding then. Measured: RTX 4060 (wave32), Windows 11 Pro 26300, Rust 1.100, debug. cargo test --workspace -- --test-threads=4: 678 passed, 0 failed, 41 ignored; SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware. Removing fract_f's clamp in emit.rs fails the test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WsgnReN2iZK9RUNckZAhrv
|
AMD / native-wave64 data point (the "Not tested" axis): Setup: Windows 11 Pro 26300, Ryzen 7 7800X3D, 32 GB; adapters: AMD Radeon(TM) Graphics (Raphael iGPU, wave64) and RTX 3080 Ti 12 GB (driver 621.01, wave32-only). PR head Runs (
The 16-bit fract clamp ( Not tested: discrete AMD GPUs, other titles. AI use: Gentle Shell (Pi coding agent), model qwen4-max: ran the tests and wrote this report from their logs; a human reviews it before posting. No code changes. |
|
Test run of Tested
Review: Not tested: no retail title (not needed for a test-only change), release build; the PR's head on its old base was not run, only its merge onto Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
|
Independent GPU test report on Tested
Not tested
AI use
|
…l-dev#111) In the default mode every f16 result that is narrowed from binary32 went through HLSL f32tof16, which rounds toward zero: on an RTX 4070 Ti and an RDNA2 iGPU every inexact v_add/sub/sqrt/rcp/rsq/exp/log/ldexp_f16 result came out one binary16 step low, and an overflow stopped at 65504 instead of inf. Native RDNA2 rounds to nearest even (luckyteagirl's measurements on xcl-dev#672). to_f16_expr now narrows with f32_to_f16_rm(e, 0u) in the default mode, the helper the multiplies already use (xcl-dev#166); under a dynamic mode nothing changes. v_fract_f16 clamps its binary32 result below 1.0, and 1 - 2^-24 narrows to 1.0 by nearest even, so its binary16 result is kept at 0x3BFF (xcl-dev#655). Supersedes xcl-dev#696, whose add / sub cases this covers. Assisted-by: Claude Code (Claude Opus 5.5)
Empirical test report (bc2537e)Hardware / environment
Commands and results
$env:XCL_ADAPTER = 'A770'
$env:RUST_TEST_NOCAPTURE = '1'
& $arcLockScript -Test {
& $testExe gpu::recomp::tests::gpu_float_rounding_ops --exact --nocapture --test-threads=1
}
Observed behavior The PR adds one test covering floor, ceil, truncation, nearest-even rounding, and fract in f32 and f16. Both formats matched the expected results on all 16 input cases, including ties of both signs, signed zero, infinities, and NaN. For the small negative inputs, fract matched the largest representable value below 1.0 in each format (f32 Not tested Full GPU workspace suite and game smoke runs were omitted. AI use Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr655-focused.log and published. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
Adds GPU coverage for
v_floor,v_ceil,v_trunc,v_rndneandv_fractin both f32 and f16, with 16 inputs each.The cases cover:
0x3F7FFFFF/0x3BFF).Previously, only fract of infinities and NaN had GPU coverage (#68).
The f16 fract case is particularly relevant to #111. For x = -2^-14, x - floor(x) is 1 - 2^-14 in f32, which rounds to nearest as 1.0 in f16. Switching
to_f16_exprto round to nearest locally causedv_fract_f16to return0x3c00instead of0x3bff.The test should catch this regression when the f16 rounding behavior is corrected.
What is in it
crates/xcl/src/gpu/recomp/tests.rs:gpu_float_rounding_ops.Tested
x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug.cargo test --workspace -- --test-threads=4onbc2537e: 685 passed, 0 failed, 41 ignored (main9ce2070: 684 / 0 / 41).gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64).fract_for switchingto_f16_exprto round to nearest causes the test to fail (both checked locally, reverted).Regression run
Not tested
AI use