commit-gnuradio
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]