summaryrefslogtreecommitdiff
path: root/gnuradio-core/src
diff options
context:
space:
mode:
authorTom Rondeau2012-02-06 22:02:56 -0500
committerTom Rondeau2012-02-13 14:57:15 -0500
commitf34b496341ceb73baffee6f8bf84ed197ffeeaf0 (patch)
tree765cc0376c5b511d96c818af06123a8c9237f98d /gnuradio-core/src
parent69210086c7ae98b93a63a1d810ee28b304a13520 (diff)
downloadgnuradio-f34b496341ceb73baffee6f8bf84ed197ffeeaf0.tar.gz
gnuradio-f34b496341ceb73baffee6f8bf84ed197ffeeaf0.tar.bz2
gnuradio-f34b496341ceb73baffee6f8bf84ed197ffeeaf0.zip
core: added Volk-optimized gr_multiply_conjugate_cc at one block with QA code.
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r--gnuradio-core/src/lib/general/CMakeLists.txt1
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am3
-rw-r--r--gnuradio-core/src/lib/general/general.i2
-rw-r--r--gnuradio-core/src/lib/general/gr_add_ff.cc4
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc69
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h57
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i32
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/Makefile.am1
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/qa_multiply_conjugate.py57
9 files changed, 222 insertions, 4 deletions
diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt
index ab35aa66a..2bc639cd3 100644
--- a/gnuradio-core/src/lib/general/CMakeLists.txt
+++ b/gnuradio-core/src/lib/general/CMakeLists.txt
@@ -235,6 +235,7 @@ set(gr_core_general_triple_threats
gr_multiply_ff
gr_multiply_const_cc
gr_multiply_const_ff
+ gr_multiply_conjugate_cc
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 89152d663..ea3b31fd3 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -99,6 +99,7 @@ libgeneral_la_SOURCES = \
gr_multiply_ff.cc \
gr_multiply_const_cc.cc \
gr_multiply_const_ff.cc \
+ gr_multiply_conjugate_cc.cc \
gr_nlog10_ff.cc \
gr_nop.cc \
gr_null_sink.cc \
@@ -259,6 +260,7 @@ grinclude_HEADERS = \
gr_multiply_ff.h \
gr_multiply_const_cc.h \
gr_multiply_const_ff.h \
+ gr_multiply_conjugate_cc.h \
gr_nco.h \
gr_nlog10_ff.h \
gr_nop.h \
@@ -423,6 +425,7 @@ swiginclude_HEADERS = \
gr_multiply_ff.i \
gr_multiply_const_cc.i \
gr_multiply_const_ff.i \
+ gr_multiply_conjugate_cc.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 c384ecfbb..89738b01a 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -110,6 +110,7 @@
#include <gr_multiply_ff.h>
#include <gr_multiply_const_cc.h>
#include <gr_multiply_const_ff.h>
+#include <gr_multiply_conjugate_cc.h>
#include <gr_feval.h>
#include <gr_pwr_squelch_cc.h>
#include <gr_pwr_squelch_ff.h>
@@ -231,6 +232,7 @@
%include "gr_multiply_ff.i"
%include "gr_multiply_const_cc.i"
%include "gr_multiply_const_ff.i"
+%include "gr_multiply_conjugate_cc.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/gr_add_ff.cc b/gnuradio-core/src/lib/general/gr_add_ff.cc
index a5db5ec5c..fc5455c98 100644
--- a/gnuradio-core/src/lib/general/gr_add_ff.cc
+++ b/gnuradio-core/src/lib/general/gr_add_ff.cc
@@ -54,9 +54,6 @@ gr_add_ff::work(int noutput_items,
int noi = d_vlen*noutput_items;
memcpy(out, input_items[0], noi*sizeof(float));
- for(size_t i = 1; i < input_items.size(); i++)
- volk_32f_x2_add_32f_u(out, out, (const float*)input_items[i], noi);
- /*
if(is_unaligned()) {
for(size_t i = 1; i < input_items.size(); i++)
volk_32f_x2_add_32f_u(out, out, (const float*)input_items[i], noi);
@@ -65,6 +62,5 @@ gr_add_ff::work(int noutput_items,
for(size_t i = 1; i < input_items.size(); i++)
volk_32f_x2_add_32f_a(out, out, (const float*)input_items[i], noi);
}
- */
return noutput_items;
}
diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc
new file mode 100644
index 000000000..103d87b8b
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc
@@ -0,0 +1,69 @@
+/* -*- 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_conjugate_cc.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+gr_multiply_conjugate_cc_sptr
+gr_make_multiply_conjugate_cc (size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new gr_multiply_conjugate_cc (vlen));
+}
+
+gr_multiply_conjugate_cc::gr_multiply_conjugate_cc (size_t vlen)
+ : gr_sync_block ("gr_multiply_conjugate_cc",
+ gr_make_io_signature (2, 2, sizeof (gr_complex)*vlen),
+ gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(alignment_multiple);
+}
+
+int
+gr_multiply_conjugate_cc::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ gr_complex *in0 = (gr_complex *) input_items[0];
+ gr_complex *in1 = (gr_complex *) input_items[1];
+ gr_complex *out = (gr_complex *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ if(is_unaligned()) {
+ volk_32fc_x2_multiply_conjugate_32fc_u(out, in0, in1, noi);
+ }
+ else {
+ volk_32fc_x2_multiply_conjugate_32fc_a(out, in0, in1, noi);
+ }
+
+ return noutput_items;
+}
+
+
+
diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h
new file mode 100644
index 000000000..eb032f31b
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h
@@ -0,0 +1,57 @@
+/* -*- 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_CONJUGATE_CC_H
+#define INCLUDED_GR_MULTIPLY_CONJUGATE_CC_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_multiply_conjugate_cc;
+typedef boost::shared_ptr<gr_multiply_conjugate_cc>
+gr_multiply_conjugate_cc_sptr;
+
+GR_CORE_API gr_multiply_conjugate_cc_sptr
+gr_make_multiply_conjugate_cc (size_t vlen=1);
+
+/*!
+ * \brief Multiplies a stream by the conjugate of the second stream
+ * \ingroup math_blk
+ */
+
+class GR_CORE_API gr_multiply_conjugate_cc : public gr_sync_block
+{
+ private:
+ friend GR_CORE_API gr_multiply_conjugate_cc_sptr
+ gr_make_multiply_conjugate_cc (size_t vlen);
+ gr_multiply_conjugate_cc (size_t vlen);
+
+ size_t d_vlen;
+
+ public:
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_MULTIPLY_CONJUGATE_CC_H */
diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i
new file mode 100644
index 000000000..023410505
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i
@@ -0,0 +1,32 @@
+/* -*- 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_conjugate_cc)
+
+gr_multiply_conjugate_cc_sptr
+gr_make_multiply_conjugate_cc (size_t vlen=1);
+
+class gr_multiply_conjugate_cc : public gr_sync_block
+{
+public:
+
+};
diff --git a/gnuradio-core/src/python/gnuradio/gr/Makefile.am b/gnuradio-core/src/python/gnuradio/gr/Makefile.am
index 16dd14790..3c9edcf5b 100644
--- a/gnuradio-core/src/python/gnuradio/gr/Makefile.am
+++ b/gnuradio-core/src/python/gnuradio/gr/Makefile.am
@@ -79,6 +79,7 @@ noinst_PYTHON = \
qa_kludged_imports.py \
qa_max.py \
qa_message.py \
+ qa_multiply_conjugate.py \
qa_mute.py \
qa_nlog10.py \
qa_noise.py \
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_multiply_conjugate.py b/gnuradio-core/src/python/gnuradio/gr/qa_multiply_conjugate.py
new file mode 100644
index 000000000..aaf3cc125
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_multiply_conjugate.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+#
+# 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.
+#
+
+from gnuradio import gr, gr_unittest
+
+class test_multiply_conjugate (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_000 (self):
+ src_data0 = (-2-2j, -1-1j, -2+2j, -1+1j,
+ 2-2j, 1-1j, 2+2j, 1+1j,
+ 0+0j)
+ src_data1 = (-3-3j, -4-4j, -3+3j, -4+4j,
+ 3-3j, 4-4j, 3+3j, 4+4j,
+ 0+0j)
+
+ exp_data = (12+0j, 8+0j, 12+0j, 8+0j,
+ 12+0j, 8+0j, 12+0j, 8+0j,
+ 0+0j)
+ src0 = gr.vector_source_c(src_data0)
+ src1 = gr.vector_source_c(src_data1)
+ op = gr.multiply_conjugate_cc ()
+ dst = gr.vector_sink_c ()
+
+ self.tb.connect(src0, (op,0))
+ self.tb.connect(src1, (op,1))
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data ()
+ self.assertEqual (exp_data, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_multiply_conjugate, "test_multiply_conjugate.xml")