diff options
author | Grant Cox <grant.cox@deepspaceamps.com> | 2019-11-20 23:18:56 -0600 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2020-01-04 23:32:42 -0800 |
commit | ebe8ffc58503a1b4f167a13d5663e8849379eaaf (patch) | |
tree | cd7b03d36b79966cf9b967bd4305da0bcb5149b1 /gr-blocks/lib/add_const_cc_impl.cc | |
parent | 27a466a9c8a03392270fadde9e5bafef5c062e61 (diff) |
gr-blocks: VOLKize add_const_ff implementation
- Use volk_32fc_x2_add_32fc to volk add constants to the input vector of
the block
- use volk::vector in add_const_ff_impl: Rather than using float* for
variable length vector addition in volk, use volk::vector<float> for
easier resizing.
- Use scoped_lock when modifying private data members in
add_const_ff_impl.cc. Remove getter functions for the d_k_copy vector.
Cast with static_cast rather than typical cast. Use vector.data()
rather than &vector[0].
Diffstat (limited to 'gr-blocks/lib/add_const_cc_impl.cc')
-rw-r--r-- | gr-blocks/lib/add_const_cc_impl.cc | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/gr-blocks/lib/add_const_cc_impl.cc b/gr-blocks/lib/add_const_cc_impl.cc index 6c326f1e1f..384efbbc6a 100644 --- a/gr-blocks/lib/add_const_cc_impl.cc +++ b/gr-blocks/lib/add_const_cc_impl.cc @@ -43,6 +43,13 @@ add_const_cc_impl::add_const_cc_impl(gr_complex k) { } +void add_const_cc_impl::set_k(gr_complex k) +{ + gr::thread::scoped_lock guard(d_setlock); + d_k = k; + std::fill(d_k_copy.begin(), d_k_copy.end(), d_k); +} + int add_const_cc_impl::work(int noutput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items) @@ -50,23 +57,14 @@ int add_const_cc_impl::work(int noutput_items, const gr_complex* iptr = (const gr_complex*)input_items[0]; gr_complex* optr = (gr_complex*)output_items[0]; - int size = noutput_items; + unsigned long input_size = static_cast<unsigned long>(noutput_items); - while (size >= 8) { - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - *optr++ = *iptr++ + d_k; - size -= 8; + gr::thread::scoped_lock guard(d_setlock); + if (d_k_copy.size() < input_size) { + d_k_copy.resize(input_size, d_k); } - while (size-- > 0) { - *optr++ = *iptr++ + d_k; - } + volk_32fc_x2_add_32fc(optr, iptr, d_k_copy.data(), noutput_items); return noutput_items; } |