Repository navigation
startup: accept slot 57 VCC branches on a wave-uniform compare (Part of #2413) - #2566
Conversation
tedin7
left a comment
There was a problem hiding this comment.
Review of head acc85ad (comment only, not merging for now).
Finding (test gap, not a proven code bug):
tools/startup/gfx2hlsl.py:2429now requiresnot mesh_vregs([tok]) and self.uniform_source(tok)for every compare source. In the new tests only the VGPR case is exercised ("a VGPR compare"). Withself.uniform_source(tok)replaced byTrue,python3 -B tests/startup_mesh57_skeleton_check.pystill printsok. So the SGPR half of the uniformity proof has no guard:uniform_sourcealso refuses SGPRs invarying_s, inmasks, or written before the last join (gfx2hlsl.py:2550-2565), and none of those is covered by a refusal control.- Please add a control where the compare source is such an SGPR (for example an SGPR in
masks, or one written before a join) and the VCC branch must be refused. It should fail when that call is dropped.
Checked and fine:
- The VCC definition set at joins (
all(definitions)empties the set when a path has none), the EXEC-at-branch and EXEC-at-compare checks, and the refusal of other VCC writes. Mutatingif mask is not None or not vcc_compares:toif False:makes the join control fail, as intended. - No other open or merged PR covers this slice (only #2548, which this extends).
- Fixture tests are the in-repo ones; the claim about captures is not something I can verify. The PR does not claim a title startup result.
Still open before a merge: CI is pending on this head, and the WARP/hardware draw cases (draw ... warp) need a Windows run on the head after the branch is brought up to date (5 behind main). I did not run those.
Commands run locally (Linux worktree on this head):
python3 -B tests/startup_mesh57_skeleton_check.py: ok- mutation 1 (
if False:at the branch check): fails as expected - mutation 2 (
uniform_sourcereplaced byTrue): still ok (the gap above) python3 tests/docs_links_check.py: passpython3 tests/bidi_controls_check.py: passgit diff --check origin/main...HEAD: clean
AI-assisted; commands listed were executed locally.
s_cbranch_vccz and s_cbranch_vccnz were refused outside the exchanges as a wave-wide condition. Accept them when every path reaching the branch last wrote VCC with a v_cmp under the full EXEC mask, no other VCC write follows, EXEC is still the full mask at the branch, and Stage proves the compare's sources wave-uniform (no VGPR, uniform SGPRs or constants). VCC is then all ones or all zeros, so the per-lane test equals the wave-wide one. Anything else stays refused. Tests: taken and not-taken vccz and vccnz branches, drawn on WARP and hardware against the CPU model; refusals for a VGPR compare, a narrowed EXEC at the branch, a VCC write between the compare and the branch, and a join where one path has no VCC definition. Part of R0Y00#2413. AI-assisted.
Refusal controls for the slot 57 branch walk: s_call_b64 and s_swappc_b64 after the count exchange (indirect control flow), a forward s_cbranch_execnz (wave-wide condition), and an s_branch from between the exchanges to after the count exchange. Each is derived from an accepted fixture and checked to reach its own refusal. AI-assisted.
A uniform compare that writes VCC under a narrowed mask leaves the other lanes at 0, so restoring EXEC before the branch does not make VCC uniform. The control narrows EXEC with s_and_saveexec_b64, compares, restores EXEC to -1 and branches on vccz; it must stay refused. AI-assisted.
Stage proves each compare source with uniform_source. The VGPR control is also caught by mesh_vregs, so nothing pinned uniform_source itself: an SGPR written before the last join is not proven uniform and the VCC branch must stay refused. Reported in review of the pull request. AI-assisted.
|
Thanks, confirmed: with Added The branch is rebased onto main AI-assisted. |
tedin7
left a comment
There was a problem hiding this comment.
Review of head f8643e7 (fixture and code review only, no executable run).
Code: the proof in mesh_skeleton is sound. VCC compares are tracked as a set, merged at joins (any path without one empties it), emptied by any other VCC write, and the branch needs a full EXEC. Stage.translate then requires every tracked compare to have wave-uniform sources (no VGPR, uniform SGPR or constant). I found no sibling table or callsite left out. No other open or merged PR covers this slice (#2548 is the base).
Checked locally on this head:
python3 -B tests/startup_mesh57_skeleton_check.py: okpython3 tests/docs_links_check.py: okpython3 tests/bidi_controls_check.py: okgit diff --check origin/main...HEAD: clean- Mutations, each reverted afterwards, and each made the skeleton check fail: dropping the narrowed-EXEC test at the branch; dropping the subset check against uniform compares; letting a join keep a definition from one path only; dropping the
uniform_sourcerequirement. - One mutation survived: removing the
ops[0] in ('vcc', 'vcc_lo')destination test. Not a blocker; a compare writing a non-VCC SGPR pair is not in the set because the VCC-write test is checked first. A one-line control would still pin it.
The CPU-reference draws need DXC and WARP, so they were not run in this review. A Windows WARP run will follow before any merge.
AI-assisted; commands listed were executed locally.
|
Win2025 WARP receipt for head f084999 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
tedin7
left a comment
There was a problem hiding this comment.
Review of head f084999: this head is f8643e7 merged with current main. The PR's own diff (3 files) is unchanged, so the earlier review of f8643e7 applies.
Checked on this head: CI green, and the Windows Server 2025 WARP dev and release run passed (receipt above, tests/startup_mesh57_skeleton_check.py rc=0).
Scope: fixture and code review only. No executable run.
AI-assisted; commands listed were executed locally.
Part of #2413, the extension of the forward-branch work of #2548 (claim).
#2548 refuses
s_cbranch_vccz/s_cbranch_vccnzoutside the exchanges as a wave-wide condition. This accepts them when VCC is provably the same bit in every lane:v_cmp_*under the full EXEC mask.mesh_skeletontracks the set of such compares and merges it at joins; a path without one empties it.Stageproves each compare's sources wave-uniform: no VGPR operand, uniform SGPRs or constants.VCC is then all ones or all zeros, so the per-lane test equals the wave-wide one. Anything else stays refused with the existing message.
Three test commits add refusal controls:
s_call_b64,s_swappc_b64, a forwards_cbranch_execnz, and ans_branchfrom between the exchanges to after the count exchange (#2548 had no controls for these), a VCC compare made under a narrowed EXEC before EXEC is restored and the branch is taken, and a compare whose SGPR source was written before a join.Tests (Windows 11, Python 3.14, DXC from the Windows SDK 10.0.26100), on main
381abc3plus the four commits:python -B tests/startup_mesh57_skeleton_check.py: ok.vcczandvccnzbranches, and avcczbranch after a join, translate.... draw <dxc> offscreen_check warpandhardware: ok. The branch cases are drawn against the CPU model (WARP: Microsoft Basic Render Driver; hardware: NVIDIA GeForce RTX 5080).docs_links_check,bidi_controls_check,startup_gfx2hlsl_watch_check,startup_translator_check,startup_gfx2hlsl_join_symbols_check,startup_gfx2hlsl_refusals_check,startup_compute_translate_check,startup_gfx2hlsl_capture_check,startup_gfx2hlsl_waitcnt_depctr_checkandstartup_gfx2hlsl_loop_constants_check.Mutation checks, run by hand. The controls fail on each:
uniform_sourcereplaced byTrue(only the SGPR-before-join control fails; the VGPR control stays refused throughmesh_vregs);s_cbranch_execnzaccepted;Measured on a local capture (counts and instruction shape only, inputs private): with #2548 applied, 77 slot 57 requests stopped at a VCC branch on a wave-wide condition. With this change none stop there, and none of them translates yet: they now stop at
a branch enters or crosses a group-memory exchange. In the program I inspected,v_cmpx_gt_u32narrows EXEC at the end of the region before the count exchange and ans_cbranch_execztargets its firsts_barrier, so the exchange is entered under a narrowed EXEC. Supporting that shape is the next step; I inspected one program and have not checked that the others stop for the same reason, and an earlier version of this text wrongly described it as a third group-memory exchange.AI-assisted.