[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 10/10: filter: fixed use of volk_malloc in
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 10/10: filter: fixed use of volk_malloc in fft_filter kernel. |
Date: |
Tue, 11 Feb 2014 21:11:23 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 295ba353abebfedf90ece523343bcfeea2c2149d
Author: Tom Rondeau <address@hidden>
Date: Tue Feb 11 16:07:16 2014 -0500
filter: fixed use of volk_malloc in fft_filter kernel.
---
gr-filter/lib/fft_filter.cc | 92 ++++++++++++++++++++++-----------------------
1 file changed, 46 insertions(+), 46 deletions(-)
diff --git a/gr-filter/lib/fft_filter.cc b/gr-filter/lib/fft_filter.cc
index b45344d..e9c381f 100644
--- a/gr-filter/lib/fft_filter.cc
+++ b/gr-filter/lib/fft_filter.cc
@@ -43,7 +43,7 @@ namespace gr {
{
set_taps(taps);
}
-
+
fft_filter_fff::~fft_filter_fff()
{
delete d_fwdfft;
@@ -61,33 +61,33 @@ namespace gr {
int i = 0;
d_taps = taps;
compute_sizes(taps.size());
-
+
d_tail.resize(tailsize());
for(i = 0; i < tailsize(); i++)
d_tail[i] = 0;
-
+
float *in = d_fwdfft->get_inbuf();
gr_complex *out = d_fwdfft->get_outbuf();
-
+
float scale = 1.0 / d_fftsize;
-
+
// Compute forward xform of taps.
// Copy taps into first ntaps slots, then pad with zeros
for (i = 0; i < d_ntaps; i++)
in[i] = taps[i] * scale;
-
+
for (; i < d_fftsize; i++)
in[i] = 0;
-
+
d_fwdfft->execute(); // do the xform
-
+
// now copy output to d_xformed_taps
for (i = 0; i < d_fftsize/2+1; i++)
d_xformed_taps[i] = out[i];
-
+
return d_nsamples;
}
-
+
// determine and set d_ntaps, d_nsamples, d_fftsize
void
fft_filter_fff::compute_sizes(int ntaps)
@@ -96,7 +96,7 @@ namespace gr {
d_ntaps = ntaps;
d_fftsize = (int) (2 * pow(2.0, ceil(log(double(ntaps)) / log(2.0))));
d_nsamples = d_fftsize - d_ntaps + 1;
-
+
if(VERBOSE) {
std::cerr << "fft_filter_fff: ntaps = " << d_ntaps
<< " fftsize = " << d_fftsize
@@ -111,7 +111,7 @@ namespace gr {
volk_free(d_xformed_taps);
d_fwdfft = new fft::fft_real_fwd(d_fftsize);
d_invfft = new fft::fft_real_rev(d_fftsize);
- d_xformed_taps =
(gr_complex*)volk_malloc(sizeof(gr_complex)*d_fftsize/2+1,
+ d_xformed_taps =
(gr_complex*)volk_malloc(sizeof(gr_complex)*(d_fftsize/2+1),
volk_get_alignment());
}
}
@@ -143,35 +143,35 @@ namespace gr {
{
return d_nthreads;
}
-
+
int
fft_filter_fff::filter(int nitems, const float *input, float *output)
{
int dec_ctr = 0;
int j = 0;
int ninput_items = nitems * d_decimation;
-
+
for (int i = 0; i < ninput_items; i += d_nsamples){
-
+
memcpy(d_fwdfft->get_inbuf(), &input[i], d_nsamples * sizeof(float));
-
+
for (j = d_nsamples; j < d_fftsize; j++)
d_fwdfft->get_inbuf()[j] = 0;
-
+
d_fwdfft->execute(); // compute fwd xform
-
+
gr_complex *a = d_fwdfft->get_outbuf();
gr_complex *b = d_xformed_taps;
gr_complex *c = d_invfft->get_inbuf();
-
+
volk_32fc_x2_multiply_32fc_a(c, a, b, d_fftsize/2+1);
-
+
d_invfft->execute(); // compute inv xform
-
- // add in the overlapping tail
+
+ // add in the overlapping tail
for (j = 0; j < tailsize(); j++)
d_invfft->get_outbuf()[j] += d_tail[j];
-
+
// copy nsamples to output
j = dec_ctr;
while (j < d_nsamples) {
@@ -179,19 +179,19 @@ namespace gr {
j += d_decimation;
}
dec_ctr = (j - d_nsamples);
-
+
// stash the tail
memcpy(&d_tail[0], d_invfft->get_outbuf() + d_nsamples,
tailsize() * sizeof(float));
}
-
+
return nitems;
}
/**************************************************************/
-
+
fft_filter_ccc::fft_filter_ccc(int decimation,
const std::vector<gr_complex> &taps,
int nthreads)
@@ -200,7 +200,7 @@ namespace gr {
{
set_taps(taps);
}
-
+
fft_filter_ccc::~fft_filter_ccc()
{
delete d_fwdfft;
@@ -218,33 +218,33 @@ namespace gr {
int i = 0;
d_taps = taps;
compute_sizes(taps.size());
-
+
d_tail.resize(tailsize());
for(i = 0; i < tailsize(); i++)
d_tail[i] = 0;
-
+
gr_complex *in = d_fwdfft->get_inbuf();
gr_complex *out = d_fwdfft->get_outbuf();
-
+
float scale = 1.0 / d_fftsize;
-
+
// Compute forward xform of taps.
// Copy taps into first ntaps slots, then pad with zeros
for(i = 0; i < d_ntaps; i++)
in[i] = taps[i] * scale;
-
+
for(; i < d_fftsize; i++)
in[i] = 0;
-
+
d_fwdfft->execute(); // do the xform
-
+
// now copy output to d_xformed_taps
for(i = 0; i < d_fftsize; i++)
d_xformed_taps[i] = out[i];
-
+
return d_nsamples;
}
-
+
// determine and set d_ntaps, d_nsamples, d_fftsize
void
fft_filter_ccc::compute_sizes(int ntaps)
@@ -253,7 +253,7 @@ namespace gr {
d_ntaps = ntaps;
d_fftsize = (int) (2 * pow(2.0, ceil(log(double(ntaps)) / log(2.0))));
d_nsamples = d_fftsize - d_ntaps + 1;
-
+
if(VERBOSE) {
std::cerr << "fft_filter_ccc: ntaps = " << d_ntaps
<< " fftsize = " << d_fftsize
@@ -300,17 +300,17 @@ namespace gr {
{
return d_nthreads;
}
-
+
int
fft_filter_ccc::filter(int nitems, const gr_complex *input, gr_complex
*output)
{
int dec_ctr = 0;
int j = 0;
int ninput_items = nitems * d_decimation;
-
+
for(int i = 0; i < ninput_items; i += d_nsamples) {
memcpy(d_fwdfft->get_inbuf(), &input[i], d_nsamples *
sizeof(gr_complex));
-
+
for(j = d_nsamples; j < d_fftsize; j++)
d_fwdfft->get_inbuf()[j] = 0;
@@ -319,16 +319,16 @@ namespace gr {
gr_complex *a = d_fwdfft->get_outbuf();
gr_complex *b = d_xformed_taps;
gr_complex *c = d_invfft->get_inbuf();
-
+
volk_32fc_x2_multiply_32fc_a(c, a, b, d_fftsize);
-
+
d_invfft->execute(); // compute inv xform
-
+
// add in the overlapping tail
-
+
for(j = 0; j < tailsize(); j++)
d_invfft->get_outbuf()[j] += d_tail[j];
-
+
// copy nsamples to output
j = dec_ctr;
while(j < d_nsamples) {
@@ -336,7 +336,7 @@ namespace gr {
j += d_decimation;
}
dec_ctr = (j - d_nsamples);
-
+
// stash the tail
memcpy(&d_tail[0], d_invfft->get_outbuf() + d_nsamples,
tailsize() * sizeof(gr_complex));
- [Commit-gnuradio] [gnuradio] branch master updated (19d111e -> 295ba35), git, 2014/02/11
- [Commit-gnuradio] [gnuradio] 03/10: Fixed other issues with app - changes to fft display - still missing 'tune on click', git, 2014/02/11
- [Commit-gnuradio] [gnuradio] 06/10: filter: added a ccc version of the pfb_arb_resampler block., git, 2014/02/11
- [Commit-gnuradio] [gnuradio] 02/10: update README, git, 2014/02/11
- [Commit-gnuradio] [gnuradio] 04/10: fixed click to tune, click mouse on fft display will tune to that frequency, git, 2014/02/11
- [Commit-gnuradio] [gnuradio] 05/10: Merge remote-tracking branch 'cswiger/master' into hfx, git, 2014/02/11
- [Commit-gnuradio] [gnuradio] 07/10: uhd: hf_explorer example: Added some more options for better handling of rates., git, 2014/02/11
- [Commit-gnuradio] [gnuradio] 08/10: Merge branch 'maint', git, 2014/02/11
- [Commit-gnuradio] [gnuradio] 10/10: filter: fixed use of volk_malloc in fft_filter kernel.,
git <=
- [Commit-gnuradio] [gnuradio] 09/10: qtgui: in sink_c and sink_f, use volk_malloc/volk_free instead of new for buffers., git, 2014/02/11
- [Commit-gnuradio] [gnuradio] 01/10: fixing hfx.py for proper uhd support - tuning was negative of desired change, removed antenna tuner support, git, 2014/02/11