Skip to content

perf(shader): reuse first-lane producers across one EXEC narrowing - #728

Open
GDemay wants to merge 3 commits into
pragyaangaur:mainfrom
GDemay:codex/campaign-exec-subset
Open

GDemay wants to merge 3 commits into
pragyaangaur:mainfrom
GDemay:codex/campaign-exec-subset

Conversation

@GDemay

@GDemay GDemay commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Related to #553. A first-lane read of a proven uniform vector producer can reuse that producer across a direct s_and_saveexec_b64 narrowing in the same block. Both SSA words of the read mask must come from that exact narrowing and both producer mask words must match its input. The preexisting consumer and cycle checks remain in place. Unrelated masks and results that escape the narrowed mask retain their synchronization.

Performance

Metric Before After Change
Completion, 8,192 groups × 64 guest lanes per dispatch 1.6214 ms 1.4906 ms −0.1308 ms (−8.07%)
Completion, one group per dispatch 1.3274 ms 1.3445 ms +0.0171 ms (+1.29%, overlapping timings)
Emitted group barriers for the benchmark shader 5 0 −5 (−100%)
Correct dwords checked per build including warm-up 39,326,400 39,326,400 Identical

Baseline 27380446e227799438b2c41693426ebb5c5e4420, production candidate 618de165f2e7519d8c347845859be3be3034ddda. Apple M5, macOS 27.0 (26A428), CrossOver Wine 11.0, D3DMetal 4.0 beta 3, Rust 1.98.1 Windows gnullvm debug build. Five processes per arm in alternating ABBA order, with the same original shader and benchmark instrumentation on both revisions. Each process discarded three warm-ups and retained twelve samples per group size. At 8,192 groups, individual samples ranged 1.3985–4.7713 ms before and 1.2953–2.4710 ms after. Process medians ranged 1.5973–1.7782 and 1.3675–1.5187 ms respectively. Completion includes queue submission, the recorded readback copy, fence creation, signaling and wait. GPU buffer and pipeline setup, list recording and CPU readback comparison are outside this interval. Game coverage and frame time remain unmeasured.

Verification

On the same 32-lane hardware, both builds checked nine separate correctness dispatches of 64 dwords each. The cases cover lower-only, upper-only, both and empty EXEC, an independent requirement for halves, unrelated narrowing and an escaping result. The standalone Wave64 variant was skipped on this Wave32 host. The emission test compares against a same-EXEC control and verifies that the negative cases keep their barriers. Independent review checked the paired SSA comparison and instruction order.

WINEDLLOVERRIDES='d3d12,d3d12core,dxgi=b' VICTORY_REQUIRE_GPU_TESTS=1 \
  tools/macos/test-wine.sh --locked -p victory-shader --lib \
  a_first_lane_read_under_narrower_exec -- --nocapture --test-threads=1

Build the ignored narrower_exec_completion benchmark at both revisions with the same test-only fixture and run the already built binaries alone and interleaved. Use VICTORY_NARROW_EXEC_TIMING=1 with --ignored --nocapture --test-threads=1. This proof concerns one explicit EXEC narrowing. Fixed code-table proofs in #714, divergent first-lane meetings in #719 and arbitrary LDS sources are separate.

To reproduce against the pinned base, copy the benchmark and correctness instrumentation diff from this PR (crates/victory-shader/src/emit/host.rs and crates/victory-shader/src/emit/halves_tests.rs) into a base worktree. Leave emit/lower/first_lane.rs at the base revision. This gives the same instrumentation in both arms. The structural proof assertion intentionally fails on the base.

@GDemay
GDemay marked this pull request as ready for review November 28, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant