diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-03-06 14:59:56 -0500 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-03-06 14:59:56 -0500 |
commit | 4865f080c419349274d945e046b2e46920edc682 (patch) | |
tree | 1b071e87444c9cfde9279c391cb2c8751c7e445b | |
parent | a770feec38cd8a188a4c4c88f34d513155b4b539 (diff) |
core: removing goertzel and fft implementations from core; see gr-fft.
Also cleaning up some other leftovers.
-rw-r--r-- | docs/sphinx/source/gr/dft_blk.rst | 6 | ||||
-rw-r--r-- | docs/sphinx/source/gr/filter_blk.rst | 42 | ||||
-rw-r--r-- | docs/sphinx/source/gr/index.rst | 56 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/CMakeLists.txt | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/gri_goertzel.cc | 75 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/gri_goertzel.h | 57 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gri_fft.cc | 336 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gri_fft.h | 189 | ||||
-rwxr-xr-x | gr-filter/examples/benchmark_filters.py (renamed from gnuradio-core/src/python/gnuradio/gr/benchmark_filters.py) | 4 |
10 files changed, 2 insertions, 766 deletions
diff --git a/docs/sphinx/source/gr/dft_blk.rst b/docs/sphinx/source/gr/dft_blk.rst deleted file mode 100644 index 4ac1d2e621..0000000000 --- a/docs/sphinx/source/gr/dft_blk.rst +++ /dev/null @@ -1,6 +0,0 @@ -gnuradio.gr: Fourier Transform -============================== - -.. autooldblock:: gnuradio.gr.goertzel_fc -.. autooldblock:: gnuradio.gr.fft_vcc -.. autooldblock:: gnuradio.gr.fft_vfc diff --git a/docs/sphinx/source/gr/filter_blk.rst b/docs/sphinx/source/gr/filter_blk.rst deleted file mode 100644 index 35b0aa866c..0000000000 --- a/docs/sphinx/source/gr/filter_blk.rst +++ /dev/null @@ -1,42 +0,0 @@ -gnuradio.gr: Filters -==================== - -.. autooldblock:: gnuradio.gr.fft_filter_ccc -.. autooldblock:: gnuradio.gr.fft_filter_fff -.. autooldblock:: gnuradio.gr.filter_delay_fc -.. autooldblock:: gnuradio.gr.fir_filter_ccc -.. autooldblock:: gnuradio.gr.fir_filter_ccf -.. autooldblock:: gnuradio.gr.fir_filter_fcc -.. autooldblock:: gnuradio.gr.fir_filter_fff -.. autooldblock:: gnuradio.gr.fir_filter_fsf -.. autooldblock:: gnuradio.gr.fir_filter_scc -.. autooldblock:: gnuradio.gr.fractional_interpolator_cc -.. autooldblock:: gnuradio.gr.fractional_interpolator_ff -.. autooldblock:: gnuradio.gr.freq_xlating_fir_filter_ccc -.. autooldblock:: gnuradio.gr.freq_xlating_fir_filter_ccf -.. autooldblock:: gnuradio.gr.freq_xlating_fir_filter_fcc -.. autooldblock:: gnuradio.gr.freq_xlating_fir_filter_fcf -.. autooldblock:: gnuradio.gr.freq_xlating_fir_filter_scc -.. autooldblock:: gnuradio.gr.freq_xlating_fir_filter_scf -.. autooldblock:: gnuradio.gr.hilbert_fc -.. autooldblock:: gnuradio.gr.iir_filter_ffd -.. autooldblock:: gnuradio.gr.interp_fir_filter_ccc -.. autooldblock:: gnuradio.gr.interp_fir_filter_ccf -.. autooldblock:: gnuradio.gr.interp_fir_filter_fcc -.. autooldblock:: gnuradio.gr.interp_fir_filter_fff -.. autooldblock:: gnuradio.gr.interp_fir_filter_fsf -.. autooldblock:: gnuradio.gr.interp_fir_filter_scc -.. autooldblock:: gnuradio.gr.rational_resampler_base_ccc -.. autooldblock:: gnuradio.gr.rational_resampler_base_ccf -.. autooldblock:: gnuradio.gr.rational_resampler_base_fcc -.. autooldblock:: gnuradio.gr.rational_resampler_base_fff -.. autooldblock:: gnuradio.gr.rational_resampler_base_fsf -.. autooldblock:: gnuradio.gr.rational_resampler_base_scc -.. autooldblock:: gnuradio.gr.single_pole_iir_filter_cc -.. autooldblock:: gnuradio.gr.single_pole_iir_filter_ff -.. autooldblock:: gnuradio.gr.pfb_arb_resampler_ccf -.. autooldblock:: gnuradio.gr.pfb_channelizer_ccf -.. autooldblock:: gnuradio.gr.pfb_clock_sync_ccf -.. autooldblock:: gnuradio.gr.pfb_clock_sync_fff -.. autooldblock:: gnuradio.gr.pfb_decimator_ccf -.. autooldblock:: gnuradio.gr.pfb_interpolator_ccf diff --git a/docs/sphinx/source/gr/index.rst b/docs/sphinx/source/gr/index.rst index 387f857f5e..f35653aaf8 100644 --- a/docs/sphinx/source/gr/index.rst +++ b/docs/sphinx/source/gr/index.rst @@ -55,52 +55,6 @@ Signal Sinks gnuradio.gr.udp_sink gnuradio.gr.wavfile_sink -Filters -^^^^^^^ - -.. autosummary:: - :nosignatures: - - gnuradio.gr.fft_filter_ccc - gnuradio.gr.fft_filter_fff - gnuradio.gr.filter_delay_fc - gnuradio.gr.fir_filter_ccc - gnuradio.gr.fir_filter_ccf - gnuradio.gr.fir_filter_fcc - gnuradio.gr.fir_filter_fff - gnuradio.gr.fir_filter_fsf - gnuradio.gr.fir_filter_scc - gnuradio.gr.fractional_interpolator_cc - gnuradio.gr.fractional_interpolator_ff - gnuradio.gr.freq_xlating_fir_filter_ccc - gnuradio.gr.freq_xlating_fir_filter_ccf - gnuradio.gr.freq_xlating_fir_filter_fcc - gnuradio.gr.freq_xlating_fir_filter_fcf - gnuradio.gr.freq_xlating_fir_filter_scc - gnuradio.gr.freq_xlating_fir_filter_scf - gnuradio.gr.hilbert_fc - gnuradio.gr.iir_filter_ffd - gnuradio.gr.interp_fir_filter_ccc - gnuradio.gr.interp_fir_filter_ccf - gnuradio.gr.interp_fir_filter_fcc - gnuradio.gr.interp_fir_filter_fff - gnuradio.gr.interp_fir_filter_fsf - gnuradio.gr.interp_fir_filter_scc - gnuradio.gr.rational_resampler_base_ccc - gnuradio.gr.rational_resampler_base_ccf - gnuradio.gr.rational_resampler_base_fcc - gnuradio.gr.rational_resampler_base_fff - gnuradio.gr.rational_resampler_base_fsf - gnuradio.gr.rational_resampler_base_scc - gnuradio.gr.single_pole_iir_filter_cc - gnuradio.gr.single_pole_iir_filter_ff - gnuradio.gr.pfb_arb_resampler_ccf - gnuradio.gr.pfb_channelizer_ccf - gnuradio.gr.pfb_clock_sync_ccf - gnuradio.gr.pfb_clock_sync_fff - gnuradio.gr.pfb_decimator_ccf - gnuradio.gr.pfb_interpolator_ccf - Information Coding and Decoding ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -127,16 +81,6 @@ Type Conversions gnuradio.gr.complex_to_arg -Fourier Transform -^^^^^^^^^^^^^^^^^ - -.. autosummary:: - :nosignatures: - - gnuradio.gr.goertzel_fc - gnuradio.gr.fft_vcc - gnuradio.gr.fft_vfc - Miscellaneous Blocks ^^^^^^^^^^^^^^^^^^^^ diff --git a/gnuradio-core/src/lib/filter/CMakeLists.txt b/gnuradio-core/src/lib/filter/CMakeLists.txt index 703580213e..a185b06bd5 100644 --- a/gnuradio-core/src/lib/filter/CMakeLists.txt +++ b/gnuradio-core/src/lib/filter/CMakeLists.txt @@ -26,7 +26,6 @@ ######################################################################## list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.c - ${CMAKE_CURRENT_SOURCE_DIR}/gri_goertzel.cc ) ######################################################################## @@ -35,7 +34,6 @@ list(APPEND gnuradio_core_sources install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_rotator.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_goertzel.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel" ) diff --git a/gnuradio-core/src/lib/filter/gri_goertzel.cc b/gnuradio-core/src/lib/filter/gri_goertzel.cc deleted file mode 100644 index 2fbdd3b137..0000000000 --- a/gnuradio-core/src/lib/filter/gri_goertzel.cc +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <cmath> - -#include <gri_goertzel.h> - -gri_goertzel::gri_goertzel(int rate, int len, float freq) -{ - gri_setparms(rate, len, freq); -} - -void -gri_goertzel::gri_setparms(int rate, int len, float freq) -{ - d_d1 = 0.0; - d_d2 = 0.0; - - float w = 2.0*M_PI*freq/rate; - d_wr = 2.0*std::cos(w); - d_wi = std::sin(w); - d_len = len; - d_processed = 0; - -} - -gr_complex gri_goertzel::batch(float *in) -{ - d_d1 = 0.0; - d_d2 = 0.0; - - for(int i = 0; i < d_len; i++) - input(in[i]); - - return output(); -} - -void gri_goertzel::input(const float &input) -{ - float y = input + d_wr*d_d1 - d_d2; - d_d2 = d_d1; - d_d1 = y; - d_processed++; -} - -gr_complex gri_goertzel::output() -{ - gr_complex out((0.5*d_wr*d_d1-d_d2)/d_len, (d_wi*d_d1)/d_len); - d_d1 = 0.0; - d_d2 = 0.0; - d_processed = 0; - return out; -} diff --git a/gnuradio-core/src/lib/filter/gri_goertzel.h b/gnuradio-core/src/lib/filter/gri_goertzel.h deleted file mode 100644 index e28cb21a88..0000000000 --- a/gnuradio-core/src/lib/filter/gri_goertzel.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_GOERTZEL_H -#define INCLUDED_GRI_GOERTZEL_H - -#include <gr_core_api.h> -#include <gr_types.h> - -/*! - * \brief Implements Goertzel single-bin DFT calculation - * \ingroup misc - */ -class GR_CORE_API gri_goertzel -{ -public: - gri_goertzel() {} - gri_goertzel(int rate, int len, float freq); - void gri_setparms(int rate, int len, float freq); - - // Process a input array - gr_complex batch(float *in); - - // Process sample by sample - void input(const float &in); - gr_complex output(); - bool ready() const { return d_processed == d_len; } - -private: - float d_d1; - float d_d2; - float d_wr; - float d_wi; - int d_len; - int d_processed; -}; - -#endif /* INCLUDED_GRI_GOERTZEL_H */ diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index de1ad59092..599d0f2a0d 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -77,7 +77,6 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gri_add_const_ss_generic.cc ${CMAKE_CURRENT_SOURCE_DIR}/gri_control_loop.cc ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gri_fft.cc ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.c ) diff --git a/gnuradio-core/src/lib/general/gri_fft.cc b/gnuradio-core/src/lib/general/gri_fft.cc deleted file mode 100644 index 78446ad39b..0000000000 --- a/gnuradio-core/src/lib/general/gri_fft.cc +++ /dev/null @@ -1,336 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2008,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gri_fft.h> -#include <gr_sys_paths.h> -#include <fftw3.h> - -#ifdef _MSC_VER //http://www.fftw.org/install/windows.html#DLLwisdom -static void my_fftw_write_char(char c, void *f) { fputc(c, (FILE *) f); } -#define fftw_export_wisdom_to_file(f) fftw_export_wisdom(my_fftw_write_char, (void*) (f)) -#define fftwf_export_wisdom_to_file(f) fftwf_export_wisdom(my_fftw_write_char, (void*) (f)) -#define fftwl_export_wisdom_to_file(f) fftwl_export_wisdom(my_fftw_write_char, (void*) (f)) - -static int my_fftw_read_char(void *f) { return fgetc((FILE *) f); } -#define fftw_import_wisdom_from_file(f) fftw_import_wisdom(my_fftw_read_char, (void*) (f)) -#define fftwf_import_wisdom_from_file(f) fftwf_import_wisdom(my_fftw_read_char, (void*) (f)) -#define fftwl_import_wisdom_from_file(f) fftwl_import_wisdom(my_fftw_read_char, (void*) (f)) -#endif //_MSC_VER - -#include <gr_complex.h> -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <cassert> -#include <stdexcept> - -#include <boost/filesystem/operations.hpp> -#include <boost/filesystem/path.hpp> -namespace fs = boost::filesystem; - -gr_complex * -gri_fft_malloc_complex(int size) -{ - return (gr_complex*)fftwf_malloc(sizeof(gr_complex)*size); -} - -float * -gri_fft_malloc_float(int size) -{ - return (float*)fftwf_malloc(sizeof(float)*size); -} - -double * -gri_fft_malloc_double(int size) -{ - return (double*)fftwf_malloc(sizeof(double)*size); -} - -void -gri_fft_free(void *b) -{ - fftwf_free(b); -} - -boost::mutex & -gri_fft_planner::mutex() -{ - static boost::mutex s_planning_mutex; - - return s_planning_mutex; -} - -static const char * -wisdom_filename () -{ - static fs::path path; - path = fs::path(gr_appdata_path()) / ".gr_fftw_wisdom"; - return path.string().c_str(); -} - -static void -gri_fftw_import_wisdom () -{ - const char *filename = wisdom_filename (); - FILE *fp = fopen (filename, "r"); - if (fp != 0){ - int r = fftwf_import_wisdom_from_file (fp); - fclose (fp); - if (!r){ - fprintf (stderr, "gri_fftw: can't import wisdom from %s\n", filename); - } - } -} - -static void -gri_fftw_config_threading (int nthreads) -{ - static int fftw_threads_inited = 0; - -#ifdef FFTW3F_THREADS - if (fftw_threads_inited == 0) - { - fftw_threads_inited = 1; - fftwf_init_threads(); - } - - fftwf_plan_with_nthreads(nthreads); -#endif -} - -static void -gri_fftw_export_wisdom () -{ - const char *filename = wisdom_filename (); - FILE *fp = fopen (filename, "w"); - if (fp != 0){ - fftwf_export_wisdom_to_file (fp); - fclose (fp); - } - else { - fprintf (stderr, "gri_fftw: "); - perror (filename); - } -} - -// ---------------------------------------------------------------- - -gri_fft_complex::gri_fft_complex (int fft_size, bool forward, int nthreads) -{ - // Hold global mutex during plan construction and destruction. - gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex()); - - assert (sizeof (fftwf_complex) == sizeof (gr_complex)); - - if (fft_size <= 0) - throw std::out_of_range ("gri_fftw: invalid fft_size"); - - d_fft_size = fft_size; - d_inbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) * inbuf_length ()); - if (d_inbuf == 0) - throw std::runtime_error ("fftwf_malloc"); - - d_outbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) * outbuf_length ()); - if (d_outbuf == 0){ - fftwf_free (d_inbuf); - throw std::runtime_error ("fftwf_malloc"); - } - - d_nthreads = nthreads; - gri_fftw_config_threading (nthreads); - gri_fftw_import_wisdom (); // load prior wisdom from disk - - d_plan = fftwf_plan_dft_1d (fft_size, - reinterpret_cast<fftwf_complex *>(d_inbuf), - reinterpret_cast<fftwf_complex *>(d_outbuf), - forward ? FFTW_FORWARD : FFTW_BACKWARD, - FFTW_MEASURE); - - if (d_plan == NULL) { - fprintf(stderr, "gri_fft_complex: error creating plan\n"); - throw std::runtime_error ("fftwf_plan_dft_1d failed"); - } - gri_fftw_export_wisdom (); // store new wisdom to disk -} - -gri_fft_complex::~gri_fft_complex () -{ - // Hold global mutex during plan construction and destruction. - gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex()); - - fftwf_destroy_plan ((fftwf_plan) d_plan); - fftwf_free (d_inbuf); - fftwf_free (d_outbuf); -} - -void -gri_fft_complex::set_nthreads(int n) -{ - if (n <= 0) - throw std::out_of_range ("gri_fftw: invalid number of threads"); - d_nthreads = n; - -#ifdef FFTW3F_THREADS - fftwf_plan_with_nthreads(d_nthreads); -#endif -} - -void -gri_fft_complex::execute () -{ - fftwf_execute ((fftwf_plan) d_plan); -} - -// ---------------------------------------------------------------- - -gri_fft_real_fwd::gri_fft_real_fwd (int fft_size, int nthreads) -{ - // Hold global mutex during plan construction and destruction. - gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex()); - - assert (sizeof (fftwf_complex) == sizeof (gr_complex)); - - if (fft_size <= 0) - throw std::out_of_range ("gri_fftw: invalid fft_size"); - - d_fft_size = fft_size; - d_inbuf = (float *) fftwf_malloc (sizeof (float) * inbuf_length ()); - if (d_inbuf == 0) - throw std::runtime_error ("fftwf_malloc"); - - d_outbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) * outbuf_length ()); - if (d_outbuf == 0){ - fftwf_free (d_inbuf); - throw std::runtime_error ("fftwf_malloc"); - } - - d_nthreads = nthreads; - gri_fftw_config_threading (nthreads); - gri_fftw_import_wisdom (); // load prior wisdom from disk - - d_plan = fftwf_plan_dft_r2c_1d (fft_size, - d_inbuf, - reinterpret_cast<fftwf_complex *>(d_outbuf), - FFTW_MEASURE); - - if (d_plan == NULL) { - fprintf(stderr, "gri_fft_real_fwd: error creating plan\n"); - throw std::runtime_error ("fftwf_plan_dft_r2c_1d failed"); - } - gri_fftw_export_wisdom (); // store new wisdom to disk -} - -gri_fft_real_fwd::~gri_fft_real_fwd () -{ - // Hold global mutex during plan construction and destruction. - gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex()); - - fftwf_destroy_plan ((fftwf_plan) d_plan); - fftwf_free (d_inbuf); - fftwf_free (d_outbuf); -} - -void -gri_fft_real_fwd::set_nthreads(int n) -{ - if (n <= 0) - throw std::out_of_range ("gri_fftw: invalid number of threads"); - d_nthreads = n; - -#ifdef FFTW3F_THREADS - fftwf_plan_with_nthreads(d_nthreads); -#endif -} - -void -gri_fft_real_fwd::execute () -{ - fftwf_execute ((fftwf_plan) d_plan); -} - -// ---------------------------------------------------------------- - -gri_fft_real_rev::gri_fft_real_rev (int fft_size, int nthreads) -{ - // Hold global mutex during plan construction and destruction. - gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex()); - - assert (sizeof (fftwf_complex) == sizeof (gr_complex)); - - if (fft_size <= 0) - throw std::out_of_range ("gri_fftw: invalid fft_size"); - - d_fft_size = fft_size; - d_inbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) * inbuf_length ()); - if (d_inbuf == 0) - throw std::runtime_error ("fftwf_malloc"); - - d_outbuf = (float *) fftwf_malloc (sizeof (float) * outbuf_length ()); - if (d_outbuf == 0){ - fftwf_free (d_inbuf); - throw std::runtime_error ("fftwf_malloc"); - } - - d_nthreads = nthreads; - gri_fftw_config_threading (nthreads); - gri_fftw_import_wisdom (); // load prior wisdom from disk - - // FIXME If there's ever a chance that the planning functions - // will be called in multiple threads, we've got to ensure single - // threaded access. They are not thread-safe. - d_plan = fftwf_plan_dft_c2r_1d (fft_size, - reinterpret_cast<fftwf_complex *>(d_inbuf), - d_outbuf, - FFTW_MEASURE); - - if (d_plan == NULL) { - fprintf(stderr, "gri_fft_real_rev: error creating plan\n"); - throw std::runtime_error ("fftwf_plan_dft_c2r_1d failed"); - } - gri_fftw_export_wisdom (); // store new wisdom to disk -} - -gri_fft_real_rev::~gri_fft_real_rev () -{ - fftwf_destroy_plan ((fftwf_plan) d_plan); - fftwf_free (d_inbuf); - fftwf_free (d_outbuf); -} - -void -gri_fft_real_rev::set_nthreads(int n) -{ - if (n <= 0) - throw std::out_of_range ("gri_fftw: invalid number of threads"); - d_nthreads = n; - -#ifdef FFTW3F_THREADS - fftwf_plan_with_nthreads(d_nthreads); -#endif -} - -void -gri_fft_real_rev::execute () -{ - fftwf_execute ((fftwf_plan) d_plan); -} - diff --git a/gnuradio-core/src/lib/general/gri_fft.h b/gnuradio-core/src/lib/general/gri_fft.h deleted file mode 100644 index c6fbd4f43f..0000000000 --- a/gnuradio-core/src/lib/general/gri_fft.h +++ /dev/null @@ -1,189 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GRI_FFT_H_ -#define _GRI_FFT_H_ - -/* - * Wrappers for FFTW single precision 1d dft - */ - -#include <gr_core_api.h> -#include <gr_complex.h> -#include <boost/thread.hpp> - -/*! \brief Helper function for allocating complex* buffers - */ -GR_CORE_API gr_complex* gri_fft_malloc_complex(int size); - -/*! \brief Helper function for allocating float* buffers - */ -GR_CORE_API float* gri_fft_malloc_float(int size); - -/*! \brief Helper function for allocating double* buffers - */ -GR_CORE_API double* gri_fft_malloc_double(int size); - -/*! \brief Helper function for freeing fft buffers - */ -GR_CORE_API void gri_fft_free(void *b); - - -/*! - * \brief Export reference to planner mutex for those apps that - * want to use FFTW w/o using the gri_fftw* classes. - */ -class GR_CORE_API gri_fft_planner { -public: - typedef boost::mutex::scoped_lock scoped_lock; - /*! - * Return reference to planner mutex - */ - static boost::mutex &mutex(); -}; - -/*! - * \brief FFT: complex in, complex out - * \ingroup misc - */ -class GR_CORE_API gri_fft_complex { - int d_fft_size; - int d_nthreads; - gr_complex *d_inbuf; - gr_complex *d_outbuf; - void *d_plan; - -public: - gri_fft_complex (int fft_size, bool forward = true, int nthreads=1); - virtual ~gri_fft_complex (); - - /* - * These return pointers to buffers owned by gri_fft_complex into which - * input and output take place. It's done this way in order to - * ensure optimal alignment for SIMD instructions. - */ - gr_complex *get_inbuf () const { return d_inbuf; } - gr_complex *get_outbuf () const { return d_outbuf; } - - int inbuf_length () const { return d_fft_size; } - int outbuf_length () const { return d_fft_size; } - - /*! - * Set the number of threads to use for caclulation. - */ - void set_nthreads(int n); - - /*! - * Get the number of threads being used by FFTW - */ - int nthreads() const { return d_nthreads; } - - /*! - * compute FFT. The input comes from inbuf, the output is placed in outbuf. - */ - void execute (); -}; - -/*! - * \brief FFT: real in, complex out - * \ingroup misc - */ -class GR_CORE_API gri_fft_real_fwd { - int d_fft_size; - int d_nthreads; - float *d_inbuf; - gr_complex *d_outbuf; - void *d_plan; - -public: - gri_fft_real_fwd (int fft_size, int nthreads=1); - virtual ~gri_fft_real_fwd (); - - /* - * These return pointers to buffers owned by gri_fft_real_fwd into - * which input and output take place. It's done this way in order - * to ensure optimal alignment for SIMD instructions. - */ - float *get_inbuf () const { return d_inbuf; } - gr_complex *get_outbuf () const { return d_outbuf; } - - int inbuf_length () const { return d_fft_size; } - int outbuf_length () const { return d_fft_size / 2 + 1; } - - /*! - * Set the number of threads to use for caclulation. - */ - void set_nthreads(int n); - - /*! - * Get the number of threads being used by FFTW - */ - int nthreads() const { return d_nthreads; } - - /*! - * compute FFT. The input comes from inbuf, the output is placed in outbuf. - */ - void execute (); -}; - -/*! - * \brief FFT: complex in, float out - * \ingroup misc - */ -class GR_CORE_API gri_fft_real_rev { - int d_fft_size; - int d_nthreads; - gr_complex *d_inbuf; - float *d_outbuf; - void *d_plan; - -public: - gri_fft_real_rev (int fft_size, int nthreads=1); - virtual ~gri_fft_real_rev (); - - /* - * These return pointers to buffers owned by gri_fft_real_rev into - * which input and output take place. It's done this way in order - * to ensure optimal alignment for SIMD instructions. - */ - gr_complex *get_inbuf () const { return d_inbuf; } - float *get_outbuf () const { return d_outbuf; } - - int inbuf_length () const { return d_fft_size / 2 + 1; } - int outbuf_length () const { return d_fft_size; } - - /*! - * Set the number of threads to use for caclulation. - */ - void set_nthreads(int n); - - /*! - * Get the number of threads being used by FFTW - */ - int nthreads() const { return d_nthreads; } - - /*! - * compute FFT. The input comes from inbuf, the output is placed in outbuf. - */ - void execute (); -}; - -#endif diff --git a/gnuradio-core/src/python/gnuradio/gr/benchmark_filters.py b/gr-filter/examples/benchmark_filters.py index 4fc10b7210..5fd012bcc4 100755 --- a/gnuradio-core/src/python/gnuradio/gr/benchmark_filters.py +++ b/gr-filter/examples/benchmark_filters.py @@ -66,9 +66,9 @@ def main(): block_size = options.block_size dec = options.decimation - benchmark("gr.fir_filter_ccc", gr.fir_filter_ccc, + benchmark("filter.fir_filter_ccc", gr.fir_filter_ccc, dec, ntaps, total_input_size, block_size) - benchmark("gr.fft_filter_ccc", gr.fft_filter_ccc, + benchmark("filter.fft_filter_ccc", gr.fft_filter_ccc, dec, ntaps, total_input_size, block_size) if __name__ == '__main__': |