diff options
author | ghostop14 <ghostop14@gmail.com> | 2020-01-29 17:20:16 -0500 |
---|---|---|
committer | Michael Dickens <michael.dickens@ettus.com> | 2020-02-14 10:05:12 -0500 |
commit | aa0bd44efbf8afdfd93d627e486c1427426b76f9 (patch) | |
tree | dd2acb4ebed83dc5a553678ba46b76424690b90a /gnuradio-runtime/include/gnuradio/nco.h | |
parent | 36680f338e0b7ae7e5bcf7d2a860527ca7b14dfe (diff) |
gr-digital: Improve Performance of Costas Loop
This update is focused on improving the throughput of the Costas
loop, however some changes are more global performance enhancements
as this PR has evolved. Updates include an ENABLE_NATIVE added to
CMake, which is off by default but enables native compiling (including
FMA support) if desired; sincos was inlined in sincos.h and sincos.cc
was removed from the appropriate CMake to improve sincos speed, some
constants were added to math.h, inlined functions in costas loop and
nco.h, used switch instead of function pointer (much faster), and
used fast complex multiply to get around all the range checking in
the standard complex.h complex multiply function on all builds.
Diffstat (limited to 'gnuradio-runtime/include/gnuradio/nco.h')
-rw-r--r-- | gnuradio-runtime/include/gnuradio/nco.h | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/gnuradio-runtime/include/gnuradio/nco.h b/gnuradio-runtime/include/gnuradio/nco.h index 6542fe58de..4bcdfe686b 100644 --- a/gnuradio-runtime/include/gnuradio/nco.h +++ b/gnuradio-runtime/include/gnuradio/nco.h @@ -44,27 +44,15 @@ public: void adjust_freq(double delta_angle_rate) { phase_inc += delta_angle_rate; } // increment current phase angle - void step() - { - phase += phase_inc; - if (fabs(phase) > GR_M_PI) { - while (phase > GR_M_PI) - phase -= 2 * GR_M_PI; - - while (phase < -GR_M_PI) - phase += 2 * GR_M_PI; - } - } - - void step(int n) + void step(int n = 1) { phase += phase_inc * n; if (fabs(phase) > GR_M_PI) { while (phase > GR_M_PI) - phase -= 2 * GR_M_PI; + phase -= GR_M_TWOPI; while (phase < -GR_M_PI) - phase += 2 * GR_M_PI; + phase += GR_M_TWOPI; } } @@ -73,7 +61,7 @@ public: double get_freq() const { return phase_inc; } // compute sin and cos for current phase angle - void sincos(float* sinx, float* cosx) const; + void sincos(float* sinx, float* cosx) const { gr::sincosf(phase, sinx, cosx); } // compute cos or sin for current phase angle float cos() const { return std::cos(phase); } @@ -94,12 +82,6 @@ protected: }; template <class o_type, class i_type> -void nco<o_type, i_type>::sincos(float* sinx, float* cosx) const -{ - gr::sincosf(phase, sinx, cosx); -} - -template <class o_type, class i_type> void nco<o_type, i_type>::sin(float* output, int noutput_items, double ampl) { for (int i = 0; i < noutput_items; i++) { |