[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));
- [Commit-gnuradio] [gnuradio] annotated tag gr_basic_work created (now ac6eec1), git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 02/28: gr-basic: volkified the add fn for f32, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 14/28: basic: integrated volk routine for float multiply const, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 23/28: Merge branch 'inplace_blocks' of gnuradio.org:jblum into gr_basic, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 10/28: Volk: add 32fc_s32fc_multiply_32fc to profiler, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 06/28: basic: call volk for float32 multiplier types, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 09/28: Volk: added 32fc x scalar multiply, implemented in Orc & generic. Orc/SSE tested 10x faster than generic., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 25/28: core: added set_output_alignment (policy 2 version), git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 11/28: basic: use volk multiply scalar function for multiply_const fc32,
git <=
- [Commit-gnuradio] [gnuradio] 24/28: basic: set inplace on gr-basic math blocks, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 16/28: basic: performance tweak for sig source index mod, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 04/28: basic: added other basic operators, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 01/28: basic: attempt at new component, partial adder implementation, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 27/28: basic: added dynamic delay block, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 13/28: Volk: whoops, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 17/28: core: squashed in-place block work, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 07/28: basic add/mult const, needs test, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 15/28: basic: added super fast signal source, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 26/28: basic: use set_output_alignment in the basic math blocks, git, 2016/08/14