Repository navigation
fix(shader): leave the BDA lookup functions through one return - #7571
Conversation
The lookups returned from each failed check. On NVIDIA 595.99 a subgroup whose invocations left `get_bda_pointer` or `probe_bda_pointer` through three different returns (one past a range's end, one below the first range and one that found its range) never finished (Xid 109), which is how boykopovar#5859's anchor tests hang `agc_driver_bda_device`. Each check now branches to the end of a single-pass loop, where a phi takes the result, and the function returns once. The lookups stay DontInline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rent checks A 64-lane program that doesn't stop invocations reads one dword per lane at 0xfff00 + low over a table whose first range is [0x100000, 0x100010): one lane below the first range, one past its end, one at its last dword and the others at its start. The unmapped lanes must read zero with the unmapped fault recorded, the others their dword, and every read kind must match the anchored program. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
@milescoviello Windows/another NVIDIA-driver datapoint for your exact head
These are composition-scoped results, not an unchanged-main suite or a title fix. The private BDA fixture selected NVIDIA; no AMD coverage is attributed to an environment-variable request. AI-assisted independent validation: yes (Codex). |
|
Thanks @Amoenus, that narrows it. With your RTX 5080 on driver 610.62, the original lookup runs the new case without hanging, so it isn't every NVIDIA driver. Here it's an RTX 4070 Ti (Ada) on Linux with 595.99.02, where AI-assisted: yes (Claude Code) |
|
Independent Linux Ampere and RADV comparison for exact head Ubuntu 24.04, kernel
The exact fixed head also passed once per device before the original-lookup control. Only This extends the affected NVIDIA hardware beyond Ada on the reported driver version. The observed original-lookup failure here is device loss (-4), not the reported timeout (2); I did not reproduce the exact Xid 109 signature (the accessible kernel journal query returned no matching entries). I ran the original NVIDIA control once, then restored the fix and observed the three passes above; this is not a failure-frequency measurement or proof of the driver compiler's internal cause. No title or full-suite result, and no Khronos validation-layer coverage. I did not count lavapipe as read/anchor coverage because this fixture skips |
|
Thanks @simonbbby. So it isn't specific to Ada. I added your result to the description. AI-assisted: yes (Claude Code) |
|
@milescoviello on "it follows the 595.99 driver rather than the GPU generation": on this Linux Ampere host the hang is still there on 615.78.08. That's a higher version than the 610.62 that passed for @Amoenus on Windows, so the version number alone doesn't explain his pass. His run also differs in GPU generation (RTX 5080, Blackwell), OS and tree (his integration), and this run doesn't separate those. CachyOS, kernel 7.2.9-2-cachyos, GCC 16.2.1, Release build. RTX 3080 Ti (Ampere), NVIDIA driver 615.78.08. Only the NVIDIA ICD was in
Each failing run logged one kernel line, Compared with @simonbbby's RTX 3090 run, this adds a newer driver, a plain Not checked: any title, validation layers, other driver versions on this card. lavapipe isn't counted, since the fixture skips BDA execution on CPU devices. AI-assisted: yes |
|
Thanks @Dextroid17, that corrects my comment above: a newer driver on Linux hangs too, so it doesn't follow 595.99. I've changed that comment and the description. The pass on 610.62 now differs in OS (Windows), GPU generation (Blackwell) and tree, as you say. AI-assisted: yes (Claude Code) |
|
Apple GPU / MoltenVK datapoint for head 8e7d887. Here the SPIR-V goes through SPIRV-Cross to MSL and the Metal compiler, so this is a different lookup codegen from the NVIDIA, Intel and AMD runs above. Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Method: main 81cb863 + @mugurc's
GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704) Written with AI assistance (Claude Code). I ran the builds and tests above on my machine. |
|
Thanks @jotitadev, that's a useful datapoint because it goes through a different compiler. I added it to the description. AI-assisted: yes (Claude Code) |
|
Register pressure on Intel, since #5814 was closed over spills on Gen9 and this PR also restructures the BDA lookup. Intel Arrow Lake iGPU (Gen12.7, Core Ultra 7 265K), Mesa 26.1.6 ANV, Debian 13, kernel 6.12. Compiled code.
So on this GPU, ANV reduces both forms of the lookup to the same machine code. Run time of the whole test binary, 3 runs each:
Limits: this is Gen12.7, not the Gen9 HD 520 where #5814 regressed, and the backend differs between them, so it doesn't replace that run. I also haven't checked which of the 107 variants contain the lookup. AI-assisted: yes (Claude Code) |
|
Windows on Ada with a newer driver, the combination the thread was missing: RTX 4070 (
So on Windows the failure isn't specific to the 596.21 driver from the report: an Ada card on 616.92, newer than the 610.62 that passed on the RTX 5080, fails on AI-assisted: yes (Claude Code). The builds, the runs and this comment were done and written by Claude Code on my machine. |
|
Same on NVIDIA 617.42 (updated driver, same machine and trees): AI-assisted: yes (Claude Code). |
|
Thanks @m335671, that's the run the thread needed. An Ada card failing on 616.92 and 617.42, with the AI-assisted: yes (Claude Code) |
|
Windows data from a GPU where
Two of the AI-assisted: yes (Claude Code) |
|
Thanks @MaxLikesCode. A second Ada card (RTX 4090, 617.42) failing on AI-assisted: yes (Claude Code) |
|
Windows NVIDIA run where Windows 11 (10.0.26200), NVIDIA GeForce RTX 4050 Laptop GPU, driver 617.42, WinLibs GCC 15.2.0 r7, Release,
Before this, I bisected the failure on this machine to the #5859 merge: Not checked: Linux, AMD, the Intel iGPU (disabled on this laptop right now), or a title. AI-assisted |
|
For the record, the matrix cell I can't find above: Windows + Ampere. GeForce RTX 3070 (GA104, driver 32.0.16.1088), Windows 11 (22635.5305), Ryzen 5 5600X, WinLibs GCC 15.2.0 r7, Release.
So the generation effect holds on Windows too: Ampere fails on Details in #7584: #7584 (comment) AI-assisted: yes. |
|
@elliot1377 @Rajkamalcode thank you both. The RTX 4050 Laptop and RTX 3070 runs fill the two cells the thread was missing: an Ada laptop part that loses the device rather than timing out, and Ampere on Windows. Both fail on AI-assisted: yes (Claude Code) |
…ee, async lane off) The tree is local/merge19 020d736: combo19, batched staging, the overlap staging fixes and the adopt20 fixes, merged with upstream main b509767 (+ boykopovar#7571), with the committer fixes and the async-lane diagnostics. Same-session pair with the lane off on both: 4.99 vs 4.19 presents per 10 s, trace p50 2,070 vs 2,372 ms. T1 t1-yb-m19 MATCH. SourceVersion 3b35146912b7970c. AI-assisted: yes
…ee, async lane off) The tree is local/merge19 020d736: combo19, batched staging, the overlap staging fixes and the adopt20 fixes, merged with upstream main b509767 (+ boykopovar#7571), with the committer fixes and the async-lane diagnostics. Same-session pair with the lane off on both: 4.99 vs 4.19 presents per 10 s, trace p50 2,070 vs 2,372 ms. T1 t1-yb-m19 MATCH. SourceVersion 3b35146912b7970c. AI-assisted: yes
What
agc_driver_bda_devicehangs the GPU on NVIDIA since #5859. Onmaina62c724 it fails 3 of 3 withvkWaitForFences graphics: Vulkan result 2(the 5 s fence timeout), and the kernel logsNVRM: Xid 109 ... CTX SWITCH TIMEOUTfor it. 385ed71, just before #5859, passes.mainpasses on an Intel Arrow Lake iGPU (Mesa 26.1 ANV). The dispatch that hangs is in #5859's newRunBdaAnchorTests, but in the plain program, which reads throughget_bda_pointerandprobe_bda_pointer, lookup code #5859 didn't change.I reduced it with a temporary hook in the test (not part of this PR). It takes a program that doesn't stop invocations at a fault, as
BdaInvocationsMayStopdecides for programs with barriers, reading one dword per lane in 64 lanes. That program hangs when invocations in one subgroup leave the lookup through three different returns:index == 0, unmapped);Any two of the three don't hang, and neither do 8-bit reads or the program that stops invocations. It doesn't need the address overflows #5859's test inputs produce either. With a table whose first range is [0x100000, 0x100010) and lanes at 0xfff01, 0x100010 and 0x100000, it hangs the same way. Without
DontInlineon the lookups it doesn't hang. Without it on the dword read functions or on the fault recorder, it still hangs.The change. The lookups returned from each failed check (
ReturnBdaZeroIf,ReturnBdaFailureIf). Now their body sits in a single-pass loop. Each failed check records its fault (inget_bda_pointer) and branches to the loop's merge block. A phi there takes the result, and the function's oneOpReturnValuereturns it. The early checks are all outside the binary-search loop, so each exit is a break of the new loop. The lookups stayDontInline: 5693c77 measured minutes of NVIDIA compile time per shader when they are inlined.ReturnBdaFailureIfno longer has a caller. I left it inSpirvBdaFault.cppbecause #6416, #6751 and #7392 add code right after it, so removing it can wait for a follow-up.Test.
RunBdaAnchorTestsnow ends with that subgroup in the 64-lane program that doesn't stop invocations, over the table above. The program reads one dword at 0xfff00 plus one lane's offset, with lanes below the first range, past its end, at its last dword and at its start. The unmapped lanes must read zero with the unmapped fault recorded, the others their dword, and every read kind must match the anchored program.Tested
Ubuntu 24.04 (Linux 6.8), GCC 13.3, NVIDIA RTX 4070 Ti (595.99.02); Intel Arrow Lake iGPU (Mesa 26.1 ANV).
agc_driver_bda_device:maina62c724 fails 3 of 3 on NVIDIA. With this PR (head 8e7d887, including the new case) it passes 3 of 3 on NVIDIA and 3 of 3 on the Intel iGPU.INTEL_DEBUG=csand Mesa's shader cache off,agc_driver_bda_device's 107 compiled variants are identical onmainfd58ca3 and with this PR. The statistics match (211,249 instructions, 0:0 spills:fills in every variant), and so does the full assembly (0 of 1,041,924 lines differ). Run times are unchanged: 1614-1660 ms against 1623-1646 ms with a warm Mesa cache, 20.8-20.9 s against 21.1-21.4 s with it off. Gen9 (HD 520) isn't covered (details).main's lookup with the new case also passes 3 of 3 there, so that driver doesn't hang. @simonbbby saw the same with 595.99.02 on an RTX 3090 (Ampere) (comment):main's lookup with the new case lost the device, while this head passes 3 of 3, and RADV (gfx1036, Mesa 25.2.8) passes both. @Dextroid17 saw it with Linux 615.78.08 on an RTX 3080 Ti (Ampere) (comment):mainfails 3 of 3, each with an Xid 109, and this head passes 3 of 3. @jotitadev ran it on an Apple M2 Max through MoltenVK 1.4.2 and through MoltenVKmainwith SPIRV-Cross Ratchet & Clank: Rift Apart: SIGSEGV since #861, an address-less 64 GiB reservation now takes the addresses the title hints next #2704 (comment). This head andmain's lookup with the new case both pass 3 of 3, and the^agc|^shadersuite has the same 46 failures with and without this PR, none of them a BDA test. So the hang is seen with Linux drivers 595.99.02 (Ada, Ampere) and 615.78.08 (Ampere), and not with 610.62 on Windows on a Blackwell card, which differs in OS, GPU generation and tree.ctest -R "^agc_|^shader_ir": 711/711 pass on NVIDIA. With the hook, every reduced case completes with the fix: the overflow and no-overflow repros, 1 and 4 dwords, plain and anchored.agc_shader_replay --spv(Release,ANYPS5_ENABLE_SPIRV_TOOLSoff,ANYPS5_NO_SHADER_CACHE=1) over the 466 shader requests I had dumped, from PPSA30839 (MXGP 26), PPSA31162 (Super Meat Boy 3D) and one other app:main's.spirv-val --target-env vulkan1.2reports the sameCullPrimitiveEXTerror for them before and after this PR.DontInline.Title level: no claim. I don't know a title that hits this. It needs a program with a barrier in which one subgroup reads mapped, below-table and past-end guest addresses at once.
tools/check_conventions.py --base upstream/mainpasses.tools/pr_overlap.pylists two pull requests that conflict withmain, so it couldn't compare them. #6947 also editsDefineBdaLookup, and #6373 editstests/BdaExecution.cpp. I'll rebase onto whichever lands first.main84c1a4d fails 3 of 3 (-4). With this PR it passes 3 of 3, and withmain'sSpirvBdaLookup.cppit fails 3 of 3 again. So it isn't specific to the 596.21 driver: Ada fails on newer drivers too, while the RTX 5080 (Blackwell) passed.mainad502d7 fails 5 of 5 (Vulkan result 2, then-4), and with this PR it passes 3 of 3. Two of themainruns came after the PR runs, so it doesn't depend on cache state.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code