summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/general
diff options
context:
space:
mode:
authorTom Rondeau2012-02-02 17:26:39 -0500
committerTom Rondeau2012-02-13 14:56:34 -0500
commitae663decab658be25ac01072fa2f5c8454bd6167 (patch)
treec9bf58b3a8624764ed92f5c4bb9a8df6d54dc07b /gnuradio-core/src/lib/general
parenta3b19015cb1c896aef19a7817458878337b3f5e3 (diff)
downloadgnuradio-ae663decab658be25ac01072fa2f5c8454bd6167.tar.gz
gnuradio-ae663decab658be25ac01072fa2f5c8454bd6167.tar.bz2
gnuradio-ae663decab658be25ac01072fa2f5c8454bd6167.zip
core: moving multiply_const_ff from gengen to general to take advantage of volk.
Also adds SSE and AVX and unaligned Volk versions for this.
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r--gnuradio-core/src/lib/general/CMakeLists.txt1
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am9
-rw-r--r--gnuradio-core/src/lib/general/general.i2
-rw-r--r--gnuradio-core/src/lib/general/general_generated.i1
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.cc7
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_const_cc.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_const_ff.cc80
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_const_ff.h60
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_const_ff.i33
9 files changed, 186 insertions, 9 deletions
diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt
index 6afdfe27c..393f732b7 100644
--- a/gnuradio-core/src/lib/general/CMakeLists.txt
+++ b/gnuradio-core/src/lib/general/CMakeLists.txt
@@ -232,6 +232,7 @@ set(gr_core_general_triple_threats
gr_map_bb
gr_multiply_cc
gr_multiply_const_cc
+ gr_multiply_const_ff
gr_nlog10_ff
gr_nop
gr_null_sink
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am
index 65b5a729e..5a6f5bf46 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -94,6 +94,9 @@ libgeneral_la_SOURCES = \
gr_lfsr_32k_source_s.cc \
gr_map_bb.cc \
gr_misc.cc \
+ gr_multiply_cc.cc \
+ gr_multiply_const_cc.cc \
+ gr_multiply_const_ff.cc \
gr_nlog10_ff.cc \
gr_nop.cc \
gr_null_sink.cc \
@@ -249,6 +252,9 @@ grinclude_HEADERS = \
gr_map_bb.h \
gr_math.h \
gr_misc.h \
+ gr_multiply_cc.h \
+ gr_multiply_const_cc.h \
+ gr_multiply_const_ff.h \
gr_nco.h \
gr_nlog10_ff.h \
gr_nop.h \
@@ -408,6 +414,9 @@ swiginclude_HEADERS = \
gr_kludge_copy.i \
gr_lfsr_32k_source_s.i \
gr_map_bb.i \
+ gr_multiply_cc.i \
+ gr_multiply_const_cc.i \
+ gr_multiply_const_ff.i \
gr_nlog10_ff.i \
gr_nop.i \
gr_null_sink.i \
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index 7de13258e..ac3fef84c 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -108,6 +108,7 @@
#include <gr_map_bb.h>
#include <gr_multiply_cc.h>
#include <gr_multiply_const_cc.h>
+#include <gr_multiply_const_ff.h>
#include <gr_feval.h>
#include <gr_pwr_squelch_cc.h>
#include <gr_pwr_squelch_ff.h>
@@ -226,6 +227,7 @@
%include "gr_map_bb.i"
%include "gr_multiply_cc.i"
%include "gr_multiply_const_cc.i"
+%include "gr_multiply_const_ff.i"
%include "gr_feval.i"
%include "gr_pwr_squelch_cc.i"
%include "gr_pwr_squelch_ff.i"
diff --git a/gnuradio-core/src/lib/general/general_generated.i b/gnuradio-core/src/lib/general/general_generated.i
index 847860f53..52e09f89b 100644
--- a/gnuradio-core/src/lib/general/general_generated.i
+++ b/gnuradio-core/src/lib/general/general_generated.i
@@ -29,7 +29,6 @@
#include <gr_divide_ff.h>
#include <gr_divide_ii.h>
#include <gr_divide_ss.h>
-#include <gr_multiply_const_ff.h>
#include <gr_multiply_const_ii.h>
#include <gr_multiply_const_ss.h>
#include <gr_multiply_const_vcc.h>
diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.cc b/gnuradio-core/src/lib/general/gr_int_to_float.cc
index dca0e1b89..7ec15b1a8 100644
--- a/gnuradio-core/src/lib/general/gr_int_to_float.cc
+++ b/gnuradio-core/src/lib/general/gr_int_to_float.cc
@@ -26,7 +26,6 @@
#include <gr_int_to_float.h>
#include <gr_io_signature.h>
-#include <gri_int_to_float.h>
#include <volk/volk.h>
gr_int_to_float_sptr
@@ -54,17 +53,13 @@ gr_int_to_float::work (int noutput_items,
const int32_t *in = (const int32_t *) input_items[0];
float *out = (float *) output_items[0];
-#if 1
if(is_unaligned()) {
volk_32i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items);
}
else {
volk_32i_s32f_convert_32f_a(out, in, d_scale, d_vlen*noutput_items);
}
-#else
- gri_int_to_float(in, out, d_vlen*noutput_items);
-#endif
-
+
return noutput_items;
}
diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc
index e301ae8eb..59521f54a 100644
--- a/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc
+++ b/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc
@@ -57,8 +57,6 @@ gr_multiply_const_cc::set_k(gr_complex k)
d_k = k;
}
-#include <cstdio>
-
int
gr_multiply_const_cc::work (int noutput_items,
gr_vector_const_void_star &input_items,
diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc b/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc
new file mode 100644
index 000000000..8354cb27b
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc
@@ -0,0 +1,80 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_multiply_const_ff.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+gr_multiply_const_ff_sptr
+gr_make_multiply_const_ff (float k, size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new gr_multiply_const_ff (k, vlen));
+}
+
+gr_multiply_const_ff::gr_multiply_const_ff (float k, size_t vlen)
+ : gr_sync_block ("gr_multiply_const_ff",
+ gr_make_io_signature (1, 1, sizeof (float)*vlen),
+ gr_make_io_signature (1, 1, sizeof (float)*vlen)),
+ d_k(k), d_vlen(vlen)
+{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
+}
+
+float
+gr_multiply_const_ff::k() const
+{
+ return d_k;
+}
+
+void
+gr_multiply_const_ff::set_k(float k)
+{
+ d_k = k;
+}
+
+int
+gr_multiply_const_ff::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const float *in = (const float *) input_items[0];
+ float *out = (float *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ if(is_unaligned()) {
+ volk_32f_s32f_multiply_32f_u(out, in, d_k, noi);
+ }
+ else {
+ volk_32f_s32f_multiply_32f_a(out, in, d_k, noi);
+ }
+
+ return noutput_items;
+}
+
+
+
diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.h b/gnuradio-core/src/lib/general/gr_multiply_const_ff.h
new file mode 100644
index 000000000..ef42a92f4
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_const_ff.h
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_MULTIPLY_CONST_FF_H
+#define INCLUDED_GR_MULTIPLY_CONST_FF_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_multiply_const_ff;
+typedef boost::shared_ptr<gr_multiply_const_ff> gr_multiply_const_ff_sptr;
+
+GR_CORE_API gr_multiply_const_ff_sptr
+gr_make_multiply_const_ff (float k, size_t vlen=1);
+
+/*!
+ * \brief Multiply stream of float values with a constant \p k
+ * \ingroup math_blk
+ */
+
+class GR_CORE_API gr_multiply_const_ff : public gr_sync_block
+{
+ private:
+ friend GR_CORE_API gr_multiply_const_ff_sptr
+ gr_make_multiply_const_ff (float k, size_t vlen);
+ gr_multiply_const_ff (float k, size_t vlen);
+
+ float d_k;
+ size_t d_vlen;
+
+ public:
+ float k() const;
+ void set_k(float k);
+
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_MULTIPLY_CONST_FF_H */
diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.i b/gnuradio-core/src/lib/general/gr_multiply_const_ff.i
new file mode 100644
index 000000000..0fd3b1225
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_const_ff.i
@@ -0,0 +1,33 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,multiply_const_ff)
+
+gr_multiply_const_ff_sptr
+gr_make_multiply_const_ff (float k, size_t vlen=1);
+
+class gr_multiply_const_ff : public gr_sync_block
+{
+public:
+ float k() const;
+ void set_k(float k);
+};