Replace production phase extractor with slope-linear Q512 tables#68
Merged
falseywinchnet merged 1 commit intoJun 27, 2026
Conversation
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.
Motivation
Q=512) specialized forfloatanddoubleto improve portability and L1 residency.mpmathand embed them as aligned, constexpr data to avoid runtime trig calls and range-dependent behavior.Description
src/detail/generated/bruun_phase_slope_tables.hppforbruun_phase_slope_tables<float,128,512>andbruun_phase_slope_tables<double,256,512>withalignas(64)constants and astd::uint8_t slope_to_leaf[513]map.bruun_phase_slope_leafand a genericbruun_phase_first_octant_slope_linear<T,Leaves,Q>function plus type-specific wrappersbruun_phase_first_octantandbruun_phase_first_octant_f32and float overloads ofbruun_fused_madd/bruun_fused_msubinsrc/detail/bruun_kernel.hpp.bruun_phase_atan2_mag/bruun_phase_atan2_mag_f32now use the slope-linear tables and quadrant repair; the forward mag/phase conversion loop was kept sequential over standard-order bins inconvert_standard_complex_to_mag_phase.tools/gen_phase_slope_tables.py(mpmath, 100 dps) to regenerate tables, updatedexamples/atan2_benchmark.cpplabels to the new slope paths, addedexamples/audio_magphase_roundtrip_benchmark.cpp, and added a dense slope accuracy testcheck_slope_phase_accuracyintests/correctness.cppplus a relaxed mag/phase tolerance intests/api_c.cto match the double target.Testing
cmake -S . -B build && cmake --build build -jand the build completed successfully.ctest --test-dir build --output-on-failureand all tests passed (reported 2 tests in the CI run:correctnessandapi_c)../build/atan_vectoring_network_experiment 4194304which produced:bfft slope256 linear double: 0.260033 s, 16.130 Mphase/s,bfft slope128 linear float: 0.283724 s, 14.783 Mphase/s, andbfft table sincos: 0.146617 s, 28.607 Mpair/s../build/audio_magphase_roundtrip_benchmark 2048 4096which produced split timings and accuracy metrics includingmagphase fwd+inv 0.594445 s,MSE 1.2865420194109656e-20,SNR 193.138900 dB, andmax_abs 2.043787084016202e-10.Codex Task