Repository navigation
Keep opus's runtime dispatch on x86_64 instead of presuming AVX2 - #7
Merged
Merged
Conversation
The linux-x86_64 and windows-x86_64-msvc archives were built with OPUS_X86_PRESUME_AVX2 and -march=x86-64-v3, which compiled the CPUID dispatch out and spread AVX2 and FMA through 172 functions that are not kernels. A binary linking them died on the first vfmadd on an Ivy Bridge i5-3210M. Both targets now build with opus's own default: the SSE4.1 and AVX2 kernels compiled per file and selected by opus_select_arch() at run time, so a Coffee Lake keeps its AVX2 NSQ and pitch kernels and anything without AVX2 runs the SSE4.1 ones. Measured on an i5-8500T, 60 s of 48 kHz stereo at complexity 5: 0.65% of a core with the floor, 0.73% without, identical output bytes. That is the whole price, and the consuming project chose it over a second archive. The floor verification gains a dispatch arm: MAY_HAVE on and PRESUME off in the cmake cache, opus_select_arch present in the archive, and no AVX2 or FMA instruction in any function not named *_avx2 — the property a global -march would break. The symbol check counts rather than grep -q, because under pipefail -q closing the pipe on its first match kills nm. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Ly7cjta1J2gLEHdiyHX9S
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The x86_64 archives presumed AVX2 (dispatch compiled out,
-march=x86-64-v3), so a binary linking them SIGILLs on any CPU without AVX2. They now use opus's upstream default: SSE4.1 and AVX2 kernels compiled per file and selected by CPUID at run time. Measured cost on an i5-8500T: 0.73% of a core against 0.65% for 48 kHz stereo encode.build.shverifies the dispatch build: MAY_HAVE on, PRESUME off,opus_select_archpresent, and no AVX2/FMA instruction outside a*_avx2kernel.🤖 Generated with Claude Code
https://claude.ai/code/session_012Ly7cjta1J2gLEHdiyHX9S