Repository navigation
startup: accept sample_b and get_lod under entry EXEC after a join - #2659
Conversation
tedin7
left a comment
There was a problem hiding this comment.
Review of head 524873c (after update with main). Fixture-level review only; no executable or capture-row claims.
Finding (blocks merge): dropping the blocks gate accepts divergent branches, not only uniform joins.
tools/startup/gfx2hlsl.py (the image_sample_b and image_get_lod guards in Stage.image, about lines 5088-5110) now checks only kind == 'ps' and exec_known. Nothing clears exec_known on a branch, and the branch lowering (about line 3096) uses the per-lane bits (vcc & 1) == 0, (vcc & 1) != 0, (exec & 1) == 0. In the emitted HLSL, lanes of one quad can therefore take different pc paths before the SampleBias / CalculateLevelOfDetail call. Those calls need uniform control flow for their derivatives. The plain sample keeps SampleLevel(..., 0) whenever blocks is non-empty (line ~5214), for the same reason.
Reproduced on this head: I took the plain sample_b fixture and inserted s_mov_b32 s0,s0; s_cbranch_<cond> +1; s_mov_b32 s1,s1 before the sample. s_cbranch_vccz, s_cbranch_vccnz, s_cbranch_execz and s_cbranch_scc1 are ALL accepted and emit SampleBias inside the pc == state machine. Only scc has a uniformity notion (scc_uniform); vcc/exec branches have none here.
Why the new tests miss it: the "join" fixture uses only an scc1 branch, and the "divergent" control only clears exec_lo (which already cleared exec_known before this PR). No control puts a vcc/exec-conditioned branch before the sample.
Suggested fix: accept the join only when every branch before the op is proven wave-uniform (for example scc with scc_uniform, or a compare whose sources are uniform, as already tracked in uniform_vcc_compares), refuse otherwise, and add a negative control with s_cbranch_vccz / execz before the sample in both check files.
Smaller points
check_guardsintests/startup_image_sample_b_check.py: the new "accepted after a join" case swallowsAttributeError, so it passes even if the call fails for an unrelated reason. The WARP draw case is the real guard there.- The WARP draw for the join case was not run by this review (no Windows run); it must pass on Windows before any merge.
Checked (Linux, detached worktree at this head)
python3 -B tests/startup_image_sample_b_check.py: passpython3 -B tests/startup_gfx2hlsl_image_get_lod_check.py: passpython3 tests/docs_links_check.py: passpython3 tests/bidi_controls_check.py: passgit diff --check origin/main...HEAD: clean- Branch-condition probe above: vccz/vccnz/execz/scc1 all accepted.
Not merging. Leaving this for the author to tighten the uniformity condition.
AI-assisted; commands listed were executed locally.
Review on R0Y00#2659: dropping only the blocks gate accepted vcc/exec branches before SampleBias / CalculateLevelOfDetail. Track uniform_cf (cleared by divergent s_cbranch_*), keep scc-uniform joins, and refuse vccz/vccnz/execz/execnz before the op in both fixtures. Refs R0Y00#2618 Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Review on R0Y00#2659: dropping only the blocks gate accepted vcc/exec branches before SampleBias / CalculateLevelOfDetail. Track uniform_cf (cleared by divergent s_cbranch_*), keep scc-uniform joins, and refuse vccz/vccnz/execz/execnz before the op in both fixtures. Refs R0Y00#2618 Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
e08e81a to
697419d
Compare
|
Pushed 3c56f58 on top of 697419d (no force). What: Why: implicit derivatives need all four lanes of the quad at the call together. Tests: Commands executed locally:
AI-assisted; commands listed were executed locally. |
tedin7
left a comment
There was a problem hiding this comment.
Review of head 3c56f58 (independent, code + fixture tests).
Checked:
Stage.image: the oldlen(self.blocks) > 0gate is replaced by a wave-uniform control-flow flag (uniform_cf), still requiring pixel stage and a known entry EXEC. Divergent branches before the read clear the flag, so those reads stay refused.- The follow-up commit closes the divergent back edge after the read (loop with a per-lane exit): the read sites and divergent back edges are recorded, and a read spanned by one is refused. Logic looks right for both
image_sample_bandimage_get_lod. - No other open or merged PR covers this slice (searched sample_b / get_lod). Independent of #2657.
- Scope: claims only source-built fixtures, no startup claim, so no executable result is needed here.
Commands run (Linux, on the exact head):
python3 -B tests/startup_image_sample_b_check.pyandtests/startup_gfx2hlsl_image_get_lod_check.py: passpython3 -B tests/docs_links_check.py,python3 -B tests/bidi_controls_check.py: passgit diff --check origin/main...HEAD: clean- Mutation 1: force the uniform-CF gate to always accept -> both tests fail.
- Mutation 2: disable the back-edge refusal -> both tests fail.
Verdict: sound, no blocking findings. Windows dev+release receipt follows separately.
AI-assisted; commands listed were executed locally.
Review on R0Y00#2659: dropping only the blocks gate accepted vcc/exec branches before SampleBias / CalculateLevelOfDetail. Track uniform_cf (cleared by divergent s_cbranch_*), keep scc-uniform joins, and refuse vccz/vccnz/execz/execnz before the op in both fixtures. Refs R0Y00#2618 Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
3c56f58 to
02c8188
Compare
tedin7
left a comment
There was a problem hiding this comment.
Review of head 02c8188 (rebase of 3c56f58 onto current main).
git range-diffof the three PR commits against the previous head: all three are identical (=), so my earlier review of 3c56f58 carries over unchanged.- Re-ran on this exact head:
tests/startup_image_sample_b_check.py,tests/startup_gfx2hlsl_image_get_lod_check.py,tests/docs_links_check.py,tests/bidi_controls_check.pyall pass;git diff --check origin/main...HEADclean.
No blocking findings. Windows dev+release receipt for this head follows.
AI-assisted; commands listed were executed locally.
image_sample_b and image_get_lod refused any prior branch target even when EXEC was still the entry mask (M200-01 B/L: outside straight-line with every lane active). Drop the blocks gate; keep the pixel + exec_known proof. Fixtures: uniform join before the op accepted; divergent EXEC refused; WARP draw of join-before sample_b bias -1. Refs R0Y00#2618 Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Review on R0Y00#2659: dropping only the blocks gate accepted vcc/exec branches before SampleBias / CalculateLevelOfDetail. Track uniform_cf (cleared by divergent s_cbranch_*), keep scc-uniform joins, and refuse vccz/vccnz/execz/execnz before the op in both fixtures. Refs R0Y00#2618 Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
…ack edge A divergent backward branch after the read still lets lanes of one quad leave the loop at different passes, so the read runs again with uneven quads although no divergent branch precedes it in program order. Record the read sites and the divergent back edges and refuse a read that one of them spans. Tests: synthetic words with s_cbranch_vccnz/execnz right after the read, back to it (fail before, pass after).
02c8188 to
31913ad
Compare
|
Win2025 run on #2659 (heads 02c8188, then 31913ad after another rebase; the PR's own three commits are identical by range-diff) did not produce a pass:
So no Win2025 dev+release receipt for this PR yet. The PR's own tests ( AI-assisted; commands listed were executed locally. |
R0Y00#2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Change
Refs #2618 (batch M200-01, work codes B and L).
image_sample_bandimage_get_lodrefused any prior branch target even when EXEC was still the entry mask — the M200-01 shape “outside straight-line with every lane active.”blocksgate inStage.imagefor both forms; keep pixel stage +exec_known.startup_image_sample_b_check.py: join control + WARP draw of join-before bias -1 (same mip as plain).startup_gfx2hlsl_image_get_lod_check.py: join/branch accept; divergent EXEC refusal.AI-assisted.
Verification
Commit under test: this PR head.
All passed on Linux. This agent could not run DXC / WARP / hardware draws.
Windows verification:
Expect: controls pass;
startup_image_sample_b_warpincludes the join-before bias -1 case; hardware may pass or skip 77.Evidence and follow-up
Checklist