bench: spectral-analysis perf spike (window asm ladder + pipeline profile)#82
Open
tfcollins wants to merge 15 commits into
Open
bench: spectral-analysis perf spike (window asm ladder + pipeline profile)#82tfcollins wants to merge 15 commits into
tfcollins wants to merge 15 commits into
Conversation
Adds bh_window_t4 which precomputes the Blackman-Harris window once on the calling thread then dispatches the asm apply kernel across NTHREADS=6 worker threads. Two partition strategies are used: row-partitioning when navg >= 6, and sample-range partitioning otherwise. Also fixes a subtle TLS capture bug: thread_local statics are not captured by [&] in lambdas (each thread resolves them via its own TLS slot), so sw.data() is snapshotted into a plain pointer before threads are spawned.
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.
Summary
Exploratory, self-contained performance spike under
bench/(nosrc/changes) investigating how fast genalyzer's spectral-analysis math can go, down to hand-tuned AVX-256 assembly. Two pieces:bench/bh_window_bench.cpp,bench/bh_window_asm.S): T0 baseline (std::cos×3/sample) → T1 no-transcendentals (phasor recurrence) → T2 AVX-256 intrinsics → T3 hand-tuned asm → T4 multithreaded. Each tier verified vs T0 (max-abs-err < 1e-9).bench/profile/): stage breakdown of the actualfft()path.Findings
reduce_and_scale— the per-binstd::arg(atan2) +std::polar(sincos) stage — is 47–68% of the entire transform, 1.5–4.6× the FFT itself. Since analysis consumes mean-square magnitude and only reads phase at a handful of tone bins, most of thosenavg×nfftatan2 calls appear to be wasted work. This is the next optimization target.Build/run:
bench/build.sh && bench/bh_window_bench. Details inbench/README.md,bench/profile/PROFILE.md, and the spec/plan/session-state docs underdocs/superpowers/.Test Plan
src/modifications (profiling instrumentation was temporary, reverted)