diff options
author | Tom Rondeau | 2012-01-29 17:34:06 -0500 |
---|---|---|
committer | Tom Rondeau | 2012-01-29 17:34:06 -0500 |
commit | 812144f4c153dca385b65e79401c9f1d88b90173 (patch) | |
tree | 43fa5a9e35f6ae0f9f4bbf2a97a6eae1dc85fd46 | |
parent | d142fd9e31715bae85d65c4790f278143a784142 (diff) | |
download | gnuradio-812144f4c153dca385b65e79401c9f1d88b90173.tar.gz gnuradio-812144f4c153dca385b65e79401c9f1d88b90173.tar.bz2 gnuradio-812144f4c153dca385b65e79401c9f1d88b90173.zip |
core: switched complex to mag and mag_squared to use Volk functions.
-rw-r--r-- | gnuradio-core/src/lib/general/gr_complex_to_xxx.cc | 25 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_complex_to_xxx.h | 5 |
2 files changed, 20 insertions, 10 deletions
diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc index a59c127f3..0bdd06547 100644 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc +++ b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008,2010 Free Software Foundation, Inc. + * Copyright 2004,2008,2010,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -27,6 +27,7 @@ #include <gr_complex_to_xxx.h> #include <gr_io_signature.h> #include <gr_math.h> +#include <volk/volk.h> // ---------------------------------------------------------------- @@ -152,6 +153,9 @@ gr_complex_to_mag::gr_complex_to_mag (unsigned int vlen) gr_make_io_signature (1, 1, sizeof (float) * vlen)), d_vlen(vlen) { + const int alignment_multiple = + volk_get_alignment() / sizeof(float); + set_alignment(alignment_multiple); } int @@ -163,9 +167,9 @@ gr_complex_to_mag::work (int noutput_items, float *out = (float *) output_items[0]; int noi = noutput_items * d_vlen; - for (int i = 0; i < noi; i++){ - out[i] = std::abs (in[i]); - } + // turned out to be faster than aligned/unaligned switching + volk_32fc_magnitude_32f_u(out, in, noi); + return noutput_items; } @@ -183,6 +187,9 @@ gr_complex_to_mag_squared::gr_complex_to_mag_squared (unsigned int vlen) gr_make_io_signature (1, 1, sizeof (float) * vlen)), d_vlen(vlen) { + const int alignment_multiple = + volk_get_alignment() / sizeof(float); + set_alignment(alignment_multiple); } int @@ -194,11 +201,13 @@ gr_complex_to_mag_squared::work (int noutput_items, float *out = (float *) output_items[0]; int noi = noutput_items * d_vlen; - for (int i = 0; i < noi; i++){ - const float __x = in[i].real(); - const float __y = in[i].imag(); - out[i] = __x * __x + __y * __y; + if(unaligned()) { + volk_32fc_magnitude_squared_32f_u(out, in, noi); + } + else { + volk_32fc_magnitude_squared_32f_a(out, in, noi); } + return noutput_items; } diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.h b/gnuradio-core/src/lib/general/gr_complex_to_xxx.h index 166403259..232071323 100644 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.h +++ b/gnuradio-core/src/lib/general/gr_complex_to_xxx.h @@ -109,10 +109,11 @@ class GR_CORE_API gr_complex_to_imag : public gr_sync_block */ class GR_CORE_API gr_complex_to_mag : public gr_sync_block { - friend GR_CORE_API gr_complex_to_mag_sptr gr_make_complex_to_mag (unsigned int vlen); + friend GR_CORE_API gr_complex_to_mag_sptr + gr_make_complex_to_mag (unsigned int vlen); gr_complex_to_mag (unsigned int vlen); - unsigned int d_vlen; + unsigned int d_vlen; public: virtual int work (int noutput_items, |