compute_store_aot: accept two-exit compute programs, then lower a guarded read–compute–write kernel #721
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#721
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@roansystemlabs on GitHub · 2026-11-22 22:46 UTC · original
Problem
After #708, the next compute stops in the fixed-profile archive rescan (
docs/experiments.md) are:pixel_aot.container_code()accepts a seconds_endpgmonly for pixel programs (stage == 0 and markers == 2, verified by_check_two_exitsfrom #477). Every compute (and mesh) program with more than one exit is rejected before any instruction is lowered. Thecompute_store_aotCLI also callscontainer_code(..., stage=5)withoutllvm, which the two-exit check needs.compute_store_aotstores known words (immediates, constant-buffer words or the dispatch-thread index) into one raw UAV. It has no vector memory reads, no general ALU and no control flow. Address forms such as av_mad_u32_u24row pitch are rejected.shader_profile_audit.classify()reads the PSV0 group size before it callscontainer_code(). The 1,054 records that stopped at thread-group dimensions were never checked for exits, so some of them will now stop at the multi-exit check. We cannot measure that overlap without the archive.For pixel programs,
docs/experiments.mdreports that 5,465 of 6,189 multi-marker records (88%) had exactly two markers. If compute looks similar, the two-exit case covers most of the 1,002, but that is an assumption until counted.Proposal
The goal is the first real compute kernel from the console format: an edge guard, a buffer read, some arithmetic and a guarded store, dispatched as 8×8 groups and verified on hardware. We would do it in small PRs, each one reviewable on its own, and start each step only after the previous one has landed.
Exits. Let compute (
stage == 5) use the same_check_two_exitsverifier and rules as #477: a direct branch to the block after the early exit, skipped alignment NOPs allowed, and rejection of unresolved transfers, branches into literals or padding, and disconnected blocks. Thecompute_store_aotCLI would passllvmthrough. Source-built two-exit compute fixtures would get the same negative controls as the pixel ones. This step extracts the code span only; lowering comes next. Mesh (stage == 13) stays as it is.Guard. Lower the early exit in
compute_store_aot, in two forms:s_cmp*+s_cbranch_scc0/1around the earlys_endpgm) becomesif (cond) return;;v_cmp*+s_and_saveexec_b64, with an exec branch around the earlys_endpgm) becomes a store guarded byif.The exact branch shapes would come from the LLVM 15 compile of source kernels (see Verification) before any lowering code. Stores are side effects, so the per-lane select of #338 option A (#651) does not apply here; the guard has to be a real branch. Everything outside these two forms is rejected.
Reads.
buffer_load_dword(idxen/offen) from another caller-bound buffer descriptor, withvmcntwaits tracked like the currentlgkmcntwaits.Arithmetic. A small integer and float subset for addresses and values (add, mul, mad, shifts, min/max,
v_mad_u32_u24row pitch). See question 2.First kernel. A complete guarded read, compute and write kernel with 8×8 groups and a 2D dispatch, with half of the threads out of range. After this PR, we would ask you for a CS rescan.
Alternatives
compute_store_aotprofile, one verified form at a time.if (id >= n) return;kernel needs.Verification
All inputs are source-built synthetic kernels; no game files.
llvm-mc-15/libLLVM-15.so.1in the Ubuntu CI job. For the exit and guard forms, we would include the LLVM 15 compile and disassembly of small source kernels (llc-15 -mcpu=gfx1013) with uniform and per-lane early returns. The PR would quote the exact commands._warpand_hardware. Hardware runs use an RTX 3070 on Windows 11 with the D3D12 debug layer on; each PR records the commit, driver, Windows build and GPU load. We also run the pure-Python checks fromAGENTS.md.Limits stated up front:
Questions
docs/experiments.mddoes for pixel (two/three/four/five markers and the most common layout)? It tells us whether step 1 should stay two-exit only.pixel_aotALU lowering, or keep a small separate subset insidecompute_store_aot? We will follow your choice.AI-assisted: yes
Checklist
tools/compute_store_aot.py,tests/compute_store_check.pyortools/shader_profile_audit.py. No issue or PR mentions multi-exit or early-exit compute. #477 covers pixel programs only. #606 adds a compute fallback for mesh draws, in other files.)@R0Y00 on GitHub · 2026-11-22 22:57 UTC · original
Please start with the source-built two-exit extraction PR. Reuse #477's branch and instruction-boundary checks, keep the stage and exact-marker limit explicit, and have the compute CLI and audit pass through LLVM. Include wrong-target, literal/padding and disconnected-exit controls. No new compute marker histogram is available here, so keep the counts separate from expected coverage. For a later lowering PR, model a per-lane guard as actual control flow around memory side effects. Keep the initial ALU subset small, reusing individual helpers only when their semantics match. The extraction PR can proceed independently of that decision.
@roansystemlabs on GitHub · 2026-11-22 23:19 UTC · original
Thanks. Starting the source-built two-exit extraction PR now, scoped exactly as above (extraction only; the per-lane guard and ALU subset stay for later PRs). I'll link it here.
@roansystemlabs on GitHub · 2026-11-22 23:23 UTC · original
To keep the plan visible: we intend to carry the whole sequence in this issue ourselves, one small PR at a time (two-exit extraction → per-lane guard as control flow → vector reads → small ALU subset → first read–compute–write kernel), each opened only after the previous one is reviewed. The extraction PR is in progress now.
@roansystemlabs on GitHub · 2026-11-23 00:03 UTC · original
Step 1 is up: #738 (extraction only; no lowering). The per-lane guard comes next, as control flow around the store.
@roansystemlabs on GitHub · 2026-11-23 00:47 UTC · original
Thanks for merging #738. Step 2 (the per-lane guard as control flow around the store) is next.
@R0Y00 on GitHub · 2026-11-23 00:50 UTC · original
Step 1 merged in #738 after the SPIR-V cache repair. Source-built LLVM 15 fixtures now exercise the #477 verifier for two-exit compute programs. This is extraction only, with no new archive count. The per-lane guard can proceed around the store as discussed, and this issue remains open for the later steps.
@roansystemlabs on GitHub · 2026-11-23 02:18 UTC · original
Step 2 is up: #776 (per-lane guard lowered as an
ifaround the masked stores; unmasked stores after the exec restore stay outside). Vector reads come next.@R0Y00 on GitHub · 2026-11-23 03:05 UTC · original
#776 merged as
e861e7e. The LLVM 15 fixtures now verify both guard shapes: masked stores to exit and a restored mask with later unconditional stores. WARP and RTX compared the buffers, and both Windows configurations and both Linux checks passed. This covers the store-guard step. The issue stays open for vector reads and the combined read–compute–write fixture.@roansystemlabs on GitHub · 2026-11-23 03:27 UTC · original
Step 3 is up: #788 (vector reads from a caller-bound source buffer, copied to the store; builds on the guard from #776). The small ALU subset and the combined read–compute–write fixture come next.
@R0Y00 on GitHub · 2026-11-23 04:25 UTC · original
#788 merged as
b5e2c5c. The guarded raw and indexed reads now copy one word from caller-bound t0 to u0, and the binding requires stable input bytes disjoint from the writes. Both Windows configurations and both Linux jobs passed. The next slice is the small ALU subset and one combined read–compute–write fixture, using the same guard and source-buffer contract.@roansystemlabs on GitHub · 2026-11-23 05:19 UTC · original
Thanks. We're taking step 4: the small ALU subset plus one combined read–compute–write fixture, on the #776 guard and the #788 source-buffer contract, with LLVM 15 gfx1013 fixtures and full readbacks on WARP and RTX 3070 under the debug layer. PR to follow.
AI-assisted: yes.
@roansystemlabs on GitHub · 2026-11-23 09:57 UTC · original
Step 4 is up: #835. It accepts four LLVM 15 gfx1013 instructions between a guarded t0 read and the u0 store (
v_and_b32,v_lshrrev_b32,v_mad_u32_u24,v_min_u32), reusing thepixel_aotmodels only where the semantics are identical, with one combined read–compute–write fixture built from source. RTX 3070 and WARP with the debug layer: 23 full readbacks each, no mismatches. Every other opcode stops with an explicit error. Add, mul_lo, left shifts, max and float are left for later slices, one fixture each.AI-assisted: yes.
@R0Y00 on GitHub · 2026-11-23 10:20 UTC · original
#835 is merged. The source-built guarded read–compute–write fixture now exercises the four ALU forms on the existing t0/u0 bindings, with full readback and negative controls. The issue remains open for the other arithmetic forms and the audit. The current MAD fixture uses 16-bit multiplicands, so the 24-bit truncation is covered by the generated-code check. A future GPU case with nonzero bits above bit 23 could distinguish that behavior independently.
@R0Y00 on GitHub · 2026-11-23 14:32 UTC · original
The missing GPU witness is up in #862. It keeps the original 16-bit-factor fixture and adds one guarded lane with bit 24 set in one factor and bit 25 in the other. WARP and RTX both produced 0x0df050e1 and left the other 319 words untouched. Removing either source truncation made word 0 differ (0xfef050e1 or 0xeff050e1). The remaining read–compute–write scope in this issue stays open.
@Jess-Doit on GitHub · 2026-11-23 16:37 UTC · original
I’ll take the guarded compute
v_mul_lo_u32slice from the remaining integer ALU work. I’ll extend #835’s source-built t0 read → guarded multiply → u0 store fixture and compare the full readback with a CPU reference, including a wrapping product, operands with bits above bit 23, and unchanged words for inactive lanes.Environment: Windows 10 22H2 (19045), GTX 1060 6 GB and WARP, Debug and Release. #898 also touches the compute translator and tests for its separate LDS operations. I’ll check the two diffs together before review. The pixel multiply work in #532/#678 is outside this slice.
AI-assisted (Codex).
@roansystemlabs on GitHub · 2026-11-23 19:06 UTC · original
Before the next arithmetic slice: could you rerun the compute audit on the current
main, now that two-exit extraction, the guard, reads and the first ALU subset (#835, #862) have landed? The README still shows 12 of 2,689 compute shaders, and the first-rejection histogram would tell us which form unblocks the most next.Once we have it, we'd take
v_add_u32,v_lshlrev_b32andv_max_u32one fixture each, in the same shape as #835 (LLVM 15 encodings, full readback on RTX 3070 + WARP, mutations), leavingv_mul_lo_u32to @Jess-Doit and checking overlap with #929–#954 first.AI-assisted.
@Jess-Doit on GitHub · 2026-11-23 19:45 UTC · original
The guarded compute
v_mul_lo_u32slice landed in #909 as4fbf91d. Its source-built readback passed on GTX 1060 and in-box WARP in Debug and Release, including the operand truncation and inactive-lane controls. This completes the multiply slice.AI-assisted (Codex).
@tedin7 on GitHub · 2026-11-24 01:04 UTC · original
Claiming the scalar-ALU slice for compute_store_aot (s_add_u32, s_sub_u32, s_and/or/xor_b32, s_lshr_b32 on the constant word), already open as #1090, with a dedicated readback and independent CPU reference. Environment: Linux with LLVM 19 locally; I rely on the Ubuntu LLVM 15 job and the Windows WARP jobs for the rest. AI-assisted.
@tedin7 on GitHub · 2026-11-24 01:13 UTC · original
Claiming the vector-shift/subtract slice for compute_store_aot (v_lshlrev_b32, v_ashrrev_i32, v_sub_nc_u32, v_subrev_nc_u32), with a dedicated readback and independent CPU reference. Environment: Linux with LLVM 19 locally; I rely on the Ubuntu LLVM 15 job and the Windows WARP jobs for the rest. AI-assisted.
@tedin7 on GitHub · 2026-11-24 02:21 UTC · original
Claiming the binary32 vector ALU slice for compute_store_aot: v_add_f32_e32, v_sub_f32_e32, v_subrev_f32_e32 and v_mul_f32_e32, with a dedicated 320-word readback, an independent CPU model that rounds each step to binary32, and one negative control per form. Fused multiply-add (v_fma_f32, v_fmac_f32_e32) stays refused because DXIL has no binary32 form with a guaranteed single rounding; NaN, infinity and denormals are not claimed. Environment: Linux with LLVM 15 and 19 locally; I rely on the Windows WARP jobs for the readback. AI-assisted.
@henriazz10 on GitHub · 2026-11-24 20:21 UTC · original
I'd like to take five more ALU slices for
compute_store_aot(gfx1013), as five separate PRs. Each one lowers only known words, and refuses modifiers it does not model (clamp,omod, neg/abs where not stated).s_bfe_u32/s_bfe_i32. Scalar bit-field extract on known words. The offset isS1[4:0]and the width isS1[22:16], per the ISA, including a width of 0 and an offset plus width past 32. SCC is unread, as in the existing scalar ALU subset.s_add_i32/s_sub_i32/s_abs_i32. Signed scalar add, subtract and absolute value on known words, with wrap-around results. SCC (signed overflow) stays unread.v_add_nc_i32/v_sub_nc_i32. The VOP3 signed vector add and subtract without carry-out. Theclampforms are refused.v_ldexp_f32. binary32S0 * 2^S1, with an exact CPU model covering overflow to infinity, underflow, denormals as handled by the existing f32 profile, NaN and infinity inputs, and large exponents.v_cvt_u32_f32. float to uint32 with RDNA2 saturation: NaN gives 0, negative values give 0, values of 2^32 and above give0xffffffff, and the rest truncate toward zero. A CPU model covers the edge inputs.For each slice:
None of these overlaps the open scalar-ALU, shift/subtract, binary32 add/sub/mul or neg/abs PRs.
AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) writes them, and Claude Code reviews them.
@henriazz10 on GitHub · 2026-11-24 21:20 UTC · original
I'd like to take five more ALU slices for
compute_store_aot(gfx1013). They will be five separate PRs, opened one at a time. Each lowers only known words and refusesclamp,omodand source modifiers that it does not model.v_add_co_u32withv_add_co_ci_u32. This is the 64-bit add pattern: the carry-out goes to VCC (or an SGPR) and the next add reads it as carry-in. The carry is tracked per lane as the translator's known value of the carry SGPR. Any other reader of that SGPR is refused.v_sub_co_u32/v_subrev_co_u32withv_sub_co_ci_u32/v_subrev_co_ci_u32. The same pattern for borrows.v_frexp_mant_f32andv_frexp_exp_i32_f32. These follow the ISA definitions for zero, infinity and NaN. They use the f32 profile's literal refusals, and the denormal assumption is stated as in thev_ldexp_f32PR.v_dot2_u32_u16andv_dot4_u32_u8. Unsigned integer dot products with accumulation, wrapping at 32 bits. Theclampforms are refused.v_mac_f32. A non-fused multiply-add: the product is rounded to binary32 before the add.Dis both an input and the output.Each PR will include:
AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) writes them, and Claude Code reviews them.
@henriazz10 on GitHub · 2026-11-25 02:15 UTC · original
I'd like to take the general per-lane compare and select for
compute_store_aot(gfx1013), as one PR.Today
v_cmp_*is accepted only as a lane-guard opener, with five predicates and operands that must be verified uniform, andv_cndmask_b32_e64only with an SGPR that holds a known constant mask. This slice adds the following.v_cmp_{f,lt,eq,le,gt,ne,ge,t}_{u32,i32},e32intovcc_loande64into an SGPR;v_cmp_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,tru}_f32, with the IEEE unordered rules for NaN.v_cndmask_b32_e32 vD, S0, vS1, vcc_loandv_cndmask_b32_e64 ..., vcc_lo|sNselect on that condition.s_and_saveexecon a per-lane condition built from loaded data, and the add-with-carry_ciforms. The existing guard path, the constant-mask select and the carry/borrow tracking keep their current behavior. A compare or carry that rewrites VCC invalidates the previous per-lane value.neg/abson f32) are refused unless modelled.clampand SDWA are refused.Evidence:
0x80000000, ±0, NaN on either side, and infinities;The open SDWA comparison PR (#1670) is for
pixel_aotand does not overlap with this.AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) writes it, and Claude Code reviews it.