OLD-7450: restore old upstream PR 7450 - wave64 emulate: a cross-lane read of a missing lane in a partial wave gives 0 #833
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!833
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/833/head"
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?
@aslan2142 on GitHub · 2026-11-24 14:21 UTC · original
aslan2142:wave64-partial-wave-zero→main· +272 −12 · 8 files · 4 commits · merged 2026-11-25 22:19 UTCClaimed in the coordination issue as: OLD-7450 #14
Restoration of my original pull request, old upstream PR 7450 in
ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Ported onto main atd0da7dade; the translator change applied unchanged, and the port adds the subgroup-32 pin inscripts/run_gpu_tests.py(below) and the RX 7900 XTX measurements to the contract row.Depends on: #793 (line-level, docs/design.md), #364, #366, #373 (line-level, scripts/run_gpu_tests.py)
What and why
--wave64-emulate, a cross-lane read of another lane's exchange slot gives 0 when the source lane doesn't exist in a partial last wave. This coversds_swizzle_b32,ds_bpermute_b32,ds_permute_b32,v_readlane_b32,v_readfirstlane_b32, DPP and the other reads behindGen.x_round. A source lane that isn't running reads 0 on the hardware.Gen.x_lane_word:x_wbase + lane < threads, else 0. It is used by the five slot reads inx_round.masked_swizzle_amdwithfetch_inactive. In a 40-thread group, lanes 32-39 ofds_swizzle_b32 offset:swizzle(SWAP,8)then read the missing lanes' registers: garbage that changes between runs.cs_w64x_partial_swizzle(40 threads: SWAP 8, BROADCAST 16,15 andds_bpermute_b32from lanes 40-47). Its 8 words were measured natively on gfx1036 throughtools/hw_oracle.tests/semantic/test_w64x_partial_swizzle.pywith a hand-written fixture. It covers 40 and 104 threads, with the prologue's zero stores replaced by a poison word in the workgroup interpreter.scripts/run_gpu_tests.pynow runs the partial-wave fixtures emulated at subgroup 32, ascheck.py'spartial_wave_testalready does.check.pyshows it wrong.docs/design.mdcontract table: "Wave64 emulation: cross-lane reads of missing lanes", with how it was confirmed.Tested
Mesa 26.3.1 RADV on Linux. "Before" is main
d0da7dadewith only this PR's tests and runner change added.test_w64x_partial_swizzle.py: before 2 fail and 1 error; after 3/3 OK.run_semantic_tests.py): before 465 files and 6,108 tests, after 466 files and 6,111 tests; 0 files fail on either.cs_w64x_partial_swizzle, emulated at subgroup 32, 20 runs ofvk_compute_testper device:run_gpu_tests.py --filter cs_w64x_partial:cs_w64x_partial_swizzlefails);check.py, emulated:cs_w64x_partial_swizzlefails on both GPUs before and isokafter.run_gpu_tests.py, the same on both GPUs, native andLEONIDA_W64_EMULATE=1:cs_imgload_tfeandcs_imgload_d16_tfe. They fail on main too and this change doesn't touch them.crosslane_fuzz.py --wave 64 --ext --dpp --no-maskdata --programs 1000 --seed 48315 --modes emulate:--limit 2000slice, native and--wave64-emulate: 2000 translated and 2000 passspirv-val, before and after, with identical modules. That slice has no compute shaders.--wave64-emulate: 40 translated and 40 passspirv-val, before and after. 25 of the 40 modules change (the ones that read across lanes).python -m compileall -q tools tests scriptsis clean;git diff --checkis clean;check_no_game_data.pypasses on every changed file;tests/test_shader_checks.py,tests/test_partial_wave_subgroup.py,tests/test_run_gpu_*.pyandtests/test_text_write_line_endings.pypass.GPUs tested: AMD Radeon RX 7900 XTX (RDNA3, RADV, Mesa 26.3.1, Linux); AMD Radeon Graphics iGPU of the Ryzen 9 7950X3D (gfx1036, RDNA2, RADV, Mesa 26.3.1, Linux)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.AI-assisted (Claude Code, Claude Opus 5.5).
@abnalstlll-byte on GitHub · 2026-11-24 14:28 UTC · original · approved these changes
Clean-Room Peer Review for PR #833 (d3d12: support x_lane_word boundary checks for cross-lane exchanges on partial waves)
Brilliant driver-level workaround and ISA conformance fix:
LGTM! Highly valuable RDNA2 shader lowering fix. Approved.
@abnalstlll-byte on GitHub · 2026-11-24 14:41 UTC · original · approved these changes
Audited and verified. Restores upstream PR 7450: under --wave64-emulate, Gen.x_lane_word selects 0 when a source lane does not exist in a partial workgroup, preventing RADV's masked_swizzle_amd optimization from reading uninitialized inactive registers. Contract table updated in docs/design.md with hardware measurements on gfx1036. Clean-room compliant. Approved.
@Sangonapou on GitHub · 2026-11-24 16:03 UTC · original
Tested
5668f16bon NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32, mesh shaders), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300), native Windows: passBuilt at this head with
scripts\build_runtime.ps1(MSVC 19.51, VS Build Tools 2026, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0);llvm-mc23.1.6, SPIRV-Tools 2026.4. No game files.run_gpu_tests.py --filter cs_w64x_partial_swizzle: withLEONIDA_W64_EMULATE=1PASS (508 523 0 0 528 0 531 0); natively SKIP (no 64-wide compute subgroup on this device), as expected on a 32-wide GPU.@aslan2142 on GitHub · 2026-11-24 19:30 UTC · original
Thanks @Sangonapou for the 3080 Ti run:
cs_w64x_partial_swizzlepassing underLEONIDA_W64_EMULATE=1and skipping natively is what a 32-wide device should do.The red checks are
main's, not this PR's:windows:gta6rt.exelink errors__imp_WaitOnAddress,WakeByAddressAllandWakeByAddressSinglefromleonida_xma2_decoder.lib. Fixed onmainby #877; this PR doesn't touch the runtime build.linux-gpu-tools/macos:cs_imgload_tfeandcs_imgload_d16_tfeare issue #31, fixed onmainby #892.AI-assisted (Claude Code, Claude Opus 5.5).
@aslan2142 on GitHub · 2026-11-25 22:19 UTC · original
Merged: wave64 emulate: a cross-lane read of a missing lane in a partial wave gives 0.
mainmerged in (0bae6f545). One conflict inscripts/run_gpu_tests.py, wheremainaddedcs_w32_wrxchg2_extandcs_w32_wrxchg2st64to the same name list.main's list is kept, withcs_w64x_partial_swizzleadded to it.test_run_gpu_tests,test_run_gpu_tests_python_assembler, the docs tests andtest_ci_registration(Linux).maind3b8251bc+0bae6f545: the semantic suite passes (492 files, 6,315 tests, 0 files failed);test_run_gpu_tests,test_shader_checkspass; the 15 docs and writer tests pass;check_no_game_data.pyis clean on the 8 changed files.AI-assisted (Claude Code, Claude Opus 5.5).