victory-simd: shared AVX2 kernels for changed_runs and the DSP convolution, bit-exact, runtime-switched #4471
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4471
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/4470/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@kewb on GitHub · 2026-11-30 20:45 UTC · original
kewb:avx2-acceleration→main· +1344 −29 · 20 files · 2 commits · closed without mergingWhat it does
Adds
crates/victory-simd: SIMD kernels shared across crates, each next to the scalar code it must match. Which kernel set runs is chosen once at run time from CPUID and environment switches.victory-gpushadow::changed_runs: the byte scans (common prefix, then differing prefix) compare 32 bytes per step with AVX2. The runs come out byte for byte the same as the old loop, which stays as the scalar version.victory-hledsp::convolve: the multiply-accumulate, the FFT stages with at least 8 butterflies per group (twiddles laid out per stage at start-up) and the output scaling use AVX. The output is bit-exact to the scalar code, including NaN, infinities and subnormals, because each lane does the same operations in the same order. FMA is opt-in and off by default.docs/simd.md):VICTORY_SIMD=auto|baseline|avx2:baselineruns every kernel of this crate on its scalar version.VICTORY_SIMD_MEMORY=0andVICTORY_SIMD_AUDIO=0turn off one area each.VICTORY_SIMD_FMA=1turns on fused multiply-add in the convolution.VICTORY_SIMD_VERIFY=1runs the scalar version beside each vector kernel and warns at the first difference.SIMD kernelsline listing the CPU's extensions and the choices made.The existing hand-written AVX2 (safecopy, torn, shadow word runs, indirect) is left alone. What was left out on purpose, and why, is in
docs/simd.md.Also in this PR: CI's clippy steps are green again
Both
cargo clippygates fail onmain(e1251c31). This PR fixes them:Shadow::rangedand copystat'smbhad no callers.Fft::runis now test-only.is_multiple_of.unwrap_or_default, with the same behaviour.Lowered::loop_capsis test-only plumbing that no test reads yet, so it gets anallowwith a reason.Relation to #4434
Both PRs change
convolve.rs, so they will conflict. #4434 changes the algorithm (real-input transforms, about half the work) and makes the low bits of the output differ. This PR keeps the algorithm and the output bits, adds runtime switches and a verify mode, and also coverschanged_runs. The two ideas can be combined: the real-input packing could run on these kernels.How it was tested
--all-targets, with and without--all-features,-D warnings).cargo test -p victory-simdcovers the dispatch rules and compares every kernel with its scalar version. That means every length up to a few vectors, unaligned starts, a difference at every position, and special float values.cargo test -p victory-hle --lib convolvechecks both FFT directions and a convolution over several blocks, bit for bit, on both kernel sets.cargo test -p victory-gpu --lib changed_runschecks that the runs are the same.#[ignore = "benchmark"]), not run for this PR:cargo test --release -p victory-hle --lib block_time -- --ignored --nocapturecargo test --release -p victory-simd --test memory scan_rate -- --ignored --nocapturecargo test --workspace --no-fail-fastfails in files this PR does not change:victory-shader/src/native.rs)thin::bindings_record_no_workshader_cache::every_switch_of_the_translator_is_in_the_keyVICTORY_SIMD_VERIFY=1on a CPU with AVX2/FMA/BMI2.0x887A0006) while nothing of ours was running on the card. It is not yet known whether that is related. The next check is a run withVICTORY_SIMD=baseline.🤖 Generated with Claude Code
Pull request closed