Skip to content

Commit 33a13b1

Browse files
Merge pull request #69 from falseywinchnet/ymqqw5-main/refactor-bfft-phase-path-with-slope-linear-extraction
Replace tree/vector atan2 kernels with slope-linear tables, add generated tables and new benchmarks
2 parents 02b1a34 + 41bcba2 commit 33a13b1

4 files changed

Lines changed: 324 additions & 41 deletions

File tree

src/detail/bruun_kernel.hpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// backend.
1313

1414
#include <algorithm>
15-
#include <array>
1615
#include <cassert>
1716
#include <cmath>
1817
#include <cstdint>
@@ -550,25 +549,7 @@ struct bruun_sincos_sample {
550549
double c;
551550
};
552551

553-
template<int K>
554-
struct bruun_sincos_table {
555-
static_assert((K & (K - 1)) == 0, "K must be a power of two");
556-
557-
std::array<bruun_sincos_sample, K> value{};
558-
559-
bruun_sincos_table() {
560-
for (int i = 0; i < K; ++i) {
561-
const double phase = bruun_tau * static_cast<double>(i) / static_cast<double>(K);
562-
value[static_cast<std::size_t>(i)].s = std::sin(phase);
563-
value[static_cast<std::size_t>(i)].c = std::cos(phase);
564-
}
565-
}
566-
567-
static const bruun_sincos_table& get() {
568-
static const bruun_sincos_table table;
569-
return table;
570-
}
571-
};
552+
#include "generated/bruun_sincos_table256.hpp"
572553

573554
// Fast phase -> sin/cos for the mag-phase inverse hot loop. The inverse of
574555
// BFFT's own forward_mag_phase stores phases in [0, 2*pi), so the common round
@@ -595,7 +576,7 @@ static inline void bruun_table256_poly3_sincos(double phase, double* s_out, doub
595576
const double sr = r * (1.0 - r2 * (1.0 / 6.0));
596577
const double cr = 1.0 - r2 * 0.5;
597578

598-
const bruun_sincos_sample sample = bruun_sincos_table<table_size>::get().value[idx];
579+
const bruun_sincos_sample sample = bruun_sincos_table256[idx];
599580
*c_out = sample.c * cr - sample.s * sr;
600581
*s_out = sample.s * cr + sample.c * sr;
601582
}

src/detail/generated/bruun_phase_slope_tables.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
// Generated by tools/gen_phase_slope_tables.py using mpmath with 100 decimal digits.
3+
// CMake and deployed builds consume this checked-in file directly; mpmath is not a build dependency.
34
// Do not edit constants by hand.
45

56
template<>

0 commit comments

Comments
 (0)