commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 11/28: basic: use volk multiply scalar func


From: git
Subject: [Commit-gnuradio] [gnuradio] 11/28: basic: use volk multiply scalar function for multiply_const fc32
Date: Mon, 15 Aug 2016 00:47:05 +0000 (UTC)

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

nwest pushed a commit to annotated tag gr_basic_work
in repository gnuradio.

commit 0261b2aa04bf29086042f0847328eef64206be69
Author: Josh Blum <address@hidden>
Date:   Wed Nov 9 12:31:20 2011 -0800

    basic: use volk multiply scalar function for multiply_const fc32
---
 gr-basic/lib/gr_basic_add_const.cc      | 12 +++----
 gr-basic/lib/gr_basic_multiply_const.cc | 61 ++++++++++++++++++++++++++++-----
 2 files changed, 58 insertions(+), 15 deletions(-)

diff --git a/gr-basic/lib/gr_basic_add_const.cc 
b/gr-basic/lib/gr_basic_add_const.cc
index 69729ce..cce5851 100644
--- a/gr-basic/lib/gr_basic_add_const.cc
+++ b/gr-basic/lib/gr_basic_add_const.cc
@@ -47,10 +47,9 @@ public:
             "add const generic",
             gr_make_io_signature (1, 1, sizeof(type)*vlen),
             gr_make_io_signature (1, 1, sizeof(type)*vlen)
-        ),
-        _vlen(vlen)
+        )
     {
-        _val.resize(_vlen);
+        _val.resize(vlen);
     }
 
     int work(
@@ -58,12 +57,12 @@ public:
         gr_vector_const_void_star &input_items,
         gr_vector_void_star &output_items
     ){
-        const size_t n_nums = noutput_items * _vlen;
+        const size_t n_nums = noutput_items * _val.size();
         type *out = reinterpret_cast<type *>(output_items[0]);
         const type *in = reinterpret_cast<const type *>(input_items[0]);
 
         //simple vec len 1 for the fast
-        if (_vlen == 1){
+        if (_val.size() == 1){
             const type val = _val[0];
             for (size_t i = 0; i < n_nums; i++){
                 out[i] = in[i] + val;
@@ -80,7 +79,7 @@ public:
     }
 
     void _set_value(const std::vector<std::complex<double> > &val){
-        if (val.size() != _vlen){
+        if (val.size() != _val.size()){
             throw std::invalid_argument("set_value called with the wrong 
length");
         }
         for (size_t i = 0; i < val.size(); i++){
@@ -89,7 +88,6 @@ public:
     }
 
 private:
-    const size_t _vlen;
     std::vector<type> _val;
 };
 
diff --git a/gr-basic/lib/gr_basic_multiply_const.cc 
b/gr-basic/lib/gr_basic_multiply_const.cc
index 048675f..469ffe9 100644
--- a/gr-basic/lib/gr_basic_multiply_const.cc
+++ b/gr-basic/lib/gr_basic_multiply_const.cc
@@ -37,6 +37,50 @@ template <typename type> void conv(const 
std::complex<double> &in, type &out){
 }
 
 /***********************************************************************
+ * FC32 multiply const implementation
+ **********************************************************************/
+class gr_basic_multiply_const_fc32 : public gr_basic_multiply_const{
+public:
+    typedef std::complex<float> type;
+
+    gr_basic_multiply_const_fc32(void):
+        gr_sync_block(
+            "multiply const fc32",
+            gr_make_io_signature (1, 1, sizeof(std::complex<float>)),
+            gr_make_io_signature (1, 1, sizeof(std::complex<float>))
+        )
+    {
+        _val.resize(1);
+        const int alignment_multiple = volk_get_alignment() / 
(sizeof(std::complex<float>));
+        set_output_multiple(std::max(1, alignment_multiple));
+    }
+
+    int work(
+        int noutput_items,
+        gr_vector_const_void_star &input_items,
+        gr_vector_void_star &output_items
+    ){
+        const type scalar = _val[0];
+        type *out = reinterpret_cast<type *>(output_items[0]);
+        const type *in = reinterpret_cast<const type *>(input_items[0]);
+        volk_32fc_s32fc_multiply_32fc_a(out, in, scalar, noutput_items);
+        return noutput_items;
+    }
+
+    void _set_value(const std::vector<std::complex<double> > &val){
+        if (val.size() != _val.size()){
+            throw std::invalid_argument("set_value called with the wrong 
length");
+        }
+        for (size_t i = 0; i < val.size(); i++){
+            conv(val[i], _val[i]);
+        }
+    }
+
+protected:
+    std::vector<type> _val;
+};
+
+/***********************************************************************
  * Generic multiply const implementation
  **********************************************************************/
 template <typename type>
@@ -47,10 +91,9 @@ public:
             "multiply const generic",
             gr_make_io_signature (1, 1, sizeof(type)*vlen),
             gr_make_io_signature (1, 1, sizeof(type)*vlen)
-        ),
-        _vlen(vlen)
+        )
     {
-        _val.resize(_vlen);
+        _val.resize(vlen);
     }
 
     int work(
@@ -58,12 +101,12 @@ public:
         gr_vector_const_void_star &input_items,
         gr_vector_void_star &output_items
     ){
-        const size_t n_nums = noutput_items * _vlen;
+        const size_t n_nums = noutput_items * _val.size();
         type *out = reinterpret_cast<type *>(output_items[0]);
         const type *in = reinterpret_cast<const type *>(input_items[0]);
 
         //simple vec len 1 for the fast
-        if (_vlen == 1){
+        if (_val.size() == 1){
             const type val = _val[0];
             for (size_t i = 0; i < n_nums; i++){
                 out[i] = in[i] * val;
@@ -80,7 +123,7 @@ public:
     }
 
     void _set_value(const std::vector<std::complex<double> > &val){
-        if (val.size() != _vlen){
+        if (val.size() != _val.size()){
             throw std::invalid_argument("set_value called with the wrong 
length");
         }
         for (size_t i = 0; i < val.size(); i++){
@@ -88,8 +131,7 @@ public:
         }
     }
 
-private:
-    const size_t _vlen;
+protected:
     std::vector<type> _val;
 };
 
@@ -97,6 +139,9 @@ private:
  * Adder factory function
  **********************************************************************/
 gr_basic_multiply_const::sptr gr_basic_multiply_const::make(op_type type, 
const size_t vlen){
+
+    if (type == OP_FC32 && vlen == 1) return sptr(new 
gr_basic_multiply_const_fc32());
+
     switch(type){
     case OP_FC64: return sptr(new 
gr_basic_multiply_const_generic<std::complex<double> >(vlen));
     case OP_F64: return sptr(new 
gr_basic_multiply_const_generic<double>(vlen));



reply via email to

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