Repository navigation
rdna2spirv: 64-bit buffer addresses without Int64, so shaders run without shaderInt64 (SHADER-423) - #850
rdna2spirv: 64-bit buffer addresses without Int64, so shaders run without shaderInt64 (SHADER-423)#850c4k3ss wants to merge 6 commits into
Conversation
lower_addr64 rewrites the assembled module's 64-bit address arithmetic (the zero-extend, shift-by-32, OR/AND, add and subtract with carry, narrowing, sign-extension, 64-bit bitcasts and pair compares the address idiom uses) into uint pairs and an OpBitcast of a 2x32 vector to the PhysicalStorageBuffer pointer, and drops OpCapability Int64 when nothing else needs it, so translated shaders run on devices without shaderInt64. --int64-addresses keeps the 64-bit form. Semantic tests for the lowering, the interpreters learn the pair pointer form, design.md row. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Audited and verified. Implements lowering of 64-bit buffer device address arithmetic into 32-bit uint pairs (OpIAddCarry, OpISubBorrow, etc.) and vector pointer bitcasting, dropping the Int64 / shaderInt64 Vulkan capability requirement for devices lacking 64-bit integer support. Preserves 64-bit path under --int64-addresses. Comprehensive semantic test suite in ests/semantic/test_addr_no_int64.py and contract docs updated in docs/design.md. Approved.
|
Tested 4f2628f on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass, regression check Runtime built at this head with
This GPU has |
|
Intel Arc readback at
12/12 passed, 0 failed, 0 skipped. Each dispatch compared all 256 readback words with the CPU expectation, including 224 untouched words. All 12 binaries also passed Reproduce the signed-offset caseUse the PR’s v_lshlrev_b32 v1, 2, v0
v_add_nc_u32 v2, 512, v1
v_mov_b32 v3, 0
global_load_dword v4, v[2:3], off offset:-4
s_waitcnt vmcnt(0)
buffer_store_dword v4, v1, s[0:3], 0 offen
s_waitcnt vmcnt(0)Initialize 256 little-endian uint32s with spirv-as --target-env vulkan1.2 case.spvasm -o case.spv
spirv-val --target-env vulkan1.2 case.spv
spirv-dis case.spv
$env:VKC_OUT_WORDS = "256"
$env:VKC_SUBGROUP_SIZE = "32"
$env:VKC_HEAP_INIT = "heap.bin"
$env:VKC_DUMP = "out.bin"
.\vk_compute_test.exe case.spv 1 dumpRead AI-assisted with OpenAI Codex. All buffers and shaders were synthetic. |
# Conflicts: # docs/design.md
After the merge of main, Gen.host_addr sign-extends every 48-bit effective VA with a shift left and an arithmetic shift right by 16 (a 32-bit shift amount). lower_addr64 knew only shifts by 32, so every address kept Int64 and the lowering did nothing. A shift by 1..31 of a (low, high) pair now becomes the two words' shifts with the bits that cross between them; the amount may be a 32-bit or a 64-bit constant. test_addr64_lowering gains a negative 48-bit VA case (bit 47 set, read below the heap base), compared with the Int64 form in spirv_mini_interp. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Rebased by merging Main's Tested on
AI-assisted (Claude Code); a second tool reviewed the shift formulas for every amount 1..32 against integer arithmetic and validated 192 lowered synthetic modules with spirv-val. |
# Conflicts: # docs/design.md
…and variable left shift After the second merge of main (RT-POST-LOAD-GPU-MEMORY, 9f98dcc), the buffer address idiom also holds the full index * stride product in 64 bits, a left shift by the element-size log read from the V# (a 32-bit value, not a constant), and a 64-bit compare against 0xFFFFFFFF for the range check. The pass refused every such module and kept Int64. A 64-bit multiply becomes the low words' product, its high word from the four 16-bit half products (plain 32-bit multiplies, which the three test interpreters run), plus each low word times the other's high word. A left shift by a 32-bit value becomes the shift by k & 31 on both words with the crossing bits, the words moved up once k >= 32. The contract row and the code comment say so. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Merged Main's Tested on
AI-assisted (Claude Code); a second tool checked the multiply and shift lowering against integer arithmetic (20,121 products, 13,504 shifts). |
# Conflicts: # tools/rdna2spirv.py
Claimed in the coordination issue as: SHADER-423 (#14 (comment)), carried over from the upstream repository, where it was open with ten independent GPU test reports when the repository went private.
What and why
Translated shaders declared
OpCapability Int64only because of buffer addresses: the translator builds each PhysicalStorageBuffer address as a 64-bit integer (zero-extend, shift by 32, OR, add an offset, convert to pointer). A device withoutshaderInt64(Intel) refuses every such module, although the shader's own arithmetic is 32-bit.lower_addr64(tools/rdna2spirv.py, run inassemble()on the finished module text) rewrites that address arithmetic into pairs of 32-bit words: adds and subtracts throughOpIAddCarry/OpISubBorrow, the shift-by-32 / OR / AND / narrowing / sign-extension / 64-bit bitcast forms the address idiom uses, pair compares, andOpConvertUToPtrof a 64-bit value asOpBitcastof a two-componentuintvector to the pointer. A value is either lowered completely or left alone; when nothing 64-bit remains, theInt64capability is dropped. Shaders that use 64-bit integers as data keep it.--int64-addresseskeeps the previous form.Also in this PR:
tests/semantic/test_addr64_lowering.py(7 tests, including negative offsets throughglobal_load), the two test interpreters learn the pair pointer form, six existing tests accept either address form, and thedocs/design.mdcontract row "64-bit addresses withoutInt64".Tested
On
maind0da7dade, Windows 11 26200, llvm-mc 23.1.6, Vulkan SDK 1.4.363, MSVC 14.44:test_addr64_lowering7,test_buffer_atomic_fminmax_and_align10,test_buffer_store_format39,test_loop_ballot_barrier15,test_wave64_emulate_opt31, all OK.pytest tests/test_translate.py tests/test_rdna2spirv_xdxr_rules.py: 675 passed.scripts/run_gpu_tests.py, test programs built from this head: 258 of 258 shaders translate and passspirv-val; 198/249 passed, 49 skipped, 2 failed. The two failures,cs_imgload_tfeandcs_imgload_d16_tfe, fail identically with thismain's own translator on the same programs (--filter cs_imgload: 2/4 both ways, same texel values), so they are not from this change.mainwithout conflicts) was run by ten independent testers with no regression against theirmain: NVIDIA RTX 2060, 4080, 5080, 5090; AMD RX 5700 XT (RDNA1), RX 6800 and a Steam Deck (RDNA2), RX 9070 XT (RDNA4), gfx1036 iGPUs on the Windows driver; Windows, Linux/RADV.GPUs tested: NVIDIA RTX 5070 Ti, driver 621.24, Windows 11
AI-assisted: yes (Claude Code); built and tested on the machine above.
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.