Repository navigation
wave64: align emulate barrier detection for s_flbit, mixed s_cmp_*_u64, and ds_nop - #4596
kotekompotek wants to merge 1 commit into
Conversation
Kam471
left a comment
There was a problem hiding this comment.
Ran this at ae5fefb8 on Windows 11, RTX 5070 Ti.
tests/semantic/test_wave64_emulate_barriers.py-> 13 tests, OK;tests/semantic/test_wave64_emulate_opt.py-> 22 tests, OK;git diff --checkclean.- GPU emulated regression:
LEONIDA_W64_EMULATE=1 run_gpu_tests.py --filter cs_w64xwith this translator -> 19/19 passed (cs_w64x_sbarrier,cs_w64x_mask_reuse(2),cs_w64x_wg128_branches,cs_w64x_partial_scmp, ...).
The three changes are consistent with the translator: s_flbit_i32(_b32) joins the s_bcnt/s_ff cross-lane mask readers in both _classify_block_body and _insn_may_barrier; s_cmp_eq/lg_u64 now rejects any operand whose register window contains a lane-mask word (_has_any_lane_mask_word), which the scalar pair compare otherwise reads as plain data; and ds_nop is skipped in Gen.x_memory_order like the other non-LDS ds_ ops, so it no longer forces an ordering split. The docs note that this is CPU-interpreter checked only. No blocking issue.
|
Replying to @kotekompotek. Checked the Vulkan 1.2 validation gap at All 21 modules validated, including the folded and multi-wave cases for the flbit lane-mask reads, mixed u64 comparisons, and LDS operations around ds_nop. All 13 original tests also passed. This was a CPU-side validation run. AI-assisted (Codex). AI-assisted. |
|
Tested
llvm-mc 20.1.2 on all. No game files. Tested and written by Claude (Claude Code), posting from @theswiss24's account. |
|
Verified PR #4596 on Windows 11 (25H2
Changes align AI-assisted (Gemini, Antigravity). |
Flyander
left a comment
There was a problem hiding this comment.
The barrier prediction now tracks both s_flbit lane-mask reads and mixed u64 comparisons with mask words, matching the translator paths; ds_nop is consistently treated as a no-op for x_memory_order. The synthetic semantic reports cover the previously crashing folded regions, and I found no blocking issue.
|
Tested head
AI-assisted (Devin). |
ae5fefb to
e38cb58
Compare
|
Tested This PR changes no C++, so the test programs were built from
Synthetic inputs only, no game data. AI-assisted. |
|
Tested e38cb58 merged onto main 3faac55 on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:
AI-assisted (Claude Code). |
|
Verified merged with current main: both changed semantic suites pass in isolated and plain discovery (test_wave64_emulate_barriers 13, test_wave64_emulate_opt 22), the docs guards are green, and the five ballot-barrier emulate failures reproduce identically on fresh main — not yours. One checklist gap: the contract table row is updated for the changed translator behaviour but no standalone semantic .asm fixture accompanies it — please add one so the new rule is pinned in the standard form alongside the inline cases (which are substantive). Not stacked on #2956 or #4152 despite shared files. No CI checks reported. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
e38cb58 to
0718bfd
Compare
|
SHADER-876 full cached-corpus result at e38cb58 against 3faac55: all 26,503 indexed shaders translated and passed Vulkan 1.2 spirv-val on both revisions under identical --wave64-emulate settings. SHA-256 matched for every emitted module across 208 batches. CPU only, SPIRV-Tools v2026.4. This establishes byte-for-byte parity for the indexed corpus; GPU execution was outside this comparison. |
|
Game-copy check of
All 26,503 already translated at the base, so the three AI-assisted (Claude Code). |
|
Tested 0718bfd (trial-merged onto main 561b65a) on NVIDIA GeForce RTX 5090 (610.88, subgroup 32..32) and AMD Radeon iGPU (RDNA2, AMD 32.0.21036.18, subgroup 32..64), Windows 11 Pro 26200: pass.
No game files. AI-assisted. |
|
Tested The merge was a fast-forward:
No game files. AI-assisted (Claude Code). |
ace237b to
ffa6ab9
Compare
…64, and ds_nop Fixes three --wave64-emulate AssertionError crashes and sync mismatches: - tools/wave64_emulate_opt.py (_classify_block_body, _insn_may_barrier): recognize s_flbit_i32_b32 and s_flbit_i32 on lane masks, and s_cmp_eq_u64/s_cmp_lg_u64 on mixed mask+data SGPR pairs via _has_any_lane_mask_word(). - tools/rdna2spirv.py (Gen.x_memory_order): treat ds_nop as a no-op matching NOOPS and wave64_emulate_opt._x_memory_order_access(). - tests/semantic/test_wave64_emulate_opt.py: add FindSMsb to run_emulated_workgroup OpExtInst handler. - tests/semantic/test_wave64_emulate_barriers.py: add unit and 64/128-thread workgroup interpreter regression tests. - docs/design.md: document the wave64-emulate barrier alignment rules and CPU verification scope. Verified locally (CPU only, no GPU/spirv-val/llvm-mc): - python -I tests/semantic/test_wave64_emulate_barriers.py -> 13/13 OK - python -I tests/semantic/test_wave64_emulate_opt.py -> 22/22 OK - pytest -q (12 test files) -> 70 passed # Conflicts: # docs/design.md # Conflicts: # docs/design.md # tools/wave64_emulate_opt.py # Conflicts: # tools/wave64_emulate_opt.py
ffa6ab9 to
80417b9
Compare
|
Second check on a Steam Deck OLED, AMD Custom GPU 0932 (RADV VANGOGH, subgroup 32..64), Mesa 26.2.6, Vulkan 1.4.354, Linux, head 80417b9.
|
Claimed in the coordination issue as: #4571 (comment)
What and why
Fixes three
--wave64-emulatebarrier-prediction /x_memory_ordermismatches betweentools/wave64_emulate_opt.pyandtools/rdna2spirv.pythat crashrdna2spirv.translate()withAssertionErrorinside foldeds_cbranch_execzregions (x_split inside a folded lane-local region) and multi-wavesync_freeguards (unexpected OpControlBarrier in sync-free multi-wave block). This is separate from #4479 (lane_eithermixed mask+constant pairs) and does not change_holds_lane_maskorlane_either:s_flbit_i32_b32ands_flbit_i32on lane masks (tools/wave64_emulate_opt.py):rdna2spirv.pycallslane_mask_word()->wave_mask()->x_round()whenholds_lane_mask(a[1])is true, but_classify_block_body()and_insn_may_barrier()omitted both opcodes. Added both to the lane-mask scan checks (plain scalar data operands still fold and staysync_free).s_cmp_eq_u64/s_cmp_lg_u64on mixed mask+data SGPR pairs (tools/wave64_emulate_opt.py):rdna2spirv.py:7473-7483materializes each individual register of a 2-register SGPR operand withwave_mask()->x_round()whenevercur_masks.get(r) is not None, even if the other half holds arbitrary runtime scalar data (notEITHER). Added_has_any_lane_mask_word()and checked it fors_cmp_eq_u64/s_cmp_lg_u64in_classify_block_body()and_insn_may_barrier()(plain-data pairs still fold and staysync_free).ds_nopinGen.x_memory_order()(tools/rdna2spirv.py):Gen.insn()callsx_memory_order()before_insn()returns early onNOOPS, andx_memory_order()did not skip"ds_nop"(unlikeNOOPSandwave64_emulate_opt._x_memory_order_access()). As a result,ds_nopwas treated as an LDS read+write, emitting a spuriousx_order_barrier()and crashing folded/sync-free blocks that combineds_read_*/ds_write_*withds_nop. Added"ds_nop"toGen.x_memory_order()'s early return.FindSMsbsupport torun_emulated_workgroup()intests/semantic/test_wave64_emulate_opt.py, addedtests/semantic/test_wave64_emulate_barriers.py(unit + 64/128-thread workgroup interpreter regression tests), and documented the rules indocs/design.md.Tested
CPU-only (Windows 10 x64, Python 3.12.6, synthetic assembly fixtures only; no GPU, no
spirv-val, nollvm-mc, and no game corpus run on this machine — binary SPIR-V assembly checked viatools/spirv_asm.pyintest_wave64_emulate_barriers.py):origin/main(03b09a08/d0835dd9): all 8 minimal wave64 reproducers (s_flbit_i32_b32,s_flbit_i32, mixed mask+datas_cmp_eq_u64/s_cmp_lg_u64, andds_read_b32 + ds_nop, each in a 64-threads_cbranch_execzfold candidate and a 128-threads_cbranch_scc0guard) crashedrdna2spirv.translate()withAssertionError.python -I tests/semantic/test_wave64_emulate_barriers.py->13/13 OK(64-thread & 128-thread strict uniform-barrier workgroup interpreter, forward & reverse invocation order, plusspirv_asm.assemble(..., target_env="vulkan1.2")).python -I tests/semantic/test_wave64_emulate_opt.py->22/22 OK.python -m pytest -q tests/semantic/test_wave64_emulate_barriers.py tests/semantic/test_wave64_emulate_opt.py tests/semantic/test_w64x_scalar_load_order.py tests/semantic/test_wave64_subgroup_ops.py tests/test_docs_repo_paths.py tests/test_docs_design_rows.py tests/test_docs_links.py tests/test_docs_table_rows.py tests/test_design_contract_rows.py tests/test_resource_hygiene.py tests/test_text_write_line_endings.py tests/test_semantic_translator_use.py->70 passed.python -m py_compileandgit diff --checkclean; LF line endings verified.AI-assisted (developed and verified with an AI coding assistant).
Checklist
docs/design.md, with how it was confirmed.