Repository navigation
Conversation
Add runtime-detected AVX2 conversion (8 samples per iteration with a 256-bit SIMD zero-lane accumulator) for Opus PCM16 -> f32 output in acphal::decode_into, keeping the scalar fallback for non-AVX2 CPUs and tail samples. Measured on Intel Core i9-9900K (--release, 200k iterations): - N=480: 227.2 ns -> 45.0 ns (5.05x) - N=960: 366.6 ns -> 71.8 ns (5.11x) - N=1920: 717.3 ns -> 148.2 ns (4.84x) - N=5760: 2139.8 ns -> 444.6 ns (4.81x) Part of xcl-dev#459. Assisted-by: Antigravity (Gemini 4 Neon)
|
Independent Ryzen 7 9800X3D check on I also timed XCL’s Synthetic audio only. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch benchmark and drafted this report. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
Vectorizes the Opus
i16 -> f32sample conversion and non-zero sample counter inacphal::decode_intousing runtime-detected AVX2 (#459item 3a), keeping the scalar implementation as fallback for non-AVX2 CPUs and tail elements.Part of #459. (Disjoint from open
acphal.rsPRs #463, #468, #471, and #939.)What is in it
crates/xcl/src/hle/acphal.rs:convert_i16_to_f32_scalar,convert_i16_to_f32_avx2(#[target_feature(enable = "avx2")]), and runtime-dispatchedconvert_i16_to_f32(OnceLock<bool>viais_x86_feature_detected!("avx2")).i16samples per iteration (_mm256_cvtepi16_epi32->_mm256_cvtepi32_ps->_mm256_mul_ps(1.0 / 32768.0)) and count zero lanes directly in a 256-bit SIMD accumulator (_mm256_sub_epi32on_mm256_cmpeq_epi32), avoiding per-iterationmovemask/popcntdependencies. Because32768.0 = 2^15is an exact power of two, multiplying by1.0 / 32768.0is bit-identical to dividing by32768.0across all 65,536i16values.convert_i16_to_f32_avx2_matches_scalar_bit_for_bitunit test verifying exhaustive bit-exactf32and non-zero count parity acrossi16::MIN..=i16::MAX, tail lengths0..=17, and shorter destination slices.Measured on Intel Core i9-9900K (
--release, 200,000 iterations per buffer length):N)Regression run
Baseline (
main):This PR (
perf/acphal-avx2-i16-to-f32):Tested
Hardware: Windows 11 Pro for Workstations (Build 26300), Intel Core i9-9900K (AVX2), 32 GB RAM, AMD Radeon RX 6800 (16337 MiB VRAM, Driver
32.0.21045.29003),rustc 1.100.0 (0ef1bc386 2026-11-09).cargo test -p xcl --lib hle::acphal:::8 passed; 0 failed; 0 ignored; 0 skipped.XCL_REQUIRE_GPU=wave64,mesh cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4:739 passed; 3 failed; 41 ignored; 0 skipped. All 3 failures are the pre-existing RDNA2placed_title_textures_share_vram_and_preserve_pixels+ 2VRAM_TEST_LOCKPoisonErrorcascades on unmodifiedmain(tracked in D3D12.X: map a one-slice title texture's packed mips where D3D12 addresses them #470)..\scripts\smoke.ps1 -Game '<game folder>\YouKnowWho'onae27c9e101166065a2e72279123a4c240608d00b(see Regression run above).Not tested
convert_i16_to_f32_avx2_matches_scalar_bit_for_bit).acphalaudio decode traffic (microbenchmarked in--releaseon i9-9900K;YouKnowWhosmoke verified no regression).AI use
Antigravity (Gemini 4 Neon) implemented the runtime-detected AVX2 conversion and bit-exact unit test in
crates/xcl/src/hle/acphal.rs, ran the release benchmark, full test suite, and smoke run.