From 9efac71df2d352878e86df54889973b5cf9164bf Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 6 Feb 2012 12:01:57 -0500 Subject: core: add functions to set/get nthreads of gri FFT object. --- gnuradio-core/src/lib/general/gri_fft.cc | 36 ++++++++++++++++++++++++++++++++ gnuradio-core/src/lib/general/gri_fft.h | 30 ++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/gnuradio-core/src/lib/general/gri_fft.cc b/gnuradio-core/src/lib/general/gri_fft.cc index 8e5c1aed9..63e307776 100644 --- a/gnuradio-core/src/lib/general/gri_fft.cc +++ b/gnuradio-core/src/lib/general/gri_fft.cc @@ -158,6 +158,18 @@ gri_fft_complex::~gri_fft_complex () 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 () { @@ -213,6 +225,18 @@ gri_fft_real_fwd::~gri_fft_real_fwd () 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 () { @@ -268,6 +292,18 @@ gri_fft_real_rev::~gri_fft_real_rev () 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 () { diff --git a/gnuradio-core/src/lib/general/gri_fft.h b/gnuradio-core/src/lib/general/gri_fft.h index c09930db0..ed80badf1 100644 --- a/gnuradio-core/src/lib/general/gri_fft.h +++ b/gnuradio-core/src/lib/general/gri_fft.h @@ -69,6 +69,16 @@ public: 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. */ @@ -101,6 +111,16 @@ public: 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. */ @@ -133,6 +153,16 @@ public: 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. */ -- cgit