Repository navigation
wave64_emulate_opt: flow-sensitive must-be-zero proof in _exec_writes_stay_inactive - #793
SweatierKey wants to merge 1 commit into
Conversation
KernelSmoker
left a comment
There was a problem hiding this comment.
Independent Linux/CPU verification of PR head e72218ed2a4116737cd4bfebbfddb79558c077ce on base d0da7dade8b688f2e0f7f23f4155d6cbb438809e: tests/test_wave64_emulate_opt_cfg.py passed 26/26 and tests/semantic/test_wave64_emulate_opt.py passed 31/31; git diff --check passed. The semantic module exercised generated shaders through the CPU interpreter. No GPU or game data used. At the latest hosted-check refresh, the PR checks were still queued. AI-assisted independent verification.
|
Tested e72218e on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass Runtime built at this head with
|
Claimed in the coordination issue as: SHADER-W64-FLOW-EXEC-FOLD (#14 (comment))
What and why
In
--wave64-emulate,find_local_exec_foldsfolds single-entry/single-exits_cbranch_execz/s_cbranch_execnzregions behindif (%active)only when_exec_writes_stay_inactivecan prove that everyEXECwrite inside the region keepsactive == Falsefor lanes that entered withEXEC == 0.Previously,
_exec_writes_stay_inactivewas flow-insensitive per 64-bit SGPR pair: if any instruction anywhere in the region wrote a non-zero-preserving mask intos[r:r+1](for instance, computing a negated inner branch mask withs_or_b64/s_xor_b64 s[r:r+1], ..., -1), the pair was permanently disqualified — even when the very next instruction overwrotes[r:r+1]with oldEXECvias_and_saveexec_b64 s[r:r+1], s[r:r+1]before restorings_mov_b64 exec, s[r:r+1]. On large wave64 compute shaders that reuse scratch SGPR pairs for nestedsaveexecguards, this falsely rejected thousands of outers_cbranch_execzfolds and forced wave votes +OpControlBarrierround cuts.This change replaces the flow-insensitive check (when CFG context
run,succ,active_blocksis supplied fromfind_local_exec_folds) with a sound forward must-be-zero dataflow over 64-bit SGPR pairss[0..126]andvcc:s_*_saveexec_b64,s_andn1/andn2_wrexec_b64,v_cmp_*,s_and/andn2/or/xor/mov/cselect/cmov_b64).(s_bits | (s_bits >> 1))on any partial 32-bit or non-zero-preserving SGPR write (including VOP3B carry-out masks) and killsvccon any partial/non-preserving write._exec_writes_stay_inactiveis called without CFG context.Aggregate impact measured on cached large wave64 compute shaders (counts only):
OpControlBarriercount drops from4,090 -> 595(-85.5%) and4,073 -> 578(-85.8%); across 6 large wave64 compute shaders, totalOpControlBarrierdrops from8,263 -> 1,273(-84.6%), and all translated SPIR-V modules passspirv-val --target-env vulkan1.2.Tested
python3 -I tests/test_wave64_emulate_opt_cfg.py: 33/33 passed (including 7 new positive and negative soundness tests inFlowSensitiveExecInactiveTest: reused scratchsaveexec,v_cmp+s_cselect_b64, unoverwrittens_xor -1, diamond merge with 1 non-zero branch, loop back-edge clobber, partial 32-bit overwrite of pair high half, VOP3B carry-out).LEONIDA_REQUIRE_SPIRV_TOOLS=1 python3 -I tests/semantic/test_wave64_emulate_opt.py: 32/32 passed (including newtest_flow_sensitive_reused_scratch_saveexec_folds_without_barrierson 64-thread and 128-thread workgroups: 1 superblock, 0 wave votes, bit-exact outputs, passesspirv-val).LEONIDA_REQUIRE_SPIRV_TOOLS=1 python3 -I scripts/run_semantic_tests.py tests/semantic: 465 files, 6109 tests, 0 failures.python3 -I tests/test_docs_links.py(16/16),python3 -I tests/test_text_write_line_endings.py(3/3),python3 -I scripts/check_no_game_data.py,python3 -m compileall -q make_game.py tools tests: all passed.vk_compute_test.exewith--wave64-emulateandspirv-valenabled): 30/30 wave64 compute fixtures (cs_w64*,cs_w64x_*,cs_wave64_ballot,cs_wm_*,cs_wqm_w64*,cs_dpp_w64) plus the nested scratch-saveexec shader passed with exact readback outputs.GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 616.92, Windows 11
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.