XAudio2: vectorize XMA2 ImdctPlan::imdct_half with runtime AVX2+FMA #1030
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1030
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1030"
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?
@AlpPesen on GitHub · 2026-11-24 10:34 UTC · original
AlpPesen:perf/xma2-avx2-imdct→main· +229 −24 · 1 files · 1 commits · openPart of #459 (item 2: XMA IMDCT / FFT).
Splits
ImdctPlan's twiddle tables into SoA stage-contiguous arrays and adds a runtime-detected (is_x86_feature_detected!("avx2")&&fma) AVX2+FMA implementation ofImdctPlan::imdct_half, keeping the scalar implementation as fallback (for non-AVX2/FMA CPUs and sizes< 32).Overlap note: touches only
ImdctPlan(crates/xcl/src/hle/xma2/mod.rs:455-660) and adds one unit test — disjoint from #525 (quantizer gains), #526 (PCM output), #884 (bit reservoir), and #861 (extradata tests).What is in it
crates/xcl/src/hle/xma2/mod.rs:exp_r/exp_iand stage-contiguousstage_tw_r/stage_tw_iinImdctPlan::new.ImdctPlan::imdct_half_avx2(#[target_feature(enable = "avx2,fma")]): 8-wide pre-rotation, fused multiply-freehalf = 1, 2radix-4 pass, 4-wide VEX FMAhalf = 4pass, 8-wide aligned AVX2+FMAhalf = 8..len2/2passes, and 16-sample post-rotation/interleave.avx2_imdct_matches_scalar_for_all_xma_sizes: verifies AVX2+FMA matches scalar (max_err < 1e-5) across all XMA sizes (N = 64, 128, 256, 512) and multiple seeds.Measured speedup (
--release, Intel Core i9-9900K, 200,000 iterations per size)N)ns/call)ns/call)Tested
26300), Intel Core i9-9900K, AMD Radeon RX 6800 (16337 MiB VRAM, driver32.0.21045.29003),rustc 1.100.0(x86_64-pc-windows-msvc), DXC1.9.2602.17(debugfor tests,releasefor benchmark & smoke runs).cargo test -p xcl --lib hle::xma2::: 8 passed, 0 failed (includingdecodes_xma2_and_xma1_bitstreams_matching_ffmpeg,fast_imdct_matches_naive_reference_for_all_xma_sizes, andavx2_imdct_matches_scalar_for_all_xma_sizes).XCL_REQUIRE_GPU=wave64,mesh+cargo test --workspace --no-fail-fast -- --test-threads=4oncdf2078: 725 passed, 3 failed, 41 ignored, 0 GPU skipped (xcllib: 683 passed / 3 failed / 21 ignored; integration/e2e: 42 passed / 0 failed / 20 ignored;XCL_SAMPLE_*unset).placed_title_textures_share_vram_and_preserve_pixels(3D 64x64x64 4 mips: subresource 2 mismatch, fixed by open PR #470) plus its 2VRAM_TEST_LOCKPoisonErrorcascades.Regression run
Both runs below used the same warmed shader/PSO cache on
YouKnowWho(60 s):main(09940bb87fa1):PR head (
cdf2078e9bbc):Not tested
YouKnowWhouses Opus, so its smoke run above is a regression check only; XMA2 decoding itself is verified against the FFmpeg reference test vectors indecodes_xma2_and_xma1_bitstreams_matching_ffmpeg).XCL_SAMPLE_*unset).avx2_imdct_matches_scalar_for_all_xma_sizes).AI use
@DavidM1911 on GitHub · 2026-11-24 11:16 UTC · original
Independent verification, merged onto current
main384f7f7locally (clean merge).Machine: Windows 11, i7-13700K (AVX2 + FMA present, so the vectorized path is the one exercised), RTX 3060 Ti + Radeon iGPU; Rust stable MSVC, debug.
cargo test -p xcl --lib xma2: 10 passed, 0 failed — includesavx2_imdct_matches_scalar_for_all_xma_sizes(AVX2 vs scalar across all XMA sizes) andfast_imdct_matches_naive_reference_for_all_xma_sizes.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
@JJAutoCompare on GitHub · 2026-11-25 05:31 UTC · original
Empirical test report (
cdf2078e)Verified PR #1030 at
cdf2078e9bbccc5fd40caa7da167bd5be0c4cad5in a clean, detached checkout.Hardware / environment
avx2=true fma=true, so the test's CPU feature guard allowed the SIMD comparison to run.rustc 1.100.0 (0ef1bc386 2026-11-09)and DXC1.9.2609.5 (01b62ad47).XCL_ADAPTER=NONE_CPU_ONLYandRUST_TEST_NOCAPTURE=1. Both commands ran outsideInvoke-ArcTest.ps1with zero Arc GPU mutex hold.Commands and results
cargo test --workspace --no-runcompleted with exit code 0 and built the workspace test executables.cargo test -p xcl --lib 'hle::xma2::tests::' -- --nocaptureexited 0. The captured log reported 8 passed, 0 failed, 0 ignored, 0SKIPPEDlines, and 699 filtered out. The harness reported 0.03 s.Observed behavior
avx2_imdct_matches_scalar_for_all_xma_sizespassed. It compared all output samples for four deterministic inputs at each of 64, 128, 256, and 512 samples. Every case met the test's maximum absolute error threshold of1e-5.fast_imdct_matches_naive_reference_for_all_xma_sizespassed through runtime dispatch at the same four sizes. The six other CPU-only XMA tests passed, including the XMA1/XMA2 decoder fixture comparisons against FFmpeg reference output.Not tested
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr1030-focused.logand published.@thehollowedone on GitHub · 2026-11-25 09:25 UTC · original
Independent Windows suite and Zen 5 IMDCT timings on cdf2078. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11.
The clean
cargo build --workspace --offline --locked -j 4passed.cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4finished with 728 passed, 0 failed, 41 ignored. Cargo’s pass count includes two native-wave64 runtime skips.A scratch release fixture timed the parent kernel, the PR scalar fallback, and the PR runtime dispatcher in the same binary. Each median covers six warmed samples of 300,000 calls with alternating order, four rotating synthetic inputs, and preallocated plans and buffers.
The dispatcher was 2.36–4.69× faster than the parent on this AVX2/FMA CPU. The PR scalar fallback had higher medians at all four sizes. Dispatcher output matched direct AVX2/FMA bit for bit. Maximum absolute error versus either scalar path was about 3e-8.
cargo test --release --offline --locked -j 4 -p xcl --lib xma2:: -- --nocapture --test-threads=1passed all nine tests including the benchmark and stock decoder tests against FFmpeg references. Retail playback throughput and CPUs without AVX2/FMA were outside this run.AI use: Codex (GPT-6, exact variant unspecified) prepared the benchmark, ran the tests and drafted this report.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.