[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 05/09: fft: replace fftwf_malloc with volk_
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 05/09: fft: replace fftwf_malloc with volk_malloc |
Date: |
Wed, 9 Mar 2016 15:50:52 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch maint
in repository gnuradio.
commit 6baa4c86c5e1f5889e44a4e8e38750b0de3bf061
Author: Nathan West <address@hidden>
Date: Wed Mar 9 00:10:08 2016 -0500
fft: replace fftwf_malloc with volk_malloc
fftwf might not be compiled with AVX, which results in improper
alignment when fftwf_malloc'd buffers are used in VOLK kernels. To fix
this, just replace all fftw_malloc/fftwf_free calls with
volk_malloc/volk_free calls with whatever alignment VOLK claims is
needed.
---
gr-fft/lib/fft.cc | 53 +++++++++++++++++++++++++++--------------------------
1 file changed, 27 insertions(+), 26 deletions(-)
diff --git a/gr-fft/lib/fft.cc b/gr-fft/lib/fft.cc
index 729600c..9041712 100644
--- a/gr-fft/lib/fft.cc
+++ b/gr-fft/lib/fft.cc
@@ -22,6 +22,8 @@
#include <gnuradio/fft/fft.h>
#include <gnuradio/sys_paths.h>
+#include <gnuradio/gr_complex.h>
+#include <volk/volk.h>
#include <fftw3.h>
#ifdef _MSC_VER //http://www.fftw.org/install/windows.html#DLLwisdom
@@ -36,7 +38,6 @@ static int my_fftw_read_char(void *f) { return fgetc((FILE *)
f); }
#define fftwl_import_wisdom_from_file(f)
fftwl_import_wisdom(my_fftw_read_char, (void*) (f))
#endif //_MSC_VER
-#include <gnuradio/gr_complex.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@ -53,25 +54,25 @@ namespace gr {
gr_complex *
malloc_complex(int size)
{
- return (gr_complex*)fftwf_malloc(sizeof(gr_complex)*size);
+ return (gr_complex*) volk_malloc (sizeof (gr_complex)*size,
volk_get_alignment ());
}
float *
malloc_float(int size)
{
- return (float*)fftwf_malloc(sizeof(float)*size);
+ return (float*) volk_malloc (sizeof (float)*size, volk_get_alignment ());
}
double *
malloc_double(int size)
{
- return (double*)fftwf_malloc(sizeof(double)*size);
+ return (double*) volk_malloc (sizeof (double)*size, volk_get_alignment
());
}
void
free(void *b)
{
- fftwf_free(b);
+ volk_free(b);
}
boost::mutex &
@@ -149,14 +150,14 @@ namespace gr {
}
d_fft_size = fft_size;
- d_inbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) *
inbuf_length ());
+ d_inbuf = (gr_complex *) volk_malloc (sizeof (gr_complex) * inbuf_length
(), volk_get_alignment ());
if (d_inbuf == 0) {
- throw std::runtime_error ("fftwf_malloc");
+ throw std::runtime_error ("volk_malloc");
}
- d_outbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) *
outbuf_length ());
+ d_outbuf = (gr_complex *) volk_malloc (sizeof (gr_complex) *
outbuf_length (), volk_get_alignment ());
if (d_outbuf == 0) {
- fftwf_free (d_inbuf);
- throw std::runtime_error ("fftwf_malloc");
+ volk_free (d_inbuf);
+ throw std::runtime_error ("volk_malloc");
}
d_nthreads = nthreads;
@@ -182,8 +183,8 @@ namespace gr {
planner::scoped_lock lock(planner::mutex());
fftwf_destroy_plan ((fftwf_plan) d_plan);
- fftwf_free (d_inbuf);
- fftwf_free (d_outbuf);
+ volk_free (d_inbuf);
+ volk_free (d_outbuf);
}
void
@@ -219,15 +220,15 @@ namespace gr {
}
d_fft_size = fft_size;
- d_inbuf = (float *) fftwf_malloc (sizeof (float) * inbuf_length ());
+ d_inbuf = (float *) volk_malloc (sizeof (float) * inbuf_length (),
volk_get_alignment ());
if (d_inbuf == 0) {
- throw std::runtime_error ("fftwf_malloc");
+ throw std::runtime_error ("volk_malloc");
}
- d_outbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) *
outbuf_length ());
+ d_outbuf = (gr_complex *) volk_malloc (sizeof (gr_complex) *
outbuf_length (), volk_get_alignment ());
if (d_outbuf == 0) {
- fftwf_free (d_inbuf);
- throw std::runtime_error ("fftwf_malloc");
+ volk_free (d_inbuf);
+ throw std::runtime_error ("volk_malloc");
}
d_nthreads = nthreads;
@@ -252,8 +253,8 @@ namespace gr {
planner::scoped_lock lock(planner::mutex());
fftwf_destroy_plan ((fftwf_plan) d_plan);
- fftwf_free (d_inbuf);
- fftwf_free (d_outbuf);
+ volk_free (d_inbuf);
+ volk_free (d_outbuf);
}
void
@@ -289,15 +290,15 @@ namespace gr {
}
d_fft_size = fft_size;
- d_inbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) *
inbuf_length ());
+ d_inbuf = (gr_complex *) volk_malloc (sizeof (gr_complex) * inbuf_length
(), volk_get_alignment ());
if (d_inbuf == 0) {
- throw std::runtime_error ("fftwf_malloc");
+ throw std::runtime_error ("volk_malloc");
}
- d_outbuf = (float *) fftwf_malloc (sizeof (float) * outbuf_length ());
+ d_outbuf = (float *) volk_malloc (sizeof (float) * outbuf_length (),
volk_get_alignment ());
if (d_outbuf == 0) {
- fftwf_free (d_inbuf);
- throw std::runtime_error ("fftwf_malloc");
+ volk_free (d_inbuf);
+ throw std::runtime_error ("volk_malloc");
}
d_nthreads = nthreads;
@@ -325,8 +326,8 @@ namespace gr {
planner::scoped_lock lock(planner::mutex());
fftwf_destroy_plan ((fftwf_plan) d_plan);
- fftwf_free (d_inbuf);
- fftwf_free (d_outbuf);
+ volk_free (d_inbuf);
+ volk_free (d_outbuf);
}
void
- [Commit-gnuradio] [gnuradio] branch maint updated (cf5ebff -> 0a1a76d), git, 2016/03/09
- [Commit-gnuradio] [gnuradio] 08/09: Merge remote-tracking branch 'nwest/filter-docs' into maint, git, 2016/03/09
- [Commit-gnuradio] [gnuradio] 07/09: CMake: Fix dummy command in UseSWIG.cmake, git, 2016/03/09
- [Commit-gnuradio] [gnuradio] 03/09: docs: change firdes::low_pass2 docs to match implementation comments, git, 2016/03/09
- [Commit-gnuradio] [gnuradio] 05/09: fft: replace fftwf_malloc with volk_malloc,
git <=
- [Commit-gnuradio] [gnuradio] 04/09: grc: run flowgraphs even if bypassed blocks contain errors, git, 2016/03/09
- [Commit-gnuradio] [gnuradio] 09/09: Merge remote-tracking branch 'nwest/fft-avx-alignment' into maint, git, 2016/03/09
- [Commit-gnuradio] [gnuradio] 06/09: fft: explicitly link to volk, git, 2016/03/09
- [Commit-gnuradio] [gnuradio] 01/09: filter docs: add bt parameter to docs for gaussian filter, git, 2016/03/09
- [Commit-gnuradio] [gnuradio] 02/09: docs: reformat firdes docs to render nicely in doxygen, git, 2016/03/09