Skip to content

Replace tree/vector atan2 kernels with slope-linear tables, add generated tables and new benchmarks#69

Merged
falseywinchnet merged 2 commits into
mainfrom
ymqqw5-main/refactor-bfft-phase-path-with-slope-linear-extraction
Jun 27, 2026
Merged

Replace tree/vector atan2 kernels with slope-linear tables, add generated tables and new benchmarks#69
falseywinchnet merged 2 commits into
mainfrom
ymqqw5-main/refactor-bfft-phase-path-with-slope-linear-extraction

Conversation

@falseywinchnet

Copy link
Copy Markdown
Owner

Motivation

  • Replace the ad-hoc tree/vectoring atan2 codepaths with a compact slope-linear table approach to simplify the hot path and ship precomputed, high-precision constants for speed and reproducible accuracy.
  • Add end-to-end audio mag/phase roundtrip and updated atan2 benchmark examples to validate and measure the new mag/phase and phase-extraction code.
  • Keep compatibility with legacy ad-hoc build commands by providing a tiny shim for src/atan_vectoring_network_experiment.cpp that delegates to the updated example source.

Description

  • Reworked phase extraction internals in src/detail/bruun_kernel.hpp to use templated bruun_phase_slope_leaf and generated slope->leaf tables, introduced bruun_phase_first_octant* and bruun_phase_atan2_mag* entry points, and replaced many previous tree/vector implementations with table-driven code and small inline helpers; added float and double fused helpers and inlining hints.
  • Added checked-in generated data headers src/detail/generated/bruun_phase_slope_tables.hpp and src/detail/generated/bruun_sincos_table256.hpp and a generator script tools/gen_phase_slope_tables.py that uses mpmath for regeneration (mpmath is not a build dependency).
  • Updated examples and build rules: changed examples/atan2_benchmark.cpp to use the slope-linear path and sample-phase bookkeeping, added examples/audio_magphase_roundtrip_benchmark.cpp, and registered new example executables in CMakeLists.txt; replaced src/atan_vectoring_network_experiment.cpp with a tiny shim that includes the example for backward-compatibility.
  • Adjusted tests to reflect the new accuracy target and new checks: loosened mag/phase tolerance in tests/api_c.c, and added check_slope_phase_accuracy and inclusion of bruun_kernel.hpp in tests/correctness.cpp.

Testing

  • Built the project with CMake (cmake -B build -S . && cmake --build build -j) and confirmed the build succeeds.
  • Ran the test suite with CTest (ctest --test-dir build) and the correctness and api_c tests completed successfully.
  • Built and ran the new examples to smoke-check behavior (examples/atan2_benchmark and examples/audio_magphase_roundtrip_benchmark) and observed expected runtime output (benchmarks run to completion).

Codex Task

@falseywinchnet falseywinchnet merged commit 33a13b1 into main Jun 27, 2026
4 checks passed
@falseywinchnet falseywinchnet deleted the ymqqw5-main/refactor-bfft-phase-path-with-slope-linear-extraction branch June 27, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant