Repository navigation
D3D12-GPU-CHANGED-RECORDS-AVX2: add AVX2 fast path for 32-byte descriptor changed_records - #2689
Conversation
|
Independent Windows 10 AVX2 check on
CPU microbenchmarks and synthetic data only. AI-assisted. |
…s (D3D12-GPU-CHANGED-RECORDS-AVX2) changed_records() scans ~400,000 32-byte descriptor slots per frame (mirroring ~40,000, d3d12/docs/findings.md). Previously, any dirty 512-byte chunk ran memcmp on the 16-record block and then ran 16 individual memcmp + memcpy calls. Add a runtime-detected AVX2 fast path for step == 32 that loads four 32-byte records (128 bytes) into ymm registers, checks all four with a single combined vpcmpeqb + vpand + vpmovmskb branch, and on mismatch stores the already-loaded new ymm vectors directly with _mm256_storeu_si256 (avoiding the double-scan and memcpy calls). Measured in --release on Ryzen 7 7800X3D (400k x 32-byte slots, 50 rounds, bit-exact parity verified): - 0% dirty: 325.9 -> 309.8 us/frame (1.05x) - 10% dirty: 432.5 -> 325.9 us/frame (1.33x) - 100% dirty: 611.3 -> 485.1 us/frame (1.26x) AI-assisted: Antigravity (Gemini 4 Neon)
ebaa9ec to
08a1cc4
Compare
|
Independent check on Windows (not the author), at
The same failure appeared for #2701 (which does not touch descriptors) under the same concurrent-load condition, so it looks like a load-sensitive write-watch test rather than this PR's AVX2 path. I reported that separately as a suite finding. Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, Rust 1.98.1 pinned. AI-assisted: yes (opencode). |
Bit-exact CPU composition with the shadow AVX2 paths in #2699MEASURED. I tested #2689 The standalone fixture extracts All 30 runs produced the same 6,955,200 output bytes. That is three runs per platform for Scope: synthetic CPU function composition and output parity. AI-assisted: Codex (GPT-6.2 Sol). |
|
RUN - VERIFY-2689-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). |
Claimed in #2570 as
D3D12-GPU-CHANGED-RECORDS-AVX2(#issuecomment-7267296583).What and why
In
d3d12/crates/leonida-gpu/src/descriptor/host.rs,changed_records()scans ~400,000 console descriptor slots (32 bytes each) and mirrors ~40,000 changed slots per frame (d3d12/docs/findings.md). Previously, whenever any 1 of 16 records in a 512-byte chunk differed,changed_records()ranmemcmpon the 512-byte chunk and then re-scanned all 16 records with 16 individualmemcmp+memcpycalls.This change adds a runtime-detected AVX2 fast path (
std::arch::is_x86_feature_detected!("avx2")) forstep == 32:ymmregisters.vpcmpeqbresults withvpandinto a singlevpmovmskb == -1fast-path branch.newymmregister directly with_mm256_storeu_si256(zero second load, zeromemcmp/memcpycalls).changed_records_scalar()on non-AVX2 CPUs or non-32-byte record strides.Verification & Measured
--releaseA/B BenchmarkHardware / OS: native Windows 11 Pro (
10.0.26200), AMD Ryzen 7 7800X3D, AMD Radeon RX 7900 XTX (gfx1100), pinned toolchainrustc 1.98.1.cargo test --release -p leonida-gpu --lib changed_records_bench -- --ignored --nocapture(400,000 × 32 B slots, 50 rounds, bit-exact parity asserted every round):325.9 µs → 309.8 µs/frame(1.05×)432.5 µs → 325.9 µs/frame(1.33×)611.3 µs → 485.1 µs/frame(1.26×)cargo test -p leonida-gpu --lib descriptor::host -- --test-threads=4—53 passed; 0 failed; 2 ignored(0.48s).python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/descriptor/host.rs— PASS.AI-assisted: Antigravity (Gemini 4 Neon)