Repository navigation
perf(shader): probe 32-bit BDA stores and share the write fallback - #1282
Swastik-51 wants to merge 5 commits into
Conversation
6850c39 to
e63cc30
Compare
|
On Linux this does not keep #1265's gain. Intel Iris Xe, Mesa 25.2.8 ANV, applied to 2cc5735, cold caches:
The cause is the Measurements and Mesa source links: #1256 (comment) |
|
Then please add numbers for this commit alone on top of #1280: GEN instruction count and compile memory for |
e63cc30 to
fe567b5
Compare
|
Updated commit
|
|
It is the new This PR has no CI checks yet, which is probably why it hasn't shown up. The rest of the suite is unchanged on a Radeon 860M (AMD numbers for the three PRs are in #1256). Tested with AI assistance (Claude Code). |
|
Could you please run the Github CI please as i need maintainer approval to run it |
|
I can't approve workflow runs here; GitHub only lets maintainers do that for first-time contributors. You don't need CI for this one, though: the test doesn't touch the GPU, so it reproduces on any build with |
fe567b5 to
515df44
Compare
|
Fixed the The test was counting the two function-local loop counter
I unfortunately can't run the full Could someone with the Intel/Mesa setup rerun the |
|
Ran it on
Cold AMD timings, measured as in #1256 (fresh executable name per run so the AMD driver cache misses,
The KiB column is the size of the AMD driver's pipeline cache file for the run. I can't produce the Intel GEN instruction count from here; that still needs someone with an Intel GPU. Measured with AI assistance (Claude Code). |
|
Thanks! Great to see agc_shader_memory passing and the full suite results confirming the two failures are pre-existing on main. |
|
Intel numbers for 515df44, the commit alone on top of #1280, as requested above. Intel Iris Xe (Alder Lake GT2), Mesa 25.2.8 ANV, Linux. Each variant was merged onto this PR's base, c5e1018, because the head currently conflicts with main in
Other store-heavy tests. Both fail on this device for the subgroup reason fixed by #1185, which is not in this base; the compile numbers still apply:
Tests at the same base:
So with |
Every 8- and 16-bit BDA store and the unaligned path of every 32-bit store emitted one get_bda_write_pointer lookup and one note_bda_write per byte at the store site, five write lookups per 32-bit store. They now call write_bda_bytes, which loops over the bytes and does, per byte and in order, the same lookup, the store when it is mapped and the write note, so faults are recorded exactly as before. On an RTX 3060 the agc_driver_flat_store binaries shrink from 496,256 to 138,240 bytes (wave32) and from 928,384 to 225,152 bytes (wave64), and the cold run from 19.7 s to 2.2 s.
note_bda_write unrolled its 8 compare-exchange probes, and drivers inline it at every BDA store and atomic. The probes now run in a loop that tries the same slots in the same order and stops at the same slot, so the recorded pages and the overflow flag are unchanged. With the byte store helper, the agc_driver_flat_store binaries on an RTX 3060 go from 138,240 to 75,648 bytes (wave32) and from 225,152 to 130,560 bytes (wave64), and the cold run from 2.2 s to 1.2 s.
… path The declaration, the state field and the definition of write_bda_bytes now sit next to EmitBdaStore and the other BDA write functions instead of next to the dword read functions, which boykopovar#1267 extends at the same lines. No change to the emitted code.
note_bda_write ran a device-scope compare-exchange on every probe, also when the slot already held the page. The table lives in host-visible memory, so each BDA store paid an atomic across PCIe, and nearly every store hits a page an earlier store noted. Load the slot first and only compare-exchange when it does not hold the page. The slots probed, the pages recorded and the overflow report are unchanged. DOOM (PPSA99666) presents through a compute kernel that stores about two million pixels through raw pointers per frame: 248 ms per dispatch before, 8.1 ms after, on an RTX 5070 Ti. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32-bit BDA stores previously emitted both an aligned 4-byte store and four unaligned byte stores at every store site, each with a lookup and a page-write probe sequence. With note_bda_write inlined by drivers, programs like agc_driver_flat_store ballooned into dozens of lookups, hundreds of atomic CAS probes, and over 134K GEN instructions on Intel. Probe the 4-byte span once with Write permission, storing directly when mapped and aligned. The unaligned and faulting fallback routes to the looping byte store helper (write_bda_bytes).
515df44 to
90d6d56
Compare
|
Closing this PR for now because the branch has accumulated significant merge conflicts with the current The implementation and measurements are still useful, and the latest results look good after the requested changes. Rather than resolving the conflicts on top of the current dependency stack, I'll preserve the work and rebase/cherry-pick the relevant changes onto the latest Thanks everyone for the reviews, testing, and especially the Intel/Mesa measurements. |
Depends on #1280 (which builds on #1265). Until they merge, this branch includes their commits; the last commit adds the 32-bit probe and fallback sharing.
32-bit BDA stores previously emitted both an aligned 4-byte store and four unaligned byte stores at every store site, each with a lookup and a page-write probe sequence. With note_bda_write inlined by drivers, programs like agc_driver_flat_store ballooned into dozens of lookups, hundreds of atomic CAS probes, and over 134K GEN instructions on Intel.
Probe the 4-byte span once with Write permission, storing directly when mapped and aligned. The unaligned and faulting fallback is shared across write sites via write_bda_dword_bytes, marked DontInline. note_bda_write is also marked DontInline.
Closes #1256 .
What
probe_bda_write_pointer(recordFaults = false,BdaAbi::Write) to probe the 4-byte span once. When mapped and 4-aligned,EmitBdaStoreemits a single 4-byte store directly and notes the write.write_bda_dword_bytes(with a coherent variant) marked withspv::FunctionControlDontInlineMaskto handle unaligned accesses, cross-range accesses, and faults without duplicating per-byte lookups at every store site.note_bda_write: Changedspv::FunctionControlMaskNonetospv::FunctionControlDontInlineMaskinDefineBdaNoteWriteso drivers do not inline its atomic CAS probes into dozens of call sites.verifyBdaWriteFallbackFunctionstoShaderMemory.cppto verify thatnote_bda_writeandwrite_bda_dword_byteshaveDontInlineMask,mainhas 0 inlineget_bda_write_pointercalls, coherence is preserved, and SPIR-V code size delta per site is kept small.Tested
python tools/check_conventions.py --base origin/mainpassed with 0 errors.verifyBdaWriteFallbackFunctionsinShaderMemory.cpp.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)