Repository navigation
compute: accept EXEC as the destination of s_bitreplicate_b64_b32 - #3179
Conversation
Captured compute programs set EXEC from a lane pattern with s_bitreplicate_b64_b32 exec, <constant>. The direct path accepted only an aligned general SGPR pair or VCC as the destination. EXEC (s126/s127) is now accepted in compute; the two halves are written like any other EXEC pair write. Odd pairs, other special registers and graphics stay refused. native_bitreplicate_exec_hardware sets EXEC from four patterns, stores lane values under it, restores EXEC and stores the saved EXEC words, against a CPU reference; the controls keep an odd destination refused. AI-assisted.
|
Review of src/gfx1013_direct_compute.inl and src/gfx1013_compute_native.cpp changes: s_cmp_lg_u64 is implemented as inequality, not signed less-than (BUG) Lines 2258-2264: const bool eq = n == "s_cmp_eq_u64";
const auto op = eq ? "eq" : "ne";
const auto combine = eq ? "and" : "or";
cond = ir.value(string(combine) + " i1 " + cmp(op, a_lo, b_lo) + ", " + cmp(op, a_hi, b_hi));For For Fix: implement proper signed 64-bit comparison: auto hi_neq = cmp("ne", a_hi, b_hi);
auto lo_signed_lt = cmp("slt", a_lo, b_lo);
cond = ir.value(string("select i1 ") + hi_neq + ", " +
ir.value(string("select i1 ") + cmp("slt", a_hi, b_hi) + ", true, false") +
", " + lo_signed_lt);s_bitcmp0_b64 / s_bitcmp1_b64 — looks correct ✓ s_cmov_b32/b64/k_i32 — looks correct ✓ v_cvt_f16_u16/i16/u16/i16 — looks correct ✓ s_bitreplicate_b64_b32 — looks correct ✓ transfer() clobber list — looks correct ✓ Summary: Blocker on s_cmp_lg_u64. The signed less-than comparison for 64-bit values needs a proper fix as shown above before this can merge. |
|
Thanks for reading through it. AI-assisted. |
pigalot
left a comment
There was a problem hiding this comment.
I reviewed f37a6dd3 merged over main d474a393. The merge is clean (tree 3b43fff4) and git diff --cached --check is clean.
What I traced.
- Acceptance: the change only widens the destination check. EXEC (
s126) is now accepted next to VCC in compute, and odd pairs, other special registers and graphics stay refused. - Writes:
write(i.dst)andwrite(i.dst + 1)go through the same scalar storage as any other EXEC pair write.active()readss126on every vector write in wave32, ands127for the upper half in split wave64, so the lane mask applies from the next instruction. - Analysis:
transferalready clears both words fors_bitreplicate_b64_b32, which leaves EXEC unknown. SCC is not written.
What I ran. I built compile_dxil native_store_replay in dev and release (plus native_compute_ir_dump in release for the _ir tests), then ran
python .agentic\scripts\with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^(native_bitreplicate_exec_(controls|hardware)|native_salu[a-z0-9_]*|native_direct_container)$'- Results: 17/17 pass in Debug and Release
/O2, with no skips.native_bitreplicate_exec_hardwarecovers all four sources and checks the lane stores under the replicated EXEC, both saved EXEC words, the unchanged SCC and the guards. - Negative control: on
main6cc46a3c, the PR'snative_bitreplicate_exec_check.py controlspasses, because the odd-pair refusal predates this PR.hardwarefails, because the replay compile refuses+0x24: bitreplicate requires an aligned general scalar pair or compute VCC.
Mutants in src/gfx1013_direct_compute.inl. For each, I rebuilt in dev and ran both new tests:
| Mutant | Result |
|---|---|
| high word replicated from S0[15:0] | killed (0x0000ffff, word 136: 0xffffffff vs 0x00000000) |
| high word not written | killed (0xff00ff00, word 136: 0x00000000 vs 0xffff0000) |
| odd-pair refusal removed | killed (controls) |
Restored and rebuilt afterwards; git diff --quiet is clean.
Non-blocking. SCC is checked only from 0, so a lowering that cleared SCC would pass. A case that sets SCC to 1 before the bitreplicate would pin that too. Wave64 isn't exercised, which matches the PR's scope.
Verdict: approve on f37a6dd3.
Environment: NVIDIA GeForce RTX 5090 driver 610.88, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32, debug layer off.
CI: Build and test on Windows passes on f37a6dd3.
This reply was AI-assisted.
Fixes #3170. Part of #2935. Target branch
main. This is the direct C++ path; #3030 (merged) coveredgfx2hlsl.py.Change (
src/gfx1013_direct_compute.inl):s_bitreplicate_b64_b32now accepts EXEC (s126/s127) as its destination pair in compute.active()reads s126 only. In split wave64, the upper half uses s127.Tests. The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on
main454fc0edplus this commit.native_bitreplicate_exec_hardware(new) sets EXEC from four sources: the literals0xff00ff00,0x0000ffffand0xf0f0f0f0, and the inline constant 5. It also checks that SCC is unchanged. It stores lane values under that EXEC, restores EXEC and stores the saved EXEC words, all against a CPU reference.native_bitreplicate_exec_controlskeeps an odd destination refused.native_direct_containerand thenative_salu*tests pass.native_bitreplicate_exec_hardware.Measured on a local capture (counts and instruction shape only) with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requestsonmain6057071b. Since then only #3147 (3a550d0a, f16 frexp inline sources) touchesgfx1013_direct_compute.inl, outside this path.s_bitreplicate_b64_b32 exec, <literal>.v_permlanex16_b32(cpp-migration: lower v_permlane16_b32 and v_permlanex16_b32 in the direct C++ compute path #3021, PR shader: lower v_permlane16_b32 and v_permlanex16_b32 in direct compute #3022) and 3 at "direct scalar move destination" (s_mov_b32 exec_hi).AI-assisted.