Repository navigation
Conversation
The console's 64-bit to 32-bit conversion: the VGPR pair is bitcast to a `double` and truncated with the host's `fptrunc`, round to nearest even, which is MODE's default. The toward-zero 64-bit mode has no DXIL form and is refused by name rather than mis-rounded. The IR had no 64-bit float type: it gains `double` (bitcode type 4) and the `fptrunc` cast (LLVM opcode 7). A module that uses it declares the doubles feature — SFI0 0x1 and the module's feature-info bit 2 — which dxil.dll checks against the module. Ten cases run on the card, checked against Rust's `as f32`: 1.0, -2.5, 0.1, a tie that rounds to even, the two smallest subnormals (0), f64 max (inf), ±inf and a NaN (payload kept). WARP tops out at SM 6.2 here, so the hardware device is the one exercised; the DXIL is validated by dxil.dll. (cherry picked from commit 0439ea5)
…nverts Two findings from the review (tyr0nsur): - A literal source of `v_cvt_f32_f64` is the **high** word of the binary64 (RDNA 2 ISA 6.2.1), the low word zero: 0xC0020000 is -2.25. `src64` reads a literal as the sign-extended integer its bits are, so the value became garbage there. The literal is handled in the lowering now, and `a_64_bit_literal_source_is_the_high_word` runs it on the card. - The round-mode check admitted every mode but toward-zero: the directed modes (1, 2) and a mode written at run time (`None`) have no DXIL form, and `fptrunc` rounds nearest-even regardless. Only MODE's default (0) converts now; anything else is refused by name. Lib suite 249 passed, 0 failed, 3 ignored; clippy `-D warnings` clean. (cherry picked from commit 1ab5616)
Review feedback on Marvisak#2348: `v_cvt_f32_f64` lowers an inline float constant (operand codes 240-248) through `src64`'s fallback, which zero-extends the **f32** bit pattern — `1.0` became 0x000000003F800000, a subnormal that converts to 0, where the hardware uses the binary64 of the value (RDNA 2 ISA 6.2.1). The instruction now maps 240-248 to the same values as binary64 (including 1/(2π)) and builds the bits with an integer constant; register pairs and literals keep their paths. `a_64_bit_inline_constant_source_is_the_same_value` converts code 242 (1.0) and expects 1.0; before this it got 0. (cherry picked from commit f956a66)
… double)
The console compiler expands a wave sum of doubles into a whole-wave section
on dword pairs: v_cndmask per dword, two v_mov_b32 per DPP step, v_add_f64 on
the pairs, v_permlanex16 per dword, v_readlane, and s_mov_b32 copies out. The
simulator followed 32-bit steps only, so both dwords were unknown and a
program reading them was refused ("a whole-wave section step the simulation
does not follow").
- wave.rs: Sym::Red64 is one dword of the binary64 sum over some lanes of
mask ? (lo, hi) : +0.0; v_add_f64 joins two terms of one masked sum over
disjoint lanes and writes both destination dwords; s_mov_b32 keeps what
its source holds; a sum over every lane is Shape::Sum64.
- lower/sum64.rs: Shape::Sum64 is one waveActiveOp.f64 per block, shared by
both dwords (FLOAT64, INT64, WAVE_OPS).
Tests: two simulator tests (the wave32 expansion is followed through its
dwords and copies; a lane counted twice is not a sum) and a GPU test running
the section end to end into v_cvt_f32_f64.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent Windows WARP check of head Result: the simulator and lowering part holds up. The GPU test Environment
Why the GPU test failsWith the D3D12 debug layer on, WARP gives the reason: The lowered section asks for Focused (PR tests plus my synthetic cases)
My synthetic cases use the same wave32 expansion as the PR's test: Matched suite (
|
kotekompotek
left a comment
There was a problem hiding this comment.
Verified: correct LLVM bitcode encodings (FpTrunc=7, TYPE_DOUBLE record 4, FeatureFlag doubles=0x1), inline-constant table matches GCN's f64 set including 1/(2pi), literal sources read as high-word-only per RDNA rules, and only MODE's default round-to-nearest is accepted (directed modes refused rather than mis-rounded). Sum64 is right too: masked lanes contribute +0.0 and one waveActiveOp.f64 serves both dwords via the per-block cache.
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed and tested against main (63bcca43) on Windows 11 (RTX 5090 + WARP + dxil.dll, VICTORY_D3D12_DEBUG=1). There is a blocking test failure on WARP plus a source-modifier bug in v_cvt_f32_f64:
-
Blocking WARP / CI failure (
emit::valu_tests::a_whole_wave_binary64_sum_reaches_the_host):- The new test passes
dxil.dlland RTX 5090, but fails on WARP atvalu_tests.rs:209withE_INVALIDARG(0x80070057). - D3D12 Debug Layer
ID3D12InfoQueuereports:
ID3D12Device::CreateComputeShader: Shader wants wave lane count of 32 but maximum wave lane count for device is 4. - WARP supports
dx.op.waveActiveOp.f64itself, so the refusal comes from whole-wave sections emittingWaveSize=32(lower.rs:608) whilevalu_tests::run_casespanics unconditionally on WARP (unlikesynthetic_tests.rs:345-349, which skipsWaveSize=32pipelines on WARP).
- The new test passes
-
Silent source-modifier drop in
v_cvt_f32_f64(crates/victory-shader/src/emit/lower.rs:6405-6427):- The
Operand::Const(240..=248)andOperand::Literal(_)arms bypassself.src64(...)and do not checkv.abs,v.neg,v.sdwa, orv.dpp. A VOP3-encodedv_cvt_f32_f64_e64 v0, -1.0(inline constant withneg/abs) silently drops the modifier instead of applying or rejecting it.
- The
-
Two non-blocking notes:
a_whole_wave_binary64_sum_reaches_the_hostcurrently runsthreads: [1, 1, 1](1 active lane); testing multi-lane reduction with inactive lanes (+0.0) andNaN/Inf/-0.0would exerciseWaveActiveSummuch more thoroughly.- On
63bcca43,emit/lower.rsgrows to 523,410 B (only 878 B below the 512 KiBxtask policylimit — merging alongside #2977 or #2104 will exceed524,288 B).
…a 32-lane sum counts the active lanes only The section declares the console's wave of 32, which WARP (4-lane waves) refuses: run_cases_wave32 skips WARP there, as synthetic_tests does. A second test runs the section over 32 lanes with only lanes below s2 active; lane l adds 2^l, so the sum is 2^s2 - 1 in any order and the inactive lanes' +0.0 must not count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks both, and thanks for chasing the WARP message down. ab08acb:
AI-assisted (Claude Code). |
|
Measured offline on the title's shaders (the method in #1247), head
So this does what you said: with #385 and #1065 on top, all five programs translate and validate. I didn't measure #2978 + #385 without #1065. On #385 alone, the 13 join programs it unblocks on Two things for the merge order:
Offline counts and unit tests only; no program names or data. |
|
Crossed with your |
|
Both result dwords at I ran 36 wave32 dispatches per adapter with positive and negative inputs and nine masks, including empty, full, alternating and lane 31 alone. Each active lane contributed ±(1 + (seed + 256 × lane) × 2⁻⁵²). The inputs are multiples of 32 units of 2⁻⁵², so every intermediate sum is exactly representable. Each dispatch read back two pairs per lane. The first pair kept both sentinel words in masked-off lanes; after restoring EXEC, all 32 lanes copied out the expected scalar pair. The empty mask gave +0. All 1,152 lane rows matched on each adapter.
I verified the loaded WARP DLL paths and validated the shader with Windows SDK |
|
Automated triage for the maintainers. Needs work. The core of the change reads well: What is in the way:
CI: failing. Generated by Claude Code |
|
Follow-up on the rounding and guest Wave64 cases discussed above. On an RTX 5070 Ti we tested a separate implementation built on #439 (
This was a separate implementation on a different base from Implementation and testing were assisted by Codex. |
Stacked on #2348 (
v_cvt_f32_f64): its three commits come first; the last commit is this change.Problem
WaveActiveSumof adoubleexpands, on the console, into a whole-wave section that works on dword pairs:v_cndmaskputs each lane's pair (or +0.0) in two VGPRs, each DPP step moves the two dwords with twov_mov_b32,v_add_f64adds the pairs,v_permlanex16joins the rows,v_readlanereads the result (on wave64, the two halves' results, added once more), and ans_mov_b32copies each dword to the register that leaves the section. The section simulator (emit/wave.rs) follows 32-bit operations only, so both dwords are unknown, and a program that reads them is refused:a whole-wave section step the simulation does not follow is not supportedThat's what five programs in this title hit once #2348 lowers the
v_cvt_f32_f64that reads the sum (before #2348 they stop at that instruction).Change
emit/wave.rs:Sym::Red64 { lo, hi, mask, lanes, high }is one dword of the binary64 sum overlanesofmask ? (lo, hi) : +0.0.v_add_f64reads both of its sources as (low, high) pairs: register pairs, SGPR pairs, inline 0. It joins two terms of one masked sum when their lanes are disjoint, and writes both destination dwords.v_mov_b32with DPP,v_permlanex16_b32andv_readlane_b32move these symbols a dword at a time already.s_mov_b32now keeps what its source holds, where it used to be unknown. A sum over every lane isShape::Sum64.emit/lower/sum64.rs(new, keepinglower.rsunder the 512 KiB policy):Shape::Sum64becomes onewaveActiveOp.f64(sum) overmask ? double(lo, hi) : 0.0. Both dwords share it, one per block. It setsFLOAT64,INT64andWAVE_OPS.Tests
wave::tests::a_binary64_sum_is_followed_through_its_dwords: the compiler's wave32 expansion (four DPP steps,v_permlanex16,v_readlane,s_mov_b32copies) givesSum64for both read dwords and both copies.wave::tests::a_binary64_sum_counting_a_lane_twice_is_not_a_sum: the same, with a lane added to itself first, gives no shape.valu_tests::a_whole_wave_binary64_sum_reaches_the_host(GPU): the same section run end to end on the host, thenv_cvt_f32_f64of the copied pair; five values,x as f32expected. Passes on an RX 9070 XT (RADV through vkd3d-proton, GE-Proton 11-14, DXC'sdxil.dll).Measured over the title's shader pack
All 25,889 distinct containers in
shaders.rpfwent throughemit::translate_withoffline, on main63bcca4+ #2348 and then with this commit added:5dc3b25986622949, refused before)Every other program's output is byte-identical: the
s_mov_b32change gives nothing else a new shape. The new program's DXIL converts with dxil-spirv (master). The other four (6f225b641c5b0708,6871d6e4b3ac9a10,926c46bab3b86bd6,a10179ab7eda0dc3) get past the section and stop later ata lane-mask join of an untracked mask, a separate class.Windows test binary under Proton on the RX 9070 XT: 306 passed and 2 failed. The 2 failures (
hosts_that_do_not_fuse_are_named,stub_pipeline_is_created) fail on main in the same environment too.cargo clippy -p victory-shader -- -D warningsis clean,cargo xtask policyis ok, andlower.rsis 523,410 bytes.Not run: the differential tests (no console compiler here) and NVIDIA.
🤖 Generated with Claude Code