GNU Radio Manual and C++ API Reference 3.10.2.0
The Free & Open Software Radio Ecosystem
fft.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2003,2008,2012,2020 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11#ifndef _FFT_FFT_H_
12#define _FFT_FFT_H_
13
14/*
15 * Wrappers for FFTW single precision 1d dft
16 */
17
18#include <gnuradio/fft/api.h>
19#include <gnuradio/gr_complex.h>
20#include <gnuradio/logger.h>
21#include <volk/volk_alloc.hh>
22#include <boost/thread.hpp>
23
24namespace gr {
25namespace fft {
26
27/*!
28 * \brief Export reference to planner mutex for those apps that
29 * want to use FFTW w/o using the fft_impl_fftw* classes.
30 */
32{
33public:
35 /*!
36 * Return reference to planner mutex
37 */
39};
40
41
42/*!
43 \brief FFT: templated
44 \ingroup misc
45 */
46
47
48template <class T, bool forward>
49struct fft_inbuf {
50 typedef T type;
51};
52
53template <>
54struct fft_inbuf<float, false> {
56};
57
58
59template <class T, bool forward>
60struct fft_outbuf {
61 typedef T type;
62};
63
64template <>
65struct fft_outbuf<float, true> {
67};
68
69template <class T, bool forward>
71{
72 int d_nthreads;
73 volk::vector<typename fft_inbuf<T, forward>::type> d_inbuf;
74 volk::vector<typename fft_outbuf<T, forward>::type> d_outbuf;
75 void* d_plan;
76 gr::logger d_logger;
77 void initialize_plan(int fft_size);
78
79public:
80 fft(int fft_size, int nthreads = 1);
81 // Copy disabled due to d_plan.
82 fft(const fft&) = delete;
83 fft& operator=(const fft&) = delete;
84 virtual ~fft();
85
86 /*
87 * These return pointers to buffers owned by fft_impl_fft_complex
88 * into which input and output take place. It's done this way in
89 * order to ensure optimal alignment for SIMD instructions.
90 */
91 typename fft_inbuf<T, forward>::type* get_inbuf() { return d_inbuf.data(); }
92 typename fft_outbuf<T, forward>::type* get_outbuf() { return d_outbuf.data(); }
93
94 int inbuf_length() const { return d_inbuf.size(); }
95 int outbuf_length() const { return d_outbuf.size(); }
96
97 /*!
98 * Set the number of threads to use for calculation.
99 */
100 void set_nthreads(int n);
101
102 /*!
103 * Get the number of threads being used by FFTW
104 */
105 int nthreads() const { return d_nthreads; }
106
107 /*!
108 * compute FFT. The input comes from inbuf, the output is placed in
109 * outbuf.
110 */
111 void execute();
112};
113
118
119} /* namespace fft */
120} /*namespace gr */
121
122#endif /* _FFT_FFT_H_ */
Definition: fft.h:71
fft(const fft &)=delete
int inbuf_length() const
Definition: fft.h:94
fft_outbuf< T, forward >::type * get_outbuf()
Definition: fft.h:92
void execute()
fft(int fft_size, int nthreads=1)
fft_inbuf< T, forward >::type * get_inbuf()
Definition: fft.h:91
int outbuf_length() const
Definition: fft.h:95
virtual ~fft()
void set_nthreads(int n)
fft & operator=(const fft &)=delete
int nthreads() const
Definition: fft.h:105
Export reference to planner mutex for those apps that want to use FFTW w/o using the fft_impl_fftw* c...
Definition: fft.h:32
static boost::mutex & mutex()
boost::mutex::scoped_lock scoped_lock
Definition: fft.h:34
GR_LOG macros.
Definition: logger.h:106
#define FFT_API
Definition: gr-fft/include/gnuradio/fft/api.h:18
std::complex< float > gr_complex
Definition: gr_complex.h:15
boost::mutex mutex
Definition: thread.h:37
boost::unique_lock< boost::mutex > scoped_lock
Definition: thread.h:38
GNU Radio logging wrapper.
Definition: basic_block.h:29
gr_complex type
Definition: fft.h:55
FFT: templated.
Definition: fft.h:49
T type
Definition: fft.h:50
gr_complex type
Definition: fft.h:66
Definition: fft.h:60
T type
Definition: fft.h:61