Skip to content

Commit 63e927a

Browse files
Merge pull request #66 from falseywinchnet/revert-65-ubkvb7-main/add-new-atan_vectoring_network_experiment
Revert "Add vectorized vec5 cubic and tree32 phase approximations + benchmark updates"
2 parents ee475ee + e8d1d10 commit 63e927a

2 files changed

Lines changed: 4 additions & 74 deletions

File tree

examples/atan2_benchmark.cpp

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ struct sample {
1818
double x;
1919
double y;
2020
double mag;
21-
double phase;
2221
};
2322

2423
double normalize_phase(double phase) {
@@ -47,7 +46,6 @@ std::vector<sample> make_samples(std::size_t count) {
4746
value.x = radius * std::cos(angle);
4847
value.y = radius * std::sin(angle);
4948
value.mag = radius;
50-
value.phase = normalize_phase(angle);
5149
}
5250
return samples;
5351
}
@@ -64,29 +62,6 @@ double time_loop(const std::vector<sample>& samples, Func func, double& sink) {
6462
return std::chrono::duration<double>(stop - start).count();
6563
}
6664

67-
#if BRUUN_LEVEL >= 1
68-
double time_vec5_pair_loop(const std::vector<sample>& samples, double& sink) {
69-
const auto start = std::chrono::steady_clock::now();
70-
double total = 0.0;
71-
std::size_t i = 0;
72-
for (; i + 1 < samples.size(); i += 2) {
73-
double phase0;
74-
double phase1;
75-
bruun::bruun_phase_atan2_mag_pair(samples[i].y, samples[i].x, samples[i].mag,
76-
samples[i + 1].y, samples[i + 1].x, samples[i + 1].mag,
77-
&phase0, &phase1);
78-
total += phase0 + phase1;
79-
}
80-
for (; i < samples.size(); ++i) {
81-
total += bruun::bruun_phase_atan2_core(samples[i].y, samples[i].x, samples[i].mag,
82-
bruun::bruun_phase_first_octant_vec5_cubic);
83-
}
84-
const auto stop = std::chrono::steady_clock::now();
85-
sink += total;
86-
return std::chrono::duration<double>(stop - start).count();
87-
}
88-
#endif
89-
9065
} // namespace
9166

9267
int main(int argc, char** argv) {
@@ -111,15 +86,6 @@ int main(int argc, char** argv) {
11186
return bruun::bruun_phase_atan2_mag(value.y, value.x, value.mag);
11287
}, sink);
11388

114-
const double bfft_vec_double_seconds = time_loop(samples, [](const sample& value) {
115-
return bruun::bruun_phase_atan2_core(value.y, value.x, value.mag,
116-
bruun::bruun_phase_first_octant_vec5_cubic);
117-
}, sink);
118-
119-
#if BRUUN_LEVEL >= 1
120-
const double bfft_vec_pair_double_seconds = time_vec5_pair_loop(samples, sink);
121-
#endif
122-
12389
const double std_float_seconds = time_loop(samples, [](const sample& value) {
12490
const float y = static_cast<float>(value.y);
12591
const float x = static_cast<float>(value.x);
@@ -136,20 +102,7 @@ int main(int argc, char** argv) {
136102
const float y = static_cast<float>(value.y);
137103
const float x = static_cast<float>(value.x);
138104
const float mag = static_cast<float>(value.mag);
139-
const double phase = bruun::bruun_phase_atan2_core(y, x, mag,
140-
bruun::bruun_phase_first_octant_vec5_cubic);
141-
return static_cast<float>(phase);
142-
}, sink);
143-
144-
const double std_sincos_seconds = time_loop(samples, [](const sample& value) {
145-
return std::sin(value.phase) + std::cos(value.phase);
146-
}, sink);
147-
148-
const double bfft_sincos_seconds = time_loop(samples, [](const sample& value) {
149-
double s_value;
150-
double c_value;
151-
bruun::bruun_table256_poly3_sincos(value.phase, &s_value, &c_value);
152-
return s_value + c_value;
105+
return bruun::bruun_phase_atan2_mag_f32(y, x, mag);
153106
}, sink);
154107

155108
const double std_sincos_seconds = time_loop(samples, [](const sample& value) {

src/detail/bruun_kernel.hpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,33 +2758,10 @@ class RFFT {
27582758
#endif
27592759
for (; k < N / 2; ++k) {
27602760
const int m = kin[k];
2761-
output[k].re = work[2*m];
2762-
output[k].im = -work[2*m + 1];
2763-
}
2764-
2765-
int k = 1;
2766-
#if BRUUN_LEVEL >= 1
2767-
for (; k + 1 < N / 2; k += 2) {
2768-
const double re0 = output[k].re;
2769-
const double im0 = output[k].im;
2770-
const double re1 = output[k + 1].re;
2771-
const double im1 = output[k + 1].im;
2772-
const double mag0 = std::sqrt(re0 * re0 + im0 * im0);
2773-
const double mag1 = std::sqrt(re1 * re1 + im1 * im1);
2774-
double phase0;
2775-
double phase1;
2776-
bruun_phase_atan2_mag_pair(im0, re0, mag0, im1, re1, mag1, &phase0, &phase1);
2777-
output[k].re = mag0;
2778-
output[k].im = phase0;
2779-
output[k + 1].re = mag1;
2780-
output[k + 1].im = phase1;
2781-
}
2782-
#endif
2783-
for (; k < N / 2; ++k) {
2784-
const double re = output[k].re;
2785-
const double im = output[k].im;
2761+
const double re = work[2*m];
2762+
const double im = -work[2*m + 1];
27862763
const double mag = std::sqrt(re * re + im * im);
2787-
double phase = bruun_phase_atan2_core(im, re, mag, bruun_phase_first_octant_vec5_cubic);
2764+
double phase = bruun_phase_atan2_mag(im, re, mag);
27882765
if (phase < 0.0) {
27892766
phase += 2.0 * M_PI;
27902767
}

0 commit comments

Comments
 (0)