mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:00:52 +01:00
[PR #224] rdna2spirv: 64-bit scalar data ops lower to 2x32-bit, no Int64 (SHADER-930) #276
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#276
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/224
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:old-pr/9958📝 Commits (1)
135d44brdna2spirv: 64-bit scalar data ops lower to 2x32-bit, no Int64 (SHADER-930)📊 Changes
11 files changed (+566 additions, -39 deletions)
View changed files
📝
docs/design.md(+1 -1)📝
runtime/test/shaders/check.py(+4 -1)➕
runtime/test/shaders/cs_w32_salu64_bfe.asm(+84 -0)➕
runtime/test/shaders/cs_w32_salu64_bits.asm(+64 -0)📝
scripts/run_gpu_tests.py(+5 -2)➕
tests/semantic/fixtures/disasm/cs_w32_salu64_bfe.s(+64 -0)➕
tests/semantic/fixtures/disasm/cs_w32_salu64_bits.s(+49 -0)➕
tests/semantic/test_salu64_2x32.py(+227 -0)📝
tests/semantic/test_salu_bfe_64.py(+8 -5)📝
tools/int_hw_probe.py(+25 -0)📝
tools/rdna2spirv.py(+35 -30)📄 Description
Original description (mentions and
#Nreferences are disabled; the numbers refer to the old repository):Item: SHADER-930 (up for grabs in the coordination issue; the earlier claim by
abnalstlll-byteon#5156had no code)What and why
SHADER-930 asks for a pure 2x32-bit lowering, with no
Int64capability, of the 64-bit scalar data opss_brev_b64,s_bfe_u64,s_bfe_i64,s_bitset0_b64,s_bitset1_b64,s_flbit_i32_b64ands_flbit_i32_i64, plus a hardware measurement.I checked each op on main first. Five of the seven were already pure 2x32-bit.
s_bfe_u64/s_bfe_i64were not: they joined the pair into anOpTypeInt 64value, did 64-bit shifts and setuses_psb. That putOpCapability Int64and the PSB declarations into every module that used them, including a pixel shader that touches no memory.s_brev_b64OpBitReverseon each dword, swapped)s_bfe_u64OpTypeInt 64,OpShiftLeft/RightLogical %ulong, setsuses_psb, soInt64+ PSBOpBitFieldUExtracton each dword, count min(w,32) / w-min(w,32)s_bfe_i64OpShiftRightArithmetic %longOpBitFieldSExtracton each dword; the high dword takes the low dword's sign when w <= 32s_bitset0_b64S0 & 63, selected into one dword)s_bitset1_b64s_flbit_i32_b64FindUMsbper dword)s_flbit_i32_i64~S0when negative, then as b64)The semantics stay as before (RDNA2 ISA SOP1/SOP2, and the
docs/design.mdrow): offset = S1[5:0], width = S1[22:16], a field past bit 63 stops there (width = min(width, 64 - offset)),s_bfe_i64sign-extends from the top bit it keeps, and SCC = D != 0. The other six ops don't write SCC. In the new lowering no shift amount reaches 32, including on the discarded side of anOpSelect, because SPIR-V leaves that undefined.Changes
tools/rdna2spirv.py: a news_bfe_u64/s_bfe_i64lowering. It no longer setsuses_psb.tests/semantic/test_salu64_2x32.py(new):OpCapability Int64orOpTypeInt 64, with SGPR-pair or constant sources.s_bfe_u64/s_bfe_i64value and SCC over offsets {0, 1, 31, 32, 33, 63} × widths {0, 1, 31, 32, 33, 63, 64, 65, 127} × 2 sources, with SCC preset to the opposite value.spirv_mini_interp, and their header,check.pyandrun_gpu_tests.pyexpect the same words.tests/semantic/test_salu_bfe_64.py: the two emission tests checked for%ulong/%longanduses_psb. They now check for the 32-bit ops and for no 64-bit type.runtime/test/shaders/cs_w32_salu64_bfe.asm,cs_w32_salu64_bits.asm(new hand-written GPU fixtures; derivations in their headers) and their translator inputs intests/semantic/fixtures/disasm/(fromregen_fixtures.py). Both are wired intoruntime/test/shaders/check.pyandscripts/run_gpu_tests.py.tools/int_hw_probe.py: 11 moresalu_64_datacases with the same edges, ready for a native run.docs/design.md: the contract row for the 64-bit scalar data ops now covers the 2x32 lowering and how it was confirmed.Tested
Linux, AMD Radeon RX 6800 XT and NVIDIA GeForce RTX 3070 in the same machine:
python -I scripts/run_gpu_tests.py --llvm-mc /usr/lib/llvm-21/bin/llvm-mc --filter cs_w32_salu64(cs_w32_salu64,cs_w32_salu64_bfe,cs_w32_salu64_bits): 3 translated, 3 pass spirv-val, 3/3 PASS on each of:cs_w32_salu64_bfewith out[7] = 0x5CC0000E, the word its header predicts. Swapping the w <= 32 sign select fails 76 checks intest_salu64_2x32.py. Both were reverted.python -m unittest discover -s tests/semantic -p test_salu64_2x32.py: 8 tests OK.test_salu*64*.py: all OK.python -I scripts/run_semantic_tests.py tests/semantic: 460 files, 6054 tests in 77 s on 16 jobs. Two files fail:test_exec_computed(2 failures) andtest_image_atomics_guard(47 failures). Both fail the same way on unmodifiedupstream/main(e56d9795), so this PR does not cause them. (Separately,python -I tests/test_shader_checks.pyhas 15 errors on main from a test harness stub that doesn't takecwd=; also not from this PR.)python -I tools/int_hw_probe.py --group salu_64_data(translator side): 21/21 match.--self-test: OK.python -I tests/test_int_hw_probe.py: OK.python -I tests/semantic/regen_fixtures.py --check: clean.python -m compileall -q make_game.py tools tests: clean.python -I scripts/check_no_game_data.pyon every new file: clean.The 64-bit SALU instructions have not been run natively in this PR; the GPU runs above run the translated SPIR-V. They were already measured natively on gfx1100 and gfx1035 (see the design.md row).
tools/hw_oracleworks on this machine (llvm-21 clang with amdgcn, ld.lld, libdrm_amdgpu 2.4.134, gcc), but the RX 6800 XT drives the desktop displays, and the DRM launcher refuses such a GPU unlessLEONIDA_HW_DRM_ALLOW_DISPLAY=1is set, because a hung kernel resets the GPU. To measure natively on gfx1030 with the new edge cases:The item names gfx1036. gfx1030 has the same RDNA2 ISA.
Checklist
.asm.docs/design.md, with how it was confirmed.AI-assisted (Claude Code).
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.