Repository navigation
GPU tests: what marking written title pages costs, per way of marking (benchmark for #2167, #2175, #2465, #2755) - #2804
0xkn0wh3r3 wants to merge 4 commits into
Conversation
A benchmark (ignored by default) and a check, in HLSL that does what translated programs do when they store to title memory: look the address up in the page table (an upload heap), set the bits of the pages written in the list's bitmap with atomics, store into the host copy. Variants: main's two unconditional atomics per store; a load first and an atomic only for a clear bit (Marvisak#2167's approach); one atomic per wave for lanes sharing a bitmap word (Marvisak#2755's); both; none. Each with the bitmap in system memory, as now, and in video memory; four ways of writing. RTX 5070 Ti, driver 621.24, ms per dispatch of 131,072 threads storing 16 dwords each (bitmap clear before the dispatch / already set): one page linear page/lane scattered main, system bitmap 79.8/76.5 75.8/75.0 1595/1583 336/337 test-first, system 1.6/0.33 11.5/0.35 21/20 13.0/6.7 wave, system 1.7/0.33 11.4/0.36 22/22 13.5/6.8 main, video bitmap 0.31/0.31 0.32/0.32 20/20 6.4/6.5 test-first, video 0.30/0.30 0.32/0.32 20/21 6.8/6.7 no marks 0.30/0.29 0.32/0.32 20/19 6.5/6.5 Atomics on a bitmap in system memory are what cost: up to 250 times the dispatch without marks. Loading first removes them once a page is marked; one atomic per wave adds nothing on this GPU. A bitmap in video memory costs nothing even with main's unconditional atomics, first marks included. What is left in "page per lane" and "scattered" is the stores into the host copy in system memory. `every_variant_marks_the_pages_main_marks` checks every variant, in both places, sets exactly main's bits. `dxc.exe` comes from the Windows SDK; without it or a GPU both tests do nothing. cargo test -p victory-gpu --release --lib marks_bench -- --ignored --nocapture
Two 256.5 KiB copies, the bitmap into read-back memory and zeros over it, as the video-memory bitmaps of Marvisak#2175 and Marvisak#2465 record at a list's end or after a submission: 12.2 µs on an RTX 5070 Ti (median of 20).
kotekompotek
left a comment
There was a problem hiding this comment.
Good benchmark design — five marking strategies x system/video bitmap placement x four write patterns, GPU timestamps on a private queue, and it answers exactly the question #2167/#2175/#2465 need for the wave-reduction work. The correctness gate is the important part and it's done right: every variant must set the identical bitmap as main for every pattern and placement (a wave-reduction that drops or double-counts a bit fails), plus the main marks nothing sanity check. #[ignore]d + dxc/GPU-gated. LGTM.
|
Reviewed and benchmarked Review & correctness
RTX 5090
|
| variant | bitmap | one page |
linear |
page per lane |
scattered |
|---|---|---|---|---|---|
main |
system |
70.129 / 69.926 | 71.398 / 68.767 | 1421.602 / 1411.691 | 296.981 / 298.548 |
main |
video |
0.175 / 0.166 | 0.159 / 0.159 | 74.801 / 74.930 | 4.692 / 4.943 |
test-first |
system |
1.520 / 0.235 | 16.534 / 0.232 | 76.975 / 77.243 | 11.575 / 5.003 |
test-first |
video |
0.166 / 0.169 | 0.159 / 0.160 | 75.115 / 75.307 | 4.684 / 4.699 |
wave |
system |
1.506 / 0.234 | 16.491 / 0.231 | 76.726 / 76.175 | 11.177 / 5.003 |
wave |
video |
0.166 / 0.175 | 0.159 / 0.159 | 75.846 / 75.360 | 4.948 / 6.206 |
wave+test-first |
system |
1.263 / 0.240 | 16.284 / 0.232 | 77.303 / 78.210 | 11.477 / 4.891 |
wave+test-first |
video |
0.171 / 0.166 | 0.159 / 0.159 | 76.147 / 76.490 | 4.787 / 4.696 |
none |
system |
0.169 / 0.172 | 0.159 / 0.160 | 75.937 / 75.488 | 4.628 / 5.066 |
Even on RTX 5090, putting the bitmap in video memory matches the none floor even with main's unconditional atomics (401×–449× on one page/linear, 19× on page per lane, 60×–63× on scattered) for 6.5 µs of copy-out/clear overhead.
|
Automated triage for the maintainers. This adds a test-only, Update for Generated by Claude Code |
Review: the benchmark spawned the SDK's dxc.exe. It now loads the SDK's dxcompiler.dll and compiles through IDxcCompiler3 in the test process (D3DCompile has no shader model 6, which the wave variant needs), signed by the SDK's dxil.dll where there is one. Without the SDK the tests still do nothing. The benchmark also times each case as four submissions of a quarter of the groups, summed: main's slowest case takes about 1.6 s for all of them, near the host's 2 s device reset, and a busy GPU pushed it over.
|
Understood. On compiling in-process: the shaders target |
|
Update to my reply above: at 02912f9 the benchmark no longer spawns anything. It compiles its SM 6.6 shaders in-process through the SDK's |
|
From a tester working with Claude (AI-assisted, Claude Code): the same comparison in the title on an AMD card under Linux, for the two kernels that cost the most GPU time in our world runs. Setup: RX 9070 XT (RDNA4), RADV / Mesa 26.3.1 through vkd3d-proton (GE-Proton 11-14), resizable BAR on. Diagnostics builds of one base ( The two kernels are GPU ms per dispatch (stable across arms, unlike per-frame totals, which follow the scene):
So on this card, for these two kernels, moving the bitmap to video memory changes nothing, and merging a wave's marks takes about a quarter off one of them. That doesn't match the 5070 Ti numbers above, where the system-memory bitmap is the whole cost. My guess, not measured yet: here the cost is their stores and atomics into the host copies of title buffers, which are in system memory too. I'm running #2870's chain next (same binary, No game data: hashes, counts and timings only. |
|
NVIDIA numbers for this bench: RTX 3060 12 GB, driver 610.88, Windows 11 26200, dxc 10.0.26100.0, on
On this GPU, system-memory atomics on the bitmap cost about 1000x the video-memory ones ( AI use: Claude Code ran the benchmarks on this machine and drafted this comment. |
…s, per way of marking (benchmark for Marvisak#2167, Marvisak#2175, Marvisak#2465, Marvisak#2755)
Five open PRs change how translated programs mark the title-memory pages they write:
This PR measures each approach on hardware, so they can be compared. It is tests only: nothing outside tests changes.
What it adds
crates/victory-gpu/src/marks_bench.rshas HLSL compute shaders that do what translated stores to title memory do:crate::memory;There is one shader for each way of marking:
maintest-first(#2167's approach)wave(#2755's approach)wave+test-firstnoneEach runs with the bitmap in system memory (the custom L0 write-back heap of
Host::shared_buffer, as on main) and in video memory. Each runs over four ways of writing: all in one page, linear, a page per lane (32 pages per bitmap word), and scattered.Times are GPU timestamps around one dispatch on a queue of the benchmark's own: 2,048 groups of 64 threads, 16 dword stores each. Each figure is the median of five runs, once with the bitmap cleared before each run ("first touch") and once with it already set.
Results (RTX 5070 Ti, driver 621.24), ms per dispatch, first touch / already set
main, system bitmaptest-first, systemwave, systemwave+test-first, systemmain, video bitmaptest-first, videononeWhat the results show:
A second benchmark times what a video-memory bitmap adds at a list's end: copying 256.5 KiB into read-back memory, then clearing it from zeros. That takes 12.2 µs per list (median of 20).
Recommendation: a video-memory bitmap (#2175 for page-table marks, #2465 for view marks) gives the full gain on its own. #2167's check-the-bit-first still helps wherever the bitmap stays in system memory, for example when the card has no room, but adds nothing on top of video memory.
Tests
every_variant_marks_the_pages_main_marks: every variant, with the bitmap in either place, sets exactly the bitsmainsets, over every pattern. Those bits are what copy-back copies.#[ignore]d:dxcompiler.dll(found under the Windows Kitsbinfolder) throughIDxcCompiler3; no process is spawned.D3DCompilecan't be used because the wave variant needs shader model 6. Without the SDK, or without a GPU, the tests do nothing.cargo clippy -p victory-gpu --all-targets -- -D warningsis clean, with and without--features diagnostics.cargo test -p victory-gpu --libfails onlydynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views. These fail the same way on main on NVIDIA (the 1,000,000-descriptor cap, fixed by GPU: page view heaps a host caps below the slots shaders index #2121).Limits
A version of #2175's approach rebased on current main, with the bitmaps pooled, is on branch
0xkn0wh3r3:gpu/marks-in-video-memory(dd65e98) for anyone who wants to try it while #2175 conflicts.