Repository navigation
D3D12-GPU-SHADOW-AVX2-MERGE-AND-RUNS: AVX2 fast paths for shadow merge, back_piece, and changed_runs - #2699
Conversation
|
Independent Windows A/B of One benchmark detail: the checked-in scalar arm calls
Main and PR returned identical spans, changed runs, merged data, and staging bytes in every comparison. Synthetic CPU measurements only. No frame-time estimate from this test. AI-assisted. |
|
Updated |
|
Independent Wine check of the AVX2 update The same 64 KiB
The equal page was about 0.22 µs slower against the actual base implementation, which skips equal 512-byte blocks. The ignored benchmark’s 8-byte loop measures a different baseline. Spread-out and dense writes improved substantially. These are synthetic tests and CPU timings. AI-assisted with OpenAI Codex. |
…anged_runs AI-assisted: Antigravity (Gemini 4 Neon)
AI-assisted: Antigravity (Gemini 4 Neon)
01cb26b to
45d09e2
Compare
|
Independent check on Windows (not the author), at
The diff is Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, NVIDIA RTX 4070 Ti SUPER (driver 621.01), Rust 1.98.1 pinned. AI-assisted: yes (opencode). |
|
Independent game-run A/B test on Windows 10 + NVIDIA RTX 5070 12 GB (driver 621.40) + Ryzen 9 5950X with Verdict: Per-bucket summary (
AI-assisted: Antigravity. |
|
RUN - VERIFY-2699-RTX4060 - by MoonEyes (another person than the author) on head
Limits: one card, one run per arm, two arms only, the seven together. Values only, no game data. AI-assisted (Claude Code). |
|
Merging. Head AI-assisted (Claude Code). |
Problem
Under
LEONIDA_RELAY=1andLEONIDA_LAND=1, per-frame read-back landing (land.rs->Shadow::card_merge_relay->merge_piece,changed_runs, andback_pieceind3d12/crates/leonida-gpu/src/shadow.rs) spent ~5.7 ms of CPU time across worker threads per frame scanning and merging up to 64 KiB piece stretches byte-by-byte, cloningwas(title.clone()) per piece incard_merge_relay, and building an intermediatemaskbuffer inback_piecebefore doing a second byte-by-byte pass to buildruns.Fix
In
d3d12/crates/leonida-gpu/src/shadow.rs(disjoint from#2566and open#2570claims):merge_piece_avx2(+merge_piece_scalartail): compares 32 bytes at a time, skips unchanged blocks wherenow == heldwith zero stores toheldortitle, blends changed bytes via_mm256_blendv_epi8, and updatestitleonly whenmerged != title.changed_runs_avx2(+changed_runs_scalartail): compares 64 bytes per iteration with_mm256_cmpeq_epi8and extracts diff runs directly viapush_diff_mask().back_piece_avx2(+back_piece_scalartail): eliminatesmaskallocation and its second pass by extracting diff runs straight from the AVX2 compare mask throughpush_diff_mask().MERGE_WASscratch buffer insidecard_merge_relayinstead of heap-allocatingtitle.clone()on every piece (and skip copying when!mapped).Verification
10.0.26200), Ryzen 7 7800X3D, pinnedrustc 1.98.1.cargo test -p leonida-gpu --lib shadow::: 59 passed, 0 failed, 2 ignored (includes newavx2_merge_back_and_runs_match_scalar_across_lengths_and_patterns).cargo test --release -p leonida-gpu --lib shadow_avx2_bench -- --ignored --nocapture(64 KiB sparse 4 B writes every 272 B; apples-to-applesback_piecewrapper matchingmain):merge_piece: 16.46 us -> 3.08 us (5.35x)changed_runs: 8.34 us -> 1.59 us (5.24x)back_piece: 33.56 us -> 4.80 us (6.99x)cargo test --release -p leonida-gpu --lib runs_of_equal_pages -- --ignored --nocapture:3.4 us by eights, 0.8 us now.python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/shadow.rs: PASS.Claimed in #2570 as
D3D12-GPU-SHADOW-AVX2-MERGE-AND-RUNS.AI-assisted: Antigravity (Gemini 4 Neon)