Repository navigation
Conversation
Packed signed 16-bit add/sub/mad with `CLAMP=1` in `Lw::valu_pk` previously lowered saturation as `IMax(IMin(t, 0x7FFF), -32768) & 0xFFFF` before OR-ing the low and high halves. On NVIDIA Ampere drivers (RTX 3070 616.56 and RTX 3060 610.88), the driver drops the trailing `& 0xFFFF` mask for negative clamped low halves, leaving sign-extended `0xFFFF_xxxx` to clobber bits [31:16] of the packed destination (for example `[-1, 1] - [1, 1]` yields `0xFFFF_FFFE` instead of `0x0000_FFFE`). Replace the `IMin`/`IMax`/`& 0xFFFF` sequence with signed 32-bit comparisons and a `select` chain over 16-bit constants (`0x7FFF`, `0x8000`) and `t & 0xFFFF`, matching the masked-select saturation form used in xcl-dev#2398 for non-packed 16-bit integer ops. Add `i16_clamp_mask_tests::v_pk_i16_clamp_uses_masked_select_without_imin_imax` (DXIL validator + IR check) and `i16_clamp_mask_tests::gpu_i16_clamp_negative_low_half_keeps_high_half` covering `V_PK_ADD_I16`, `V_PK_SUB_I16`, and `V_PK_MAD_I16` with `CLAMP=1` alongside `V_CVT_PK_I16_I32` and `V_CVT_I16_F16` controls. Based on @upipibi's root-cause analysis and fix (`upipibi/xcl@6fe2b3e`) and @Smokeyqdqd's independent RTX 3060 reproduction. Assisted-by: Google Antigravity (Gemini 4 Neon)
|
AMD run (listed as untested), plus one more Ampere card: no change from Tested: pass, head
On both cards the only result changes are The new GPU test uses Not tested: the clamp in a 64-lane wave, D3D12 debug-layer tests (no AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report. |
|
Independent RTX 5070 check: NVIDIA driver 616.92; Ryzen 7 5700X3D; Windows build 26300.10075; Rust 1.100.0 MSVC, debug; SDK DXC/DXIL 1.8.2502.11. Ran
The arithmetic fixture did not reproduce the reported Ampere wrong-result signature on this Blackwell card and driver, including on the parent. This is not a performance or retail-title test; the full suite was not run on this PR. AI use: OpenAI Codex with GPT-6.2 Astra ran the tests and reported results; Codex coordinated and prepared this summary. |
|
Linux (Wine) dual-lane run at head
The masked-select saturation is exercised mainly in paths our Wine lane runs headless without real draw compare ( Suite: AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting. |
…xcl-dev#2856 triaged SKIP, probe past xcl-dev#2855)
Direct DXIL lowering for packed signed 16-bit add/sub/mad with
CLAMP=1(v_pk_add_i16,v_pk_sub_i16,v_pk_mad_i16inLw::valu_pk,crates/xcl/src/gpu/dxil/lower_wide.rs) previously saturated each half viaIMax(IMin(t, 0x7FFF), -32768) & 0xFFFFbefore OR-ing the low and high halves into the destination register. On NVIDIA Ampere drivers (RTX 3070 driver 616.56 and RTX 3060 driver 610.88), the driver drops the trailing& 0xFFFFmask for negative clamped low halves, leaving sign-extended0xFFFF_xxxxto overwrite bits[31:16]of the packed destination (for example,[-1, 1] - [1, 1]returned0xFFFF_FFFEinstead of0x0000_FFFE).This is the packed-operation sibling to #2398 (which touches non-packed
valu16ops on disjoint lines and merges cleanly alongside this PR). Auditing all otherimin/imax/& 0xFFFFsites acrosscrates/xcl/src/gpu/dxil/confirmedLw::valu_pkwas the only remainingIMax(IMin(t, 0x7FFF), -32768) & 0xFFFFsite;v_cvt_i16_f16(lower_wide.rs) andv_cvt_pk_i16_i32(lower_valu.rs) useIMin(IMax(...))and pass as controls on Ampere.What is in it
IMax(IMin(t, 0x7FFF), -32768) & 0xFFFFin"v_pk_add_i16" | "v_pk_sub_i16" | "v_pk_mad_i16" if clamp(crates/xcl/src/gpu/dxil/lower_wide.rs) with signed 32-bit comparisons (Pred::SGtagainst0x7FFF,Pred::SLtagainst0xFFFF_8000),t & 0xFFFF, and aselectchain yielding 16-bit patterns (0x7FFF,0x8000, orlow), matching the masked-select form used in DXIL: saturate 16-bit integer valu16 ops when CLAMP=1 #2398.i16_clamp_mask_tests::v_pk_i16_clamp_uses_masked_select_without_imin_imax: validates and disassembles Direct DXIL forV_PK_ADD_I16,V_PK_SUB_I16, andV_PK_MAD_I16withCLAMP=1, assertingicmp sgt i32/icmp slt i32/select i1and noIMax,IMin, orInt64Ops.i16_clamp_mask_tests::gpu_i16_clamp_negative_low_half_keeps_high_half: runsV_PK_ADD_I16,V_PK_SUB_I16, andV_PK_MAD_I16withCLAMP=1(distinct source registers across saturation edges, negative in-range low halves, and 32-bit intermediate cancellation) alongsideV_CVT_PK_I16_I32andV_CVT_I16_F16controls on the GPU.@upipibi's root-cause analysis and fix (upipibi/xcl@6fe2b3e7, RTX 3070 616.56 reproduction) and@Smokeyqdqd's independent RTX 3060 610.88 reproduction.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5.e120925eclamp withi16_clamp_mask_testsadded):cargo test -p xcl --lib -- v_pk_i16_clamp_uses_masked_select_without_imin_imax --nocapture --test-threads=1: 0 passed, 1 failed (caughtIMaxemission on unmodifiede120925e).cargo test -p xcl --lib -- gpu_i16_clamp_negative_low_half_keeps_high_half --nocapture --test-threads=1(3x Debug RTX 4060) and--release(3x Release RTX 4060): 1 passed, 0 failed in all 6 runs (0 skipped). RTX 4060 Ada driver 621.14 keeps the& 0xFFFFmask onIMax(IMin(...)), consistent with DXIL: saturate 16-bit integer valu16 ops when CLAMP=1 #2398 where Ada passed while Ampere drivers failed 3/3 (RTX 3070 616.56 and RTX 3060 610.88, 33 mismatched lanes).651fc050):cargo clippy --all-targets -- -A clippy::approx_constant: exit 0, 0 new warnings incrates/xcl/src/gpu/dxil/lower_wide.rs.XCL_WARP=1):cargo test -p xcl --lib -- i16_clamp_mask_tests --nocapture --test-threads=1: 2 passed, 0 failed, 0 ignored in 3/3 runs (0 skipped);cargo test -p xcl --lib -- gpu::dxil:: --test-threads=4: 186 passed, 0 failed, 3 ignored (1SKIPPED:dispatch_chain_native_wave64_builds_whole: no wave64).cargo test --release -p xcl --lib -- i16_clamp_mask_tests --nocapture --test-threads=1: 2 passed, 0 failed, 0 ignored in 3/3 runs (0 skipped);cargo test --release -p xcl --lib -- gpu::dxil:: --test-threads=4: 186 passed, 0 failed, 3 ignored (1SKIPPED:dispatch_chain_native_wave64_builds_whole: no wave64).cargo build --release --workspace && cargo test --release --workspace --no-fail-fast -- --test-threads=4: 1444 passed, 0 failed, 47 ignored across 38 top-level test targets (29SKIPPEDnotices: 21 wave64, 3 per-lane refusals, 3 D3D12 debug layer, 1 heap-window fallback, 1 Windows driver-cache toggle).git merge-tree --write-tree(exit 0) against bothmain(8b957bec) and DXIL: saturate 16-bit integer valu16 ops when CLAMP=1 #2398 (e9d7aefc).Regression run
Paired quiet 60 s release runs (
scripts/smoke.ps1 -Seconds 60,XCL_NETWORK=0, RTX 4060 8 GB, driver 621.14) on exact parente120925eand PR head651fc050:Exact parent on
main(e120925e, ancestor of8b957bec):PR (
651fc050):Not tested
V_PK_ADD_I16/V_PK_SUB_I16failure and masked-select fix were independently verified 3/3 on RTX 3070 616.56 by@upipibiand RTX 3060 610.88 by@Smokeyqdqd;V_PK_MAD_I16shares the same clamp block and was verified here on WARP and RTX 4060 Ada).d3d12SDKLayers.dllnot installed).AI use
crates/xcl/src/gpu/dxil/, applied the masked-select fix andi16_clamp_mask_tests(extending@upipibi's6fe2b3e7test withV_PK_MAD_I16and an IR contract test), ran all local builds/tests/smokes, and drafted this PR description.