commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 01/02: VOLKized nlog10


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/02: VOLKized nlog10
Date: Fri, 16 Sep 2016 16:00:09 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch next
in repository gnuradio.

commit 22f637f30e54f6a46c8c40c8923ef3d8c66104e9
Author: Marcus Müller <address@hidden>
Date:   Thu Sep 15 19:43:00 2016 -0600

    VOLKized nlog10
    
    The inner VOLK demanded improvement of this.
    
    Still not perfect; a volk_32f_s32f_log2_scaled kernel would be better.
---
 gr-blocks/lib/nlog10_ff_impl.cc | 29 +++++++++++++++++++++++------
 gr-blocks/lib/nlog10_ff_impl.h  |  4 +++-
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/gr-blocks/lib/nlog10_ff_impl.cc b/gr-blocks/lib/nlog10_ff_impl.cc
index bed2da4..67dafae 100644
--- a/gr-blocks/lib/nlog10_ff_impl.cc
+++ b/gr-blocks/lib/nlog10_ff_impl.cc
@@ -26,6 +26,7 @@
 
 #include "nlog10_ff_impl.h"
 #include <gnuradio/io_signature.h>
+#include <volk/volk.h>
 
 namespace gr {
   namespace blocks {
@@ -39,8 +40,23 @@ namespace gr {
       : sync_block("nlog10_ff",
                      io_signature::make (1, 1, sizeof(float)*vlen),
                      io_signature::make (1, 1, sizeof(float)*vlen)),
-       d_n(n), d_vlen(vlen), d_k(k)
+        d_vlen(vlen)
     {
+      setk(k);
+      setn(n);
+      //TODO message handlers
+    }
+
+    void
+    nlog10_ff_impl::setk(float k)
+    {
+      d_k = k;
+    }
+
+    void
+    nlog10_ff_impl::setn(float n)
+    {
+      d_prefactor = n / log2f(10.0f);
     }
 
     int
@@ -48,15 +64,16 @@ namespace gr {
                              gr_vector_const_void_star &input_items,
                              gr_vector_void_star &output_items)
     {
+      #define novolk  0
       const float *in = (const float *) input_items[0];
       float *out = (float *) output_items[0];
       int noi = noutput_items * d_vlen;
-      float n = d_n;
-      float k = d_k;
-
-      for (int i = 0; i < noi; i++)
-       out[i] = n * log10(std::max(in[i], (float) 1e-18)) + k;
 
+      volk_32f_log2_32f(out, in, noi);
+      volk_32f_s32f_multiply_32f(out, out, d_prefactor, noi);
+      for(int i = 0; i < noi; ++i) {
+        out[i] += d_k;
+      }
       return noutput_items;
     }
 
diff --git a/gr-blocks/lib/nlog10_ff_impl.h b/gr-blocks/lib/nlog10_ff_impl.h
index dd260be..21c64d4 100644
--- a/gr-blocks/lib/nlog10_ff_impl.h
+++ b/gr-blocks/lib/nlog10_ff_impl.h
@@ -30,12 +30,14 @@ namespace gr {
 
     class BLOCKS_API nlog10_ff_impl : public nlog10_ff
     {
-      float  d_n;
+      float  d_prefactor;
       size_t d_vlen;
       float  d_k;
 
     public:
       nlog10_ff_impl(float n, size_t vlen, float k);
+      void setn(float n);
+      void setk(float k);
 
       int work(int noutput_items,
               gr_vector_const_void_star &input_items,



reply via email to

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