From accc35f380e56af156153cd01540a46c7eb98f12 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 22 Jan 2012 17:46:22 -0500 Subject: core: test case of using Volk to convert from float to short. --- gnuradio-core/src/lib/general/gr_float_to_short.cc | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.cc b/gnuradio-core/src/lib/general/gr_float_to_short.cc index 084f76f9c..415ea6982 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_short.cc @@ -27,6 +27,9 @@ #include #include #include +#include + +#include gr_float_to_short_sptr gr_make_float_to_short () @@ -39,6 +42,9 @@ gr_float_to_short::gr_float_to_short () gr_make_io_signature (1, 1, sizeof (float)), gr_make_io_signature (1, 1, sizeof (short))) { + const int alignment_multiple = + volk_get_alignment() / sizeof(short); + set_alignment(alignment_multiple); } int @@ -49,8 +55,22 @@ gr_float_to_short::work (int noutput_items, const float *in = (const float *) input_items[0]; short *out = (short *) output_items[0]; - gri_float_to_short (in, out, noutput_items); - +#if 0 + if(is_unaligned()) { + float d_scale = 1.0; + //gri_float_to_short (in, out, noutput_items); + volk_32f_s32f_convert_16i_u(out, in, d_scale, noutput_items); + } + else { + float d_scale = 1.0; + volk_32f_s32f_convert_16i_a(out, in, d_scale, noutput_items); + } +#else + float d_scale = 1.0; + volk_32f_s32f_convert_16i_u(out, in, d_scale, noutput_items); + //gri_float_to_short (in, out, noutput_items); +#endif + return noutput_items; } -- cgit From 3737aa4b86af3b489ef3b91d8580bcd893295042 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 26 Jan 2012 20:20:49 -0500 Subject: core: moved float_to_X type converters over to use Volk calls. --- gnuradio-core/src/lib/general/gr_float_to_char.cc | 18 +++++++++++++++++- gnuradio-core/src/lib/general/gr_float_to_int.cc | 18 +++++++++++++++++- gnuradio-core/src/lib/general/gr_float_to_short.cc | 13 ++++--------- 3 files changed, 38 insertions(+), 11 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.cc b/gnuradio-core/src/lib/general/gr_float_to_char.cc index 88b9d276e..2d7e21f2e 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_char.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_char.cc @@ -27,6 +27,7 @@ #include #include #include +#include gr_float_to_char_sptr gr_make_float_to_char () @@ -39,6 +40,9 @@ gr_float_to_char::gr_float_to_char () gr_make_io_signature (1, 1, sizeof (float)), gr_make_io_signature (1, 1, sizeof (char))) { + const int alignment_multiple = + volk_get_alignment() / sizeof(char); + set_alignment(alignment_multiple); } int @@ -46,10 +50,22 @@ gr_float_to_char::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { +#if 1 + float d_scale = 1.0; const float *in = (const float *) input_items[0]; - char *out = (char *) output_items[0]; + int8_t *out = (int8_t *) output_items[0]; + if(is_unaligned()) { + volk_32f_s32f_convert_8i_u(out, in, d_scale, noutput_items); + } + else { + volk_32f_s32f_convert_8i_a(out, in, d_scale, noutput_items); + } +#else + const float *in = (const float *) input_items[0]; + char *out = (char *) output_items[0]; gri_float_to_char (in, out, noutput_items); +#endif return noutput_items; } diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.cc b/gnuradio-core/src/lib/general/gr_float_to_int.cc index 2349de8cb..2ca723c7c 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_int.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_int.cc @@ -27,6 +27,7 @@ #include #include #include +#include gr_float_to_int_sptr gr_make_float_to_int () @@ -39,6 +40,9 @@ gr_float_to_int::gr_float_to_int () gr_make_io_signature (1, 1, sizeof (float)), gr_make_io_signature (1, 1, sizeof (int))) { + const int alignment_multiple = + volk_get_alignment() / sizeof(int); + set_alignment(alignment_multiple); } int @@ -46,10 +50,22 @@ gr_float_to_int::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { +#if 1 + float d_scale = 1.0; const float *in = (const float *) input_items[0]; - int *out = (int *) output_items[0]; + int32_t *out = (int32_t *) output_items[0]; + if(is_unaligned()) { + volk_32f_s32f_convert_32i_u(out, in, d_scale, noutput_items); + } + else { + volk_32f_s32f_convert_32i_a(out, in, d_scale, noutput_items); + } +#else + const float *in = (const float *) input_items[0]; + int *out = (int *) output_items[0]; gri_float_to_int (in, out, noutput_items); +#endif return noutput_items; } diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.cc b/gnuradio-core/src/lib/general/gr_float_to_short.cc index 415ea6982..6c4d031ac 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_short.cc @@ -29,8 +29,6 @@ #include #include -#include - gr_float_to_short_sptr gr_make_float_to_short () { @@ -55,20 +53,17 @@ gr_float_to_short::work (int noutput_items, const float *in = (const float *) input_items[0]; short *out = (short *) output_items[0]; -#if 0 +#if 1 + float d_scale = 1.0; + //volk_32f_s32f_convert_16i_u(out, in, d_scale, noutput_items); if(is_unaligned()) { - float d_scale = 1.0; - //gri_float_to_short (in, out, noutput_items); volk_32f_s32f_convert_16i_u(out, in, d_scale, noutput_items); } else { - float d_scale = 1.0; volk_32f_s32f_convert_16i_a(out, in, d_scale, noutput_items); } #else - float d_scale = 1.0; - volk_32f_s32f_convert_16i_u(out, in, d_scale, noutput_items); - //gri_float_to_short (in, out, noutput_items); + gri_float_to_short (in, out, noutput_items); #endif return noutput_items; -- cgit From 8f09eb204213492091fa8310b165c8ddb89b2801 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 28 Jan 2012 12:49:00 -0500 Subject: volk: cleaned up float_to_X to be Volk-only and added vlen and scale to constructor to set the vector length and a free scaling with the data. --- gnuradio-core/src/lib/general/gr_float_to_char.cc | 42 +++++++++++--------- gnuradio-core/src/lib/general/gr_float_to_char.h | 16 ++++++-- gnuradio-core/src/lib/general/gr_float_to_char.i | 10 +++-- gnuradio-core/src/lib/general/gr_float_to_int.cc | 46 ++++++++++++---------- gnuradio-core/src/lib/general/gr_float_to_int.h | 16 ++++++-- gnuradio-core/src/lib/general/gr_float_to_int.i | 10 +++-- gnuradio-core/src/lib/general/gr_float_to_short.cc | 41 +++++++++++-------- gnuradio-core/src/lib/general/gr_float_to_short.h | 15 +++++-- gnuradio-core/src/lib/general/gr_float_to_short.i | 10 +++-- 9 files changed, 130 insertions(+), 76 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.cc b/gnuradio-core/src/lib/general/gr_float_to_char.cc index 2d7e21f2e..165172ac6 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_char.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_char.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010 Free Software Foundation, Inc. + * Copyright 2004,2010,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,19 +30,32 @@ #include gr_float_to_char_sptr -gr_make_float_to_char () +gr_make_float_to_char (size_t vlen, float scale) { - return gnuradio::get_initial_sptr(new gr_float_to_char ()); + return gnuradio::get_initial_sptr(new gr_float_to_char (vlen, scale)); } -gr_float_to_char::gr_float_to_char () +gr_float_to_char::gr_float_to_char (size_t vlen, float scale) : gr_sync_block ("gr_float_to_char", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (char))) + gr_make_io_signature (1, 1, sizeof (float)*vlen), + gr_make_io_signature (1, 1, sizeof (char)*vlen)), + d_vlen(vlen), d_scale(scale) { - const int alignment_multiple = - volk_get_alignment() / sizeof(char); - set_alignment(alignment_multiple); + const int alignment_multiple = + volk_get_alignment() / sizeof(char); + set_alignment(alignment_multiple); +} + +float +gr_float_to_char::scale() const +{ + return d_scale; +} + +void +gr_float_to_char::set_scale(float scale) +{ + d_scale = scale; } int @@ -50,22 +63,15 @@ gr_float_to_char::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { -#if 1 - float d_scale = 1.0; const float *in = (const float *) input_items[0]; int8_t *out = (int8_t *) output_items[0]; if(is_unaligned()) { - volk_32f_s32f_convert_8i_u(out, in, d_scale, noutput_items); + volk_32f_s32f_convert_8i_u(out, in, d_scale, d_vlen*noutput_items); } else { - volk_32f_s32f_convert_8i_a(out, in, d_scale, noutput_items); + volk_32f_s32f_convert_8i_a(out, in, d_scale, d_vlen*noutput_items); } -#else - const float *in = (const float *) input_items[0]; - char *out = (char *) output_items[0]; - gri_float_to_char (in, out, noutput_items); -#endif return noutput_items; } diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.h b/gnuradio-core/src/lib/general/gr_float_to_char.h index 434e2e9d0..c88645a18 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_char.h +++ b/gnuradio-core/src/lib/general/gr_float_to_char.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ class gr_float_to_char; typedef boost::shared_ptr gr_float_to_char_sptr; GR_CORE_API gr_float_to_char_sptr -gr_make_float_to_char (); +gr_make_float_to_char (size_t vlen=1, float scale=1); /*! * \brief Convert stream of float to a stream of char @@ -39,10 +39,18 @@ gr_make_float_to_char (); class GR_CORE_API gr_float_to_char : public gr_sync_block { - friend GR_CORE_API gr_float_to_char_sptr gr_make_float_to_char (); - gr_float_to_char (); + private: + friend GR_CORE_API gr_float_to_char_sptr gr_make_float_to_char + (size_t vlen, float scale); + gr_float_to_char (size_t vlen, float scale); + + size_t d_vlen; + float d_scale; public: + float scale() const; + void set_scale(float scale); + virtual int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.i b/gnuradio-core/src/lib/general/gr_float_to_char.i index 05b206554..05939f1b1 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_char.i +++ b/gnuradio-core/src/lib/general/gr_float_to_char.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,9 +22,13 @@ GR_SWIG_BLOCK_MAGIC(gr,float_to_char) -gr_float_to_char_sptr gr_make_float_to_char (); +gr_float_to_char_sptr +gr_make_float_to_char (size_t vlen=1, float scale=1); class gr_float_to_char : public gr_sync_block { - gr_float_to_char (); +public: + float scale() const; + void set_scale(float scale); + gr_float_to_char (size_t vlen, float scale); }; diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.cc b/gnuradio-core/src/lib/general/gr_float_to_int.cc index 2ca723c7c..c4d9991af 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_int.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_int.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2011 Free Software Foundation, Inc. + * Copyright 2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,42 +30,48 @@ #include gr_float_to_int_sptr -gr_make_float_to_int () +gr_make_float_to_int (size_t vlen, float scale) { - return gnuradio::get_initial_sptr(new gr_float_to_int ()); + return gnuradio::get_initial_sptr(new gr_float_to_int (vlen, scale)); } -gr_float_to_int::gr_float_to_int () +gr_float_to_int::gr_float_to_int (size_t vlen, float scale) : gr_sync_block ("gr_float_to_int", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (int))) + gr_make_io_signature (1, 1, sizeof (float)*vlen), + gr_make_io_signature (1, 1, sizeof (int)*vlen)), + d_vlen(vlen), d_scale(scale) { - const int alignment_multiple = - volk_get_alignment() / sizeof(int); - set_alignment(alignment_multiple); + const int alignment_multiple = + volk_get_alignment() / sizeof(int); + set_alignment(alignment_multiple); +} + +float +gr_float_to_int::scale() const +{ + return d_scale; +} + +void +gr_float_to_int::set_scale(float scale) +{ + d_scale = scale; } int gr_float_to_int::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { -#if 1 - float d_scale = 1.0; const float *in = (const float *) input_items[0]; int32_t *out = (int32_t *) output_items[0]; if(is_unaligned()) { - volk_32f_s32f_convert_32i_u(out, in, d_scale, noutput_items); + volk_32f_s32f_convert_32i_u(out, in, d_scale, d_vlen*noutput_items); } else { - volk_32f_s32f_convert_32i_a(out, in, d_scale, noutput_items); + volk_32f_s32f_convert_32i_a(out, in, d_scale, d_vlen*noutput_items); } -#else - const float *in = (const float *) input_items[0]; - int *out = (int *) output_items[0]; - gri_float_to_int (in, out, noutput_items); -#endif return noutput_items; } diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.h b/gnuradio-core/src/lib/general/gr_float_to_int.h index 3324ed110..0b42c0aab 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_int.h +++ b/gnuradio-core/src/lib/general/gr_float_to_int.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2011 Free Software Foundation, Inc. + * Copyright 2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ class gr_float_to_int; typedef boost::shared_ptr gr_float_to_int_sptr; GR_CORE_API gr_float_to_int_sptr -gr_make_float_to_int (); +gr_make_float_to_int (size_t vlen=1, float scale=1); /*! * \brief Convert stream of float to a stream of short @@ -39,10 +39,18 @@ gr_make_float_to_int (); class GR_CORE_API gr_float_to_int : public gr_sync_block { - friend GR_CORE_API gr_float_to_int_sptr gr_make_float_to_int (); - gr_float_to_int (); + private: + friend GR_CORE_API + gr_float_to_int_sptr gr_make_float_to_int (size_t vlen, float scale); + gr_float_to_int (size_t vlen, float scale); + + size_t d_vlen; + float d_scale; public: + float scale() const; + void set_scale(float scale); + virtual int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.i b/gnuradio-core/src/lib/general/gr_float_to_int.i index 4ab04cbf2..a0b52a3c1 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_int.i +++ b/gnuradio-core/src/lib/general/gr_float_to_int.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2011 Free Software Foundation, Inc. + * Copyright 2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,9 +22,13 @@ GR_SWIG_BLOCK_MAGIC(gr,float_to_int) -gr_float_to_int_sptr gr_make_float_to_int (); +gr_float_to_int_sptr +gr_make_float_to_int (size_t vlen=1, float scale=1); class gr_float_to_int : public gr_sync_block { - gr_float_to_int (); +public: + float scale() const; + void set_scale(float scale); + gr_float_to_int (size_t vlen, float scale); }; diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.cc b/gnuradio-core/src/lib/general/gr_float_to_short.cc index 6c4d031ac..e6ac5c184 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_short.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010 Free Software Foundation, Inc. + * Copyright 2004,2010,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,19 +30,32 @@ #include gr_float_to_short_sptr -gr_make_float_to_short () +gr_make_float_to_short (size_t vlen, float scale) { - return gnuradio::get_initial_sptr(new gr_float_to_short ()); + return gnuradio::get_initial_sptr(new gr_float_to_short (vlen, scale)); } -gr_float_to_short::gr_float_to_short () +gr_float_to_short::gr_float_to_short (size_t vlen, float scale) : gr_sync_block ("gr_float_to_short", - gr_make_io_signature (1, 1, sizeof (float)), - gr_make_io_signature (1, 1, sizeof (short))) + gr_make_io_signature (1, 1, sizeof (float)*vlen), + gr_make_io_signature (1, 1, sizeof (short)*vlen)), + d_vlen(vlen), d_scale(scale) { - const int alignment_multiple = - volk_get_alignment() / sizeof(short); - set_alignment(alignment_multiple); + const int alignment_multiple = + volk_get_alignment() / sizeof(short); + set_alignment(alignment_multiple); +} + +float +gr_float_to_short::scale() const +{ + return d_scale; +} + +void +gr_float_to_short::set_scale(float scale) +{ + d_scale = scale; } int @@ -53,18 +66,12 @@ gr_float_to_short::work (int noutput_items, const float *in = (const float *) input_items[0]; short *out = (short *) output_items[0]; -#if 1 - float d_scale = 1.0; - //volk_32f_s32f_convert_16i_u(out, in, d_scale, noutput_items); if(is_unaligned()) { - volk_32f_s32f_convert_16i_u(out, in, d_scale, noutput_items); + volk_32f_s32f_convert_16i_u(out, in, d_scale, d_vlen*noutput_items); } else { - volk_32f_s32f_convert_16i_a(out, in, d_scale, noutput_items); + volk_32f_s32f_convert_16i_a(out, in, d_scale, d_vlen*noutput_items); } -#else - gri_float_to_short (in, out, noutput_items); -#endif return noutput_items; } diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.h b/gnuradio-core/src/lib/general/gr_float_to_short.h index 010d61141..93e441f41 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.h +++ b/gnuradio-core/src/lib/general/gr_float_to_short.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ class gr_float_to_short; typedef boost::shared_ptr gr_float_to_short_sptr; GR_CORE_API gr_float_to_short_sptr -gr_make_float_to_short (); +gr_make_float_to_short (size_t vlen=1, float scale=1); /*! * \brief Convert stream of float to a stream of short @@ -39,10 +39,17 @@ gr_make_float_to_short (); class GR_CORE_API gr_float_to_short : public gr_sync_block { - friend GR_CORE_API gr_float_to_short_sptr gr_make_float_to_short (); - gr_float_to_short (); + friend GR_CORE_API + gr_float_to_short_sptr gr_make_float_to_short (size_t vlen, float scale); + gr_float_to_short (size_t vlen, float scale); + + size_t d_vlen; + float d_scale; public: + float scale() const; + void set_scale(float scale); + virtual int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.i b/gnuradio-core/src/lib/general/gr_float_to_short.i index ad059c453..8da733054 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.i +++ b/gnuradio-core/src/lib/general/gr_float_to_short.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,9 +22,13 @@ GR_SWIG_BLOCK_MAGIC(gr,float_to_short) -gr_float_to_short_sptr gr_make_float_to_short (); +gr_float_to_short_sptr +gr_make_float_to_short (size_t vlen=1, float scale=1); class gr_float_to_short : public gr_sync_block { - gr_float_to_short (); +public: + float scale() const; + void set_scale(float scale); + gr_float_to_short (size_t vlen, float scale); }; -- cgit From 9009ceb57a9eef4623216aa945cb0c4173c0ee2e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 28 Jan 2012 15:08:26 -0500 Subject: core: minor tweaks to float_to_X --- gnuradio-core/src/lib/general/gr_float_to_char.cc | 1 - gnuradio-core/src/lib/general/gr_float_to_char.i | 1 - gnuradio-core/src/lib/general/gr_float_to_int.cc | 1 - gnuradio-core/src/lib/general/gr_float_to_int.i | 1 - gnuradio-core/src/lib/general/gr_float_to_short.cc | 1 - gnuradio-core/src/lib/general/gr_float_to_short.i | 1 - 6 files changed, 6 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.cc b/gnuradio-core/src/lib/general/gr_float_to_char.cc index 165172ac6..14635ff71 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_char.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_char.cc @@ -26,7 +26,6 @@ #include #include -#include #include gr_float_to_char_sptr diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.i b/gnuradio-core/src/lib/general/gr_float_to_char.i index 05939f1b1..a1c88750f 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_char.i +++ b/gnuradio-core/src/lib/general/gr_float_to_char.i @@ -30,5 +30,4 @@ class gr_float_to_char : public gr_sync_block public: float scale() const; void set_scale(float scale); - gr_float_to_char (size_t vlen, float scale); }; diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.cc b/gnuradio-core/src/lib/general/gr_float_to_int.cc index c4d9991af..28214538f 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_int.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_int.cc @@ -26,7 +26,6 @@ #include #include -#include #include gr_float_to_int_sptr diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.i b/gnuradio-core/src/lib/general/gr_float_to_int.i index a0b52a3c1..6e71f54a9 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_int.i +++ b/gnuradio-core/src/lib/general/gr_float_to_int.i @@ -30,5 +30,4 @@ class gr_float_to_int : public gr_sync_block public: float scale() const; void set_scale(float scale); - gr_float_to_int (size_t vlen, float scale); }; diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.cc b/gnuradio-core/src/lib/general/gr_float_to_short.cc index e6ac5c184..188bfdae3 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_short.cc @@ -26,7 +26,6 @@ #include #include -#include #include gr_float_to_short_sptr diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.i b/gnuradio-core/src/lib/general/gr_float_to_short.i index 8da733054..072da5213 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.i +++ b/gnuradio-core/src/lib/general/gr_float_to_short.i @@ -30,5 +30,4 @@ class gr_float_to_short : public gr_sync_block public: float scale() const; void set_scale(float scale); - gr_float_to_short (size_t vlen, float scale); }; -- cgit From c05a75d0e1d28fe2c229a9a93ef42828929999b4 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 28 Jan 2012 15:09:44 -0500 Subject: core: short_to_X: adding short_to_char block using Volk; made Volk version of short_to_float. --- gnuradio-core/src/lib/general/gr_short_to_char.cc | 67 ++++++++++++++++++++++ gnuradio-core/src/lib/general/gr_short_to_char.h | 56 ++++++++++++++++++ gnuradio-core/src/lib/general/gr_short_to_char.i | 30 ++++++++++ gnuradio-core/src/lib/general/gr_short_to_float.cc | 41 ++++++++++--- gnuradio-core/src/lib/general/gr_short_to_float.h | 18 ++++-- gnuradio-core/src/lib/general/gr_short_to_float.i | 9 ++- 6 files changed, 206 insertions(+), 15 deletions(-) create mode 100644 gnuradio-core/src/lib/general/gr_short_to_char.cc create mode 100644 gnuradio-core/src/lib/general/gr_short_to_char.h create mode 100644 gnuradio-core/src/lib/general/gr_short_to_char.i (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.cc b/gnuradio-core/src/lib/general/gr_short_to_char.cc new file mode 100644 index 000000000..a3c096e6d --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_short_to_char.cc @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,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 +#include +#include + +gr_short_to_char_sptr +gr_make_short_to_char (size_t vlen) +{ + return gnuradio::get_initial_sptr(new gr_short_to_char (vlen)); +} + +gr_short_to_char::gr_short_to_char (size_t vlen) + : gr_sync_block ("gr_short_to_char", + gr_make_io_signature (1, 1, sizeof (short)*vlen), + gr_make_io_signature (1, 1, sizeof (char)*vlen)), + d_vlen(vlen) +{ + const int alignment_multiple = + volk_get_alignment() / sizeof(char); + set_alignment(alignment_multiple); +} + +int +gr_short_to_char::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const int16_t *in = (const int16_t *) input_items[0]; + int8_t *out = (int8_t *) output_items[0]; + + if(is_unaligned()) { + volk_16i_convert_8i_u(out, in, d_vlen*noutput_items); + } + else { + volk_16i_convert_8i_a(out, in, d_vlen*noutput_items); + } + + return noutput_items; +} + + + diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.h b/gnuradio-core/src/lib/general/gr_short_to_char.h new file mode 100644 index 000000000..9682d86ec --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_short_to_char.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,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_SHORT_TO_CHAR_H +#define INCLUDED_GR_SHORT_TO_CHAR_H + +#include +#include + +class gr_short_to_char; +typedef boost::shared_ptr gr_short_to_char_sptr; + +GR_CORE_API gr_short_to_char_sptr +gr_make_short_to_char (size_t vlen=1); + +/*! + * \brief Convert stream of short to a stream of float + * \ingroup converter_blk + */ + +class GR_CORE_API gr_short_to_char : public gr_sync_block +{ + private: + friend GR_CORE_API gr_short_to_char_sptr + gr_make_short_to_char (size_t vlen); + gr_short_to_char (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_SHORT_TO_CHAR_H */ diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.i b/gnuradio-core/src/lib/general/gr_short_to_char.i new file mode 100644 index 000000000..8fa453a06 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_short_to_char.i @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,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,short_to_char) + +gr_short_to_char_sptr gr_make_short_to_char (size_t vlen=1); + +class gr_short_to_char : public gr_sync_block +{ + +}; diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.cc b/gnuradio-core/src/lib/general/gr_short_to_float.cc index 7b80953ac..d11618414 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_float.cc +++ b/gnuradio-core/src/lib/general/gr_short_to_float.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010 Free Software Foundation, Inc. + * Copyright 2004,2010,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -27,18 +27,35 @@ #include #include #include +#include gr_short_to_float_sptr -gr_make_short_to_float () +gr_make_short_to_float (size_t vlen, float scale) { - return gnuradio::get_initial_sptr(new gr_short_to_float ()); + return gnuradio::get_initial_sptr(new gr_short_to_float (vlen, scale)); } -gr_short_to_float::gr_short_to_float () +gr_short_to_float::gr_short_to_float (size_t vlen, float scale) : gr_sync_block ("gr_short_to_float", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (1, 1, sizeof (float))) + gr_make_io_signature (1, 1, sizeof (short)*vlen), + gr_make_io_signature (1, 1, sizeof (float)*vlen)), + d_vlen(vlen), d_scale(scale) { + const int alignment_multiple = + volk_get_alignment() / sizeof(float); + set_alignment(alignment_multiple); +} + +float +gr_short_to_float::scale() const +{ + return d_scale; +} + +void +gr_short_to_float::set_scale(float scale) +{ + d_scale = scale; } int @@ -49,7 +66,17 @@ gr_short_to_float::work (int noutput_items, const short *in = (const short *) input_items[0]; float *out = (float *) output_items[0]; - gri_short_to_float (in, out, noutput_items); +#if 0 + if(is_unaligned()) { + volk_16i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items); + } + else { + float d_scale = 1.0; + volk_16i_s32f_convert_32f_a(out, in, d_scale, d_vlen*noutput_items); + } +#else + gri_short_to_float (in, out, d_vlen*noutput_items); +#endif return noutput_items; } diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.h b/gnuradio-core/src/lib/general/gr_short_to_float.h index b40c966ea..efdc81ecd 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_float.h +++ b/gnuradio-core/src/lib/general/gr_short_to_float.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ class gr_short_to_float; typedef boost::shared_ptr gr_short_to_float_sptr; GR_CORE_API gr_short_to_float_sptr -gr_make_short_to_float (); +gr_make_short_to_float (size_t vlen=1, float scale=1); /*! * \brief Convert stream of short to a stream of float @@ -39,10 +39,18 @@ gr_make_short_to_float (); class GR_CORE_API gr_short_to_float : public gr_sync_block { - friend GR_CORE_API gr_short_to_float_sptr gr_make_short_to_float (); - gr_short_to_float (); - + private: + friend GR_CORE_API gr_short_to_float_sptr + gr_make_short_to_float (size_t vlen, float scale); + gr_short_to_float (size_t vlen, float scale); + + size_t d_vlen; + float d_scale; + public: + float scale() const; + void set_scale(float scale); + virtual int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.i b/gnuradio-core/src/lib/general/gr_short_to_float.i index 56759df29..229618890 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_float.i +++ b/gnuradio-core/src/lib/general/gr_short_to_float.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,9 +22,12 @@ GR_SWIG_BLOCK_MAGIC(gr,short_to_float) -gr_short_to_float_sptr gr_make_short_to_float (); +gr_short_to_float_sptr +gr_make_short_to_float (size_t vlen=1, float scale=1); class gr_short_to_float : public gr_sync_block { - gr_short_to_float (); +public: + float scale() const; + void set_scale(float scale); }; -- cgit From 7943c197eccdb16e6c42af5544b9cb34a089b360 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 28 Jan 2012 15:11:17 -0500 Subject: core: cleanup short_to_float. --- gnuradio-core/src/lib/general/gr_short_to_float.cc | 6 ------ 1 file changed, 6 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.cc b/gnuradio-core/src/lib/general/gr_short_to_float.cc index d11618414..9f71f52ed 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_float.cc +++ b/gnuradio-core/src/lib/general/gr_short_to_float.cc @@ -26,7 +26,6 @@ #include #include -#include #include gr_short_to_float_sptr @@ -66,17 +65,12 @@ gr_short_to_float::work (int noutput_items, const short *in = (const short *) input_items[0]; float *out = (float *) output_items[0]; -#if 0 if(is_unaligned()) { volk_16i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items); } else { - float d_scale = 1.0; volk_16i_s32f_convert_32f_a(out, in, d_scale, d_vlen*noutput_items); } -#else - gri_short_to_float (in, out, d_vlen*noutput_items); -#endif return noutput_items; } -- cgit From f63927a46517ea9c7e914feb9177896219b33a0d Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 28 Jan 2012 19:25:04 -0500 Subject: core: more conversion work to Volk for type converters. --- gnuradio-core/src/lib/general/gr_char_to_float.cc | 39 ++++++++++++++++------ gnuradio-core/src/lib/general/gr_char_to_float.h | 14 ++++++-- gnuradio-core/src/lib/general/gr_char_to_float.i | 7 ++-- gnuradio-core/src/lib/general/gr_int_to_float.cc | 30 ++++++++++++----- gnuradio-core/src/lib/general/gr_int_to_float.h | 16 ++++++--- gnuradio-core/src/lib/general/gr_int_to_float.i | 8 +++-- gnuradio-core/src/lib/general/gr_short_to_char.i | 3 +- gnuradio-core/src/lib/general/gr_short_to_float.cc | 1 - 8 files changed, 85 insertions(+), 33 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.cc b/gnuradio-core/src/lib/general/gr_char_to_float.cc index e68f8d208..ffe8ee4a1 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_float.cc +++ b/gnuradio-core/src/lib/general/gr_char_to_float.cc @@ -26,30 +26,47 @@ #include #include -#include +#include gr_char_to_float_sptr -gr_make_char_to_float () +gr_make_char_to_float (size_t vlen, float scale) { - return gnuradio::get_initial_sptr(new gr_char_to_float ()); + return gnuradio::get_initial_sptr(new gr_char_to_float (vlen, scale)); } -gr_char_to_float::gr_char_to_float () +gr_char_to_float::gr_char_to_float (size_t vlen, float scale) : gr_sync_block ("gr_char_to_float", - gr_make_io_signature (1, 1, sizeof (char)), - gr_make_io_signature (1, 1, sizeof (float))) + gr_make_io_signature (1, 1, sizeof (char)*vlen), + gr_make_io_signature (1, 1, sizeof (float)*vlen)), + d_vlen(vlen), d_scale(scale) { + const int alignment_multiple = + volk_get_alignment() / sizeof(float); + set_alignment(alignment_multiple); +} + +float +gr_char_to_float::scale() const +{ + return d_scale; +} + +void +gr_char_to_float::set_scale(float scale) +{ + d_scale = scale; } int gr_char_to_float::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { - const char *in = (const char *) input_items[0]; + const int8_t *in = (const int8_t *) input_items[0]; float *out = (float *) output_items[0]; - gri_char_to_float (in, out, noutput_items); - + // Note: the unaligned benchmarked much faster than the aligned + volk_8i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items); + return noutput_items; } diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.h b/gnuradio-core/src/lib/general/gr_char_to_float.h index b20d2066f..4ad8e59a8 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_float.h +++ b/gnuradio-core/src/lib/general/gr_char_to_float.h @@ -30,7 +30,7 @@ class gr_char_to_float; typedef boost::shared_ptr gr_char_to_float_sptr; GR_CORE_API gr_char_to_float_sptr -gr_make_char_to_float (); +gr_make_char_to_float (size_t vlen=1, float scale=1); /*! * \brief Convert stream of chars to a stream of float @@ -39,10 +39,18 @@ gr_make_char_to_float (); class GR_CORE_API gr_char_to_float : public gr_sync_block { - friend GR_CORE_API gr_char_to_float_sptr gr_make_char_to_float (); - gr_char_to_float (); + private: + friend GR_CORE_API gr_char_to_float_sptr + gr_make_char_to_float (size_t vlen, float scale); + gr_char_to_float (size_t vlen, float scale); + + size_t d_vlen; + float d_scale; public: + float scale() const; + void set_scale(float scale); + virtual int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.i b/gnuradio-core/src/lib/general/gr_char_to_float.i index 0403b621d..65ad861f2 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_float.i +++ b/gnuradio-core/src/lib/general/gr_char_to_float.i @@ -22,9 +22,12 @@ GR_SWIG_BLOCK_MAGIC(gr,char_to_float) -gr_char_to_float_sptr gr_make_char_to_float (); +gr_char_to_float_sptr +gr_make_char_to_float (size_t vlen=1, float scale=1); class gr_char_to_float : public gr_sync_block { - gr_char_to_float (); +public: + float scale() const; + void set_scale(float scale); }; 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 29ca22add..dca0e1b89 100644 --- a/gnuradio-core/src/lib/general/gr_int_to_float.cc +++ b/gnuradio-core/src/lib/general/gr_int_to_float.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2011 Free Software Foundation, Inc. + * Copyright 2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -27,18 +27,23 @@ #include #include #include +#include gr_int_to_float_sptr -gr_make_int_to_float () +gr_make_int_to_float (size_t vlen, float scale) { - return gnuradio::get_initial_sptr(new gr_int_to_float ()); + return gnuradio::get_initial_sptr(new gr_int_to_float (vlen, scale)); } -gr_int_to_float::gr_int_to_float () +gr_int_to_float::gr_int_to_float (size_t vlen, float scale) : gr_sync_block ("gr_int_to_float", - gr_make_io_signature (1, 1, sizeof (int32_t)), - gr_make_io_signature (1, 1, sizeof (float))) + gr_make_io_signature (1, 1, sizeof (int32_t)*vlen), + gr_make_io_signature (1, 1, sizeof (float)*vlen)), + d_vlen(vlen), d_scale(scale) { + const int alignment_multiple = + volk_get_alignment() / sizeof(float); + set_alignment(alignment_multiple); } int @@ -48,8 +53,17 @@ gr_int_to_float::work (int noutput_items, { const int32_t *in = (const int32_t *) input_items[0]; float *out = (float *) output_items[0]; - - gri_int_to_float(in, out, noutput_items); + +#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_int_to_float.h b/gnuradio-core/src/lib/general/gr_int_to_float.h index 9af381ba9..af6488a50 100644 --- a/gnuradio-core/src/lib/general/gr_int_to_float.h +++ b/gnuradio-core/src/lib/general/gr_int_to_float.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2011 Free Software Foundation, Inc. + * Copyright 2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ class gr_int_to_float; typedef boost::shared_ptr gr_int_to_float_sptr; GR_CORE_API gr_int_to_float_sptr -gr_make_int_to_float (); +gr_make_int_to_float (size_t vlen=1, float scale=1); /*! * \brief Convert stream of int to a stream of float @@ -39,10 +39,18 @@ gr_make_int_to_float (); class GR_CORE_API gr_int_to_float : public gr_sync_block { - friend GR_CORE_API gr_int_to_float_sptr gr_make_int_to_float (); - gr_int_to_float (); + private: + friend GR_CORE_API gr_int_to_float_sptr + gr_make_int_to_float (size_t vlen, float scale); + gr_int_to_float (size_t vlen, float scale); + + size_t d_vlen; + float d_scale; public: + float scale() const; + void set_scale(float scale); + virtual int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.i b/gnuradio-core/src/lib/general/gr_int_to_float.i index 8cb9e35b5..c1f25e37b 100644 --- a/gnuradio-core/src/lib/general/gr_int_to_float.i +++ b/gnuradio-core/src/lib/general/gr_int_to_float.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2011 Free Software Foundation, Inc. + * Copyright 2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,9 +22,11 @@ GR_SWIG_BLOCK_MAGIC(gr,int_to_float) -gr_int_to_float_sptr gr_make_int_to_float (); +gr_int_to_float_sptr +gr_make_int_to_float (size_t vlen=1, float scale=1); class gr_int_to_float : public gr_sync_block { - gr_int_to_float (); + float scale() const; + void set_scale(float scale); }; diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.i b/gnuradio-core/src/lib/general/gr_short_to_char.i index 8fa453a06..330a4fdda 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_char.i +++ b/gnuradio-core/src/lib/general/gr_short_to_char.i @@ -22,7 +22,8 @@ GR_SWIG_BLOCK_MAGIC(gr,short_to_char) -gr_short_to_char_sptr gr_make_short_to_char (size_t vlen=1); +gr_short_to_char_sptr +gr_make_short_to_char (size_t vlen=1); class gr_short_to_char : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.cc b/gnuradio-core/src/lib/general/gr_short_to_float.cc index 9f71f52ed..94d376a27 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_float.cc +++ b/gnuradio-core/src/lib/general/gr_short_to_float.cc @@ -71,7 +71,6 @@ gr_short_to_float::work (int noutput_items, else { volk_16i_s32f_convert_32f_a(out, in, d_scale, d_vlen*noutput_items); } - return noutput_items; } -- cgit From f6075ca94945510eddc5581b552f5e61ce1d0c46 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 28 Jan 2012 19:25:41 -0500 Subject: core: more type converters in Volk; adding char_to_short converter. --- gnuradio-core/src/lib/general/CMakeLists.txt | 3 ++ gnuradio-core/src/lib/general/Makefile.am | 2 + gnuradio-core/src/lib/general/general.i | 6 +++ gnuradio-core/src/lib/general/gr_char_to_short.cc | 64 +++++++++++++++++++++++ gnuradio-core/src/lib/general/gr_char_to_short.h | 55 +++++++++++++++++++ gnuradio-core/src/lib/general/gr_char_to_short.i | 30 +++++++++++ 6 files changed, 160 insertions(+) create mode 100644 gnuradio-core/src/lib/general/gr_char_to_short.cc create mode 100644 gnuradio-core/src/lib/general/gr_char_to_short.h create mode 100644 gnuradio-core/src/lib/general/gr_char_to_short.i (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index 6ecaa930a..6635abc8d 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -187,6 +187,7 @@ set(gr_core_general_triple_threats gr_bin_statistics_f gr_bytes_to_syms gr_char_to_float + gr_char_to_short gr_check_counting_s gr_check_lfsr_32k_s gr_complex_to_interleaved_short @@ -229,6 +230,7 @@ set(gr_core_general_triple_threats gr_kludge_copy gr_lfsr_32k_source_s gr_map_bb + gr_multiply_cc gr_nlog10_ff gr_nop gr_null_sink @@ -256,6 +258,7 @@ set(gr_core_general_triple_threats gr_rms_ff gr_repeat gr_short_to_float + gr_short_to_char gr_simple_correlator gr_simple_framer gr_simple_squelch_cc diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index 0122932cf..1b802b09c 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -46,6 +46,7 @@ libgeneral_la_SOURCES = \ gr_bin_statistics_f.cc \ gr_bytes_to_syms.cc \ gr_char_to_float.cc \ + gr_char_to_short.cc \ gr_check_counting_s.cc \ gr_check_lfsr_32k_s.cc \ gr_circular_file.cc \ @@ -123,6 +124,7 @@ libgeneral_la_SOURCES = \ gr_rms_cf.cc \ gr_rms_ff.cc \ gr_short_to_float.cc \ + gr_short_to_int.cc \ gr_int_to_float.cc \ gr_simple_correlator.cc \ gr_simple_framer.cc \ diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 5a701bf80..ec90e40e5 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -44,8 +44,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -104,6 +106,7 @@ #include #include #include +#include #include #include #include @@ -158,8 +161,10 @@ %include "gr_float_to_char.i" %include "gr_float_to_uchar.i" %include "gr_short_to_float.i" +%include "gr_short_to_char.i" %include "gr_int_to_float.i" %include "gr_char_to_float.i" +%include "gr_char_to_short.i" %include "gr_uchar_to_float.i" %include "gr_frequency_modulator_fc.i" %include "gr_phase_modulator_fc.i" @@ -218,6 +223,7 @@ %include "gr_diff_decoder_bb.i" %include "gr_framer_sink_1.i" %include "gr_map_bb.i" +%include "gr_multiply_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_char_to_short.cc b/gnuradio-core/src/lib/general/gr_char_to_short.cc new file mode 100644 index 000000000..40ffa9338 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_char_to_short.cc @@ -0,0 +1,64 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,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 +#include +#include + +gr_char_to_short_sptr +gr_make_char_to_short (size_t vlen) +{ + return gnuradio::get_initial_sptr(new gr_char_to_short (vlen)); +} + +gr_char_to_short::gr_char_to_short (size_t vlen) + : gr_sync_block ("gr_char_to_short", + gr_make_io_signature (1, 1, sizeof (char)*vlen), + gr_make_io_signature (1, 1, sizeof (short)*vlen)), + d_vlen(vlen) +{ + const int alignment_multiple = + volk_get_alignment() / sizeof(float); + set_alignment(alignment_multiple); +} + +int +gr_char_to_short::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const int8_t *in = (const int8_t *) input_items[0]; + int16_t *out = (int16_t *) output_items[0]; + + if(is_unaligned()) { + volk_8i_convert_16i_u(out, in, d_vlen*noutput_items); + } + else { + volk_8i_convert_16i_a(out, in, d_vlen*noutput_items); + } + + return noutput_items; +} diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.h b/gnuradio-core/src/lib/general/gr_char_to_short.h new file mode 100644 index 000000000..8ed974acf --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_char_to_short.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,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_CHAR_TO_SHORT_H +#define INCLUDED_GR_CHAR_TO_SHORT_H + +#include +#include + +class gr_char_to_short; +typedef boost::shared_ptr gr_char_to_short_sptr; + +GR_CORE_API gr_char_to_short_sptr +gr_make_char_to_short (size_t vlen=1); + +/*! + * \brief Convert stream of chars to a stream of float + * \ingroup converter_blk + */ + +class GR_CORE_API gr_char_to_short : public gr_sync_block +{ + friend GR_CORE_API gr_char_to_short_sptr + gr_make_char_to_short (size_t vlen); + gr_char_to_short (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_CHAR_TO_SHORT_H */ diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.i b/gnuradio-core/src/lib/general/gr_char_to_short.i new file mode 100644 index 000000000..48ddbf26b --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_char_to_short.i @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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,char_to_short) + +gr_char_to_short_sptr gr_make_char_to_short (size_t vlen=1); + +class gr_char_to_short : public gr_sync_block +{ + +}; -- cgit From 7ecd13dbeebb5083d309b2a74d158bb1bb26066e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 28 Jan 2012 19:29:45 -0500 Subject: core: update Makefile.am for new type converters. --- gnuradio-core/src/lib/general/CMakeLists.txt | 2 +- gnuradio-core/src/lib/general/Makefile.am | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index 6635abc8d..6dc9d411d 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. +# Copyright 2010-2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index 1b802b09c..65b5a729e 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2001,2002,2004,2006,2007,2008,2009 Free Software Foundation, Inc. +# Copyright 2001,2002,2004,2006-2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -197,6 +197,7 @@ grinclude_HEADERS = \ gr_bin_statistics_f.h \ gr_bytes_to_syms.h \ gr_char_to_float.h \ + gr_char_to_short.h \ gr_check_counting_s.h \ gr_check_lfsr_32k_s.h \ gr_circular_file.h \ @@ -278,6 +279,7 @@ grinclude_HEADERS = \ gr_reverse.h \ gr_rms_cf.h \ gr_rms_ff.h \ + gr_short_to_char.h \ gr_short_to_float.h \ gr_int_to_float.h \ gr_simple_correlator.h \ @@ -325,7 +327,7 @@ grinclude_HEADERS = \ gri_int_to_float.h \ gri_lfsr_15_1_0.h \ gri_lfsr_32k.h \ - gri_short_to_float.h \ + gri_short_to_char.h \ gri_uchar_to_float.h \ malloc16.h \ random.h \ @@ -363,6 +365,7 @@ swiginclude_HEADERS = \ gr_bin_statistics_f.i \ gr_bytes_to_syms.i \ gr_char_to_float.i \ + gr_char_to_short.i \ gr_check_counting_s.i \ gr_check_lfsr_32k_s.i \ gr_complex_to_interleaved_short.i \ @@ -432,6 +435,7 @@ swiginclude_HEADERS = \ gr_rms_cf.i \ gr_rms_ff.i \ gr_repeat.i \ + gr_short_to_char.i \ gr_short_to_float.i \ gr_simple_correlator.i \ gr_simple_framer.i \ -- cgit From 812144f4c153dca385b65e79401c9f1d88b90173 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 29 Jan 2012 17:34:06 -0500 Subject: core: switched complex to mag and mag_squared to use Volk functions. --- gnuradio-core/src/lib/general/gr_complex_to_xxx.cc | 25 +++++++++++++++------- gnuradio-core/src/lib/general/gr_complex_to_xxx.h | 5 +++-- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'gnuradio-core/src/lib/general') 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 #include #include +#include // ---------------------------------------------------------------- @@ -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, -- cgit From 83d0bf5d513e516d700e552fa2773dd852a6608a Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 29 Jan 2012 17:35:09 -0500 Subject: core: minor edits. --- gnuradio-core/src/lib/general/gr_char_to_short.h | 1 + 1 file changed, 1 insertion(+) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.h b/gnuradio-core/src/lib/general/gr_char_to_short.h index 8ed974acf..58f9a62b0 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_short.h +++ b/gnuradio-core/src/lib/general/gr_char_to_short.h @@ -39,6 +39,7 @@ gr_make_char_to_short (size_t vlen=1); class GR_CORE_API gr_char_to_short : public gr_sync_block { + private: friend GR_CORE_API gr_char_to_short_sptr gr_make_char_to_short (size_t vlen); gr_char_to_short (size_t vlen); -- cgit From 4769d5ff75520661ce52fae229482a96e651f7e2 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 30 Jan 2012 00:23:11 -0500 Subject: core: complex_to_xxx (float, real, imag, arg) to volk. --- gnuradio-core/src/lib/general/gr_complex_to_xxx.cc | 60 +++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'gnuradio-core/src/lib/general') 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 0bdd06547..9ed86f368 100644 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc +++ b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc @@ -57,17 +57,41 @@ gr_complex_to_float::work (int noutput_items, switch (output_items.size ()){ case 1: +#if 1 + if(is_unaligned()) { + for (int i = 0; i < noi; i++){ + out0[i] = in[i].real (); + } + } + else { + volk_32fc_deinterleave_real_32f_a(out0, in, noi); + } +#else for (int i = 0; i < noi; i++){ out0[i] = in[i].real (); } +#endif break; case 2: +#if 1 + out1 = (float *) output_items[1]; + if(is_unaligned()) { + for (int i = 0; i < noi; i++){ + out0[i] = in[i].real (); + out1[i] = in[i].imag (); + } + } + else { + volk_32fc_deinterleave_32f_x2_a(out0, out1, in, noi); + } +#else out1 = (float *) output_items[1]; for (int i = 0; i < noi; i++){ out0[i] = in[i].real (); out1[i] = in[i].imag (); } +#endif break; default: @@ -102,9 +126,21 @@ gr_complex_to_real::work (int noutput_items, float *out = (float *) output_items[0]; int noi = noutput_items * d_vlen; +#if 1 + if(is_unaligned()) { + for (int i = 0; i < noi; i++){ + out[i] = in[i].real (); + } + } + else { + volk_32fc_deinterleave_real_32f_a(out, in, noi); + } +#else for (int i = 0; i < noi; i++){ - out[i] = in[i].real (); + out0[i] = in[i].real (); } +#endif + return noutput_items; } @@ -133,9 +169,20 @@ gr_complex_to_imag::work (int noutput_items, float *out = (float *) output_items[0]; int noi = noutput_items * d_vlen; +#if 1 + if(is_unaligned()) { + for (int i = 0; i < noi; i++){ + out[i] = in[i].imag (); + } + } + else { + volk_32fc_deinterleave_imag_32f_a(out, in, noi); + } +#else for (int i = 0; i < noi; i++){ out[i] = in[i].imag (); } +#endif return noutput_items; } @@ -236,9 +283,20 @@ gr_complex_to_arg::work (int noutput_items, float *out = (float *) output_items[0]; int noi = noutput_items * d_vlen; +#if 1 + if(is_unaligned()) { + for (int i = 0; i < noi; i++){ + out[i] = gr_fast_atan2f(in[i]); + } + } + else { + volk_32fc_s32f_atan2_32f_a(out, in, 1, noi); + } +#else for (int i = 0; i < noi; i++){ // out[i] = std::arg (in[i]); out[i] = gr_fast_atan2f(in[i]); } +#endif return noutput_items; } -- cgit From 046385126d92cf9179ac84ede06d3d50e1c9030f Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 30 Jan 2012 12:12:44 -0500 Subject: core: fixing up complex_to_xxx for using Volk where appropriate. Speed benchmark were used to decide which implementation to use. --- gnuradio-core/src/lib/general/gr_complex_to_xxx.cc | 54 +++++++--------------- 1 file changed, 16 insertions(+), 38 deletions(-) (limited to 'gnuradio-core/src/lib/general') 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 9ed86f368..108a92835 100644 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc +++ b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc @@ -43,6 +43,9 @@ gr_complex_to_float::gr_complex_to_float (unsigned int vlen) gr_make_io_signature (1, 2, sizeof (float) * vlen)), d_vlen(vlen) { + const int alignment_multiple = + volk_get_alignment() / sizeof(float); + set_alignment(alignment_multiple); } int @@ -57,7 +60,6 @@ gr_complex_to_float::work (int noutput_items, switch (output_items.size ()){ case 1: -#if 1 if(is_unaligned()) { for (int i = 0; i < noi; i++){ out0[i] = in[i].real (); @@ -66,15 +68,9 @@ gr_complex_to_float::work (int noutput_items, else { volk_32fc_deinterleave_real_32f_a(out0, in, noi); } -#else - for (int i = 0; i < noi; i++){ - out0[i] = in[i].real (); - } -#endif break; case 2: -#if 1 out1 = (float *) output_items[1]; if(is_unaligned()) { for (int i = 0; i < noi; i++){ @@ -85,13 +81,6 @@ gr_complex_to_float::work (int noutput_items, else { volk_32fc_deinterleave_32f_x2_a(out0, out1, in, noi); } -#else - out1 = (float *) output_items[1]; - for (int i = 0; i < noi; i++){ - out0[i] = in[i].real (); - out1[i] = in[i].imag (); - } -#endif break; default: @@ -115,6 +104,9 @@ gr_complex_to_real::gr_complex_to_real (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 @@ -126,7 +118,6 @@ gr_complex_to_real::work (int noutput_items, float *out = (float *) output_items[0]; int noi = noutput_items * d_vlen; -#if 1 if(is_unaligned()) { for (int i = 0; i < noi; i++){ out[i] = in[i].real (); @@ -135,11 +126,6 @@ gr_complex_to_real::work (int noutput_items, else { volk_32fc_deinterleave_real_32f_a(out, in, noi); } -#else - for (int i = 0; i < noi; i++){ - out0[i] = in[i].real (); - } -#endif return noutput_items; } @@ -158,6 +144,9 @@ gr_complex_to_imag::gr_complex_to_imag (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 @@ -169,7 +158,6 @@ gr_complex_to_imag::work (int noutput_items, float *out = (float *) output_items[0]; int noi = noutput_items * d_vlen; -#if 1 if(is_unaligned()) { for (int i = 0; i < noi; i++){ out[i] = in[i].imag (); @@ -178,11 +166,7 @@ gr_complex_to_imag::work (int noutput_items, else { volk_32fc_deinterleave_imag_32f_a(out, in, noi); } -#else - for (int i = 0; i < noi; i++){ - out[i] = in[i].imag (); - } -#endif + return noutput_items; } @@ -248,7 +232,7 @@ gr_complex_to_mag_squared::work (int noutput_items, float *out = (float *) output_items[0]; int noi = noutput_items * d_vlen; - if(unaligned()) { + if(is_unaligned()) { volk_32fc_magnitude_squared_32f_u(out, in, noi); } else { @@ -272,6 +256,9 @@ gr_complex_to_arg::gr_complex_to_arg (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 @@ -283,20 +270,11 @@ gr_complex_to_arg::work (int noutput_items, float *out = (float *) output_items[0]; int noi = noutput_items * d_vlen; -#if 1 - if(is_unaligned()) { - for (int i = 0; i < noi; i++){ - out[i] = gr_fast_atan2f(in[i]); - } - } - else { - volk_32fc_s32f_atan2_32f_a(out, in, 1, noi); - } -#else + // The fast_atan2f is faster than Volk for (int i = 0; i < noi; i++){ // out[i] = std::arg (in[i]); out[i] = gr_fast_atan2f(in[i]); } -#endif + return noutput_items; } -- cgit From e8089db25b2e28824f11d27c9d98a4adef191736 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 2 Feb 2012 16:36:47 -0500 Subject: core: moving multiply_cc and multiply_const_cc out of gengen and into general so they can make use of volk calls. QA code now explicitly tests the cc versions of these blocks. --- gnuradio-core/src/lib/general/.gitignore | 6 -- gnuradio-core/src/lib/general/CMakeLists.txt | 1 + gnuradio-core/src/lib/general/general.i | 2 + gnuradio-core/src/lib/general/gr_multiply_cc.cc | 69 ++++++++++++++++++ gnuradio-core/src/lib/general/gr_multiply_cc.h | 56 +++++++++++++++ gnuradio-core/src/lib/general/gr_multiply_cc.i | 32 +++++++++ .../src/lib/general/gr_multiply_const_cc.cc | 82 ++++++++++++++++++++++ .../src/lib/general/gr_multiply_const_cc.h | 60 ++++++++++++++++ .../src/lib/general/gr_multiply_const_cc.i | 33 +++++++++ 9 files changed, 335 insertions(+), 6 deletions(-) create mode 100644 gnuradio-core/src/lib/general/gr_multiply_cc.cc create mode 100644 gnuradio-core/src/lib/general/gr_multiply_cc.h create mode 100644 gnuradio-core/src/lib/general/gr_multiply_cc.i create mode 100644 gnuradio-core/src/lib/general/gr_multiply_const_cc.cc create mode 100644 gnuradio-core/src/lib/general/gr_multiply_const_cc.h create mode 100644 gnuradio-core/src/lib/general/gr_multiply_const_cc.i (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/.gitignore b/gnuradio-core/src/lib/general/.gitignore index 4f3696f58..349651e0c 100644 --- a/gnuradio-core/src/lib/general/.gitignore +++ b/gnuradio-core/src/lib/general/.gitignore @@ -158,12 +158,6 @@ /gr_divide_ss.cc /gr_divide_ss.h /gr_divide_ss.i -/gr_multiply_cc.cc -/gr_multiply_cc.h -/gr_multiply_cc.i -/gr_multiply_const_cc.cc -/gr_multiply_const_cc.h -/gr_multiply_const_cc.i /gr_multiply_const_ff.cc /gr_multiply_const_ff.h /gr_multiply_const_ff.i diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index 6dc9d411d..6afdfe27c 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -231,6 +231,7 @@ set(gr_core_general_triple_threats gr_lfsr_32k_source_s gr_map_bb gr_multiply_cc + gr_multiply_const_cc gr_nlog10_ff gr_nop gr_null_sink diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index ec90e40e5..7de13258e 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -107,6 +107,7 @@ #include #include #include +#include #include #include #include @@ -224,6 +225,7 @@ %include "gr_framer_sink_1.i" %include "gr_map_bb.i" %include "gr_multiply_cc.i" +%include "gr_multiply_const_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_multiply_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_cc.cc new file mode 100644 index 000000000..0d20e6257 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_multiply_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 +#include +#include + +gr_multiply_cc_sptr +gr_make_multiply_cc (size_t vlen) +{ + return gnuradio::get_initial_sptr(new gr_multiply_cc (vlen)); +} + +gr_multiply_cc::gr_multiply_cc (size_t vlen) + : gr_sync_block ("gr_multiply_cc", + gr_make_io_signature (1, -1, 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_cc::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + gr_complex *out = (gr_complex *) output_items[0]; + int noi = d_vlen*noutput_items; + + memcpy(out, input_items[0], noi*sizeof(gr_complex)); + if(is_unaligned()) { + for(size_t i = 1; i < input_items.size(); i++) + volk_32fc_x2_multiply_32fc_u(out, out, (gr_complex*)input_items[i], noi); + } + else { + for(size_t i = 1; i < input_items.size(); i++) + volk_32fc_x2_multiply_32fc_a(out, out, (gr_complex*)input_items[i], noi); + } + return noutput_items; +} + + + diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.h b/gnuradio-core/src/lib/general/gr_multiply_cc.h new file mode 100644 index 000000000..f80ec8b25 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_multiply_cc.h @@ -0,0 +1,56 @@ +/* -*- 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_CC_H +#define INCLUDED_GR_MULTIPLY_CC_H + +#include +#include + +class gr_multiply_cc; +typedef boost::shared_ptr gr_multiply_cc_sptr; + +GR_CORE_API gr_multiply_cc_sptr +gr_make_multiply_cc (size_t vlen=1); + +/*! + * \brief Multiply streams of complex values + * \ingroup math_blk + */ + +class GR_CORE_API gr_multiply_cc : public gr_sync_block +{ + private: + friend GR_CORE_API gr_multiply_cc_sptr + gr_make_multiply_cc (size_t vlen); + gr_multiply_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_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.i b/gnuradio-core/src/lib/general/gr_multiply_cc.i new file mode 100644 index 000000000..61768c390 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_multiply_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_cc) + +gr_multiply_cc_sptr +gr_make_multiply_cc (size_t vlen=1); + +class gr_multiply_cc : public gr_sync_block +{ +public: + +}; diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc new file mode 100644 index 000000000..e301ae8eb --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc @@ -0,0 +1,82 @@ +/* -*- 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 +#include +#include + +gr_multiply_const_cc_sptr +gr_make_multiply_const_cc (gr_complex k, size_t vlen) +{ + return gnuradio::get_initial_sptr(new gr_multiply_const_cc (k, vlen)); +} + +gr_multiply_const_cc::gr_multiply_const_cc (gr_complex k, size_t vlen) + : gr_sync_block ("gr_multiply_const_cc", + gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen), + gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)), + d_k(k), d_vlen(vlen) +{ + const int alignment_multiple = + volk_get_alignment() / sizeof(gr_complex); + set_alignment(alignment_multiple); +} + +gr_complex +gr_multiply_const_cc::k() const +{ + return d_k; +} + +void +gr_multiply_const_cc::set_k(gr_complex k) +{ + d_k = k; +} + +#include + +int +gr_multiply_const_cc::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const gr_complex *in = (const gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + int noi = d_vlen*noutput_items; + + if(is_unaligned()) { + volk_32fc_s32fc_multiply_32fc_u(out, in, d_k, noi); + } + else { + volk_32fc_s32fc_multiply_32fc_a(out, in, d_k, noi); + } + + return noutput_items; +} + + + diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.h b/gnuradio-core/src/lib/general/gr_multiply_const_cc.h new file mode 100644 index 000000000..1791d9160 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_multiply_const_cc.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_CC_H +#define INCLUDED_GR_MULTIPLY_CONST_CC_H + +#include +#include + +class gr_multiply_const_cc; +typedef boost::shared_ptr gr_multiply_const_cc_sptr; + +GR_CORE_API gr_multiply_const_cc_sptr +gr_make_multiply_const_cc (gr_complex k, size_t vlen=1); + +/*! + * \brief Multiply stream of complex values with a constant \p k + * \ingroup math_blk + */ + +class GR_CORE_API gr_multiply_const_cc : public gr_sync_block +{ + private: + friend GR_CORE_API gr_multiply_const_cc_sptr + gr_make_multiply_const_cc (gr_complex k, size_t vlen); + gr_multiply_const_cc (gr_complex k, size_t vlen); + + gr_complex d_k; + size_t d_vlen; + + public: + gr_complex k() const; + void set_k(gr_complex 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_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.i b/gnuradio-core/src/lib/general/gr_multiply_const_cc.i new file mode 100644 index 000000000..be8d32b31 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_multiply_const_cc.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_cc) + +gr_multiply_const_cc_sptr +gr_make_multiply_const_cc (gr_complex k, size_t vlen=1); + +class gr_multiply_const_cc : public gr_sync_block +{ +public: + gr_complex k() const; + void set_k(gr_complex k); +}; -- cgit From a3b19015cb1c896aef19a7817458878337b3f5e3 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 2 Feb 2012 16:38:56 -0500 Subject: core: more fixes when moving files from gengen to general. --- gnuradio-core/src/lib/general/general_generated.i | 4 ---- 1 file changed, 4 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/general_generated.i b/gnuradio-core/src/lib/general/general_generated.i index a41f30a3d..847860f53 100644 --- a/gnuradio-core/src/lib/general/general_generated.i +++ b/gnuradio-core/src/lib/general/general_generated.i @@ -29,8 +29,6 @@ #include #include #include -#include -#include #include #include #include @@ -106,8 +104,6 @@ %include %include %include -%include -%include %include %include %include -- cgit From ae663decab658be25ac01072fa2f5c8454bd6167 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 2 Feb 2012 17:26:39 -0500 Subject: 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. --- gnuradio-core/src/lib/general/CMakeLists.txt | 1 + gnuradio-core/src/lib/general/Makefile.am | 9 +++ gnuradio-core/src/lib/general/general.i | 2 + gnuradio-core/src/lib/general/general_generated.i | 1 - gnuradio-core/src/lib/general/gr_int_to_float.cc | 7 +- .../src/lib/general/gr_multiply_const_cc.cc | 2 - .../src/lib/general/gr_multiply_const_ff.cc | 80 ++++++++++++++++++++++ .../src/lib/general/gr_multiply_const_ff.h | 60 ++++++++++++++++ .../src/lib/general/gr_multiply_const_ff.i | 33 +++++++++ 9 files changed, 186 insertions(+), 9 deletions(-) create mode 100644 gnuradio-core/src/lib/general/gr_multiply_const_ff.cc create mode 100644 gnuradio-core/src/lib/general/gr_multiply_const_ff.h create mode 100644 gnuradio-core/src/lib/general/gr_multiply_const_ff.i (limited to 'gnuradio-core/src/lib/general') 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 #include #include +#include #include #include #include @@ -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 #include #include -#include #include #include #include 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 #include -#include #include 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 - 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 +#include +#include + +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 +#include + +class gr_multiply_const_ff; +typedef boost::shared_ptr 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); +}; -- cgit From 47c390286d49e00498a3443a3dcb9f83d11c7ecc Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 4 Feb 2012 11:05:25 -0500 Subject: core: new multiply_const_ff and multiply_ff blocks done using Volk. --- gnuradio-core/src/lib/general/.gitignore | 6 -- gnuradio-core/src/lib/general/CMakeLists.txt | 1 + gnuradio-core/src/lib/general/Makefile.am | 3 + gnuradio-core/src/lib/general/general.i | 2 + gnuradio-core/src/lib/general/general_generated.i | 3 - gnuradio-core/src/lib/general/gr_multiply_ff.cc | 69 +++++++++++++++++++++++ gnuradio-core/src/lib/general/gr_multiply_ff.h | 56 ++++++++++++++++++ gnuradio-core/src/lib/general/gr_multiply_ff.i | 32 +++++++++++ 8 files changed, 163 insertions(+), 9 deletions(-) create mode 100644 gnuradio-core/src/lib/general/gr_multiply_ff.cc create mode 100644 gnuradio-core/src/lib/general/gr_multiply_ff.h create mode 100644 gnuradio-core/src/lib/general/gr_multiply_ff.i (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/.gitignore b/gnuradio-core/src/lib/general/.gitignore index 349651e0c..b04ffe4ae 100644 --- a/gnuradio-core/src/lib/general/.gitignore +++ b/gnuradio-core/src/lib/general/.gitignore @@ -158,18 +158,12 @@ /gr_divide_ss.cc /gr_divide_ss.h /gr_divide_ss.i -/gr_multiply_const_ff.cc -/gr_multiply_const_ff.h -/gr_multiply_const_ff.i /gr_multiply_const_ii.cc /gr_multiply_const_ii.h /gr_multiply_const_ii.i /gr_multiply_const_ss.cc /gr_multiply_const_ss.h /gr_multiply_const_ss.i -/gr_multiply_ff.cc -/gr_multiply_ff.h -/gr_multiply_ff.i /gr_multiply_ii.cc /gr_multiply_ii.h /gr_multiply_ii.i diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index 393f732b7..301465361 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -231,6 +231,7 @@ set(gr_core_general_triple_threats gr_lfsr_32k_source_s gr_map_bb gr_multiply_cc + gr_multiply_ff gr_multiply_const_cc gr_multiply_const_ff gr_nlog10_ff diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index 5a6f5bf46..b452a5107 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -95,6 +95,7 @@ libgeneral_la_SOURCES = \ gr_map_bb.cc \ gr_misc.cc \ gr_multiply_cc.cc \ + gr_multiply_ff.cc \ gr_multiply_const_cc.cc \ gr_multiply_const_ff.cc \ gr_nlog10_ff.cc \ @@ -253,6 +254,7 @@ grinclude_HEADERS = \ gr_math.h \ gr_misc.h \ gr_multiply_cc.h \ + gr_multiply_ff.h \ gr_multiply_const_cc.h \ gr_multiply_const_ff.h \ gr_nco.h \ @@ -415,6 +417,7 @@ swiginclude_HEADERS = \ gr_lfsr_32k_source_s.i \ gr_map_bb.i \ gr_multiply_cc.i \ + gr_multiply_ff.i \ gr_multiply_const_cc.i \ gr_multiply_const_ff.i \ gr_nlog10_ff.i \ diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index ac3fef84c..8e1be02f9 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -107,6 +107,7 @@ #include #include #include +#include #include #include #include @@ -226,6 +227,7 @@ %include "gr_framer_sink_1.i" %include "gr_map_bb.i" %include "gr_multiply_cc.i" +%include "gr_multiply_ff.i" %include "gr_multiply_const_cc.i" %include "gr_multiply_const_ff.i" %include "gr_feval.i" diff --git a/gnuradio-core/src/lib/general/general_generated.i b/gnuradio-core/src/lib/general/general_generated.i index 52e09f89b..82f9a6006 100644 --- a/gnuradio-core/src/lib/general/general_generated.i +++ b/gnuradio-core/src/lib/general/general_generated.i @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -103,14 +102,12 @@ %include %include %include -%include %include %include %include %include %include %include -%include %include %include %include diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.cc b/gnuradio-core/src/lib/general/gr_multiply_ff.cc new file mode 100644 index 000000000..a7d34ce51 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_multiply_ff.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 +#include +#include + +gr_multiply_ff_sptr +gr_make_multiply_ff (size_t vlen) +{ + return gnuradio::get_initial_sptr(new gr_multiply_ff (vlen)); +} + +gr_multiply_ff::gr_multiply_ff (size_t vlen) + : gr_sync_block ("gr_multiply_ff", + gr_make_io_signature (1, -1, sizeof (float)*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 +gr_multiply_ff::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + float *out = (float *) output_items[0]; + int noi = d_vlen*noutput_items; + + memcpy(out, input_items[0], noi*sizeof(float)); + if(is_unaligned()) { + for(size_t i = 1; i < input_items.size(); i++) + volk_32f_x2_multiply_32f_u(out, out, (const float*)input_items[i], noi); + } + else { + for(size_t i = 1; i < input_items.size(); i++) + volk_32f_x2_multiply_32f_a(out, out, (const float*)input_items[i], noi); + } + return noutput_items; +} + + + diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.h b/gnuradio-core/src/lib/general/gr_multiply_ff.h new file mode 100644 index 000000000..ae36cb1e0 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_multiply_ff.h @@ -0,0 +1,56 @@ +/* -*- 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_FF_H +#define INCLUDED_GR_MULTIPLY_FF_H + +#include +#include + +class gr_multiply_ff; +typedef boost::shared_ptr gr_multiply_ff_sptr; + +GR_CORE_API gr_multiply_ff_sptr +gr_make_multiply_ff (size_t vlen=1); + +/*! + * \brief Multiply streams of complex values + * \ingroup math_blk + */ + +class GR_CORE_API gr_multiply_ff : public gr_sync_block +{ + private: + friend GR_CORE_API gr_multiply_ff_sptr + gr_make_multiply_ff (size_t vlen); + gr_multiply_ff (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_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.i b/gnuradio-core/src/lib/general/gr_multiply_ff.i new file mode 100644 index 000000000..0f06301f2 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_multiply_ff.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_ff) + +gr_multiply_ff_sptr +gr_make_multiply_ff (size_t vlen=1); + +class gr_multiply_ff : public gr_sync_block +{ +public: + +}; -- cgit From fb2a84add9706a046b4761021707d6bb97496a2e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 6 Feb 2012 10:32:18 -0500 Subject: core: added volk version of add_ff. --- gnuradio-core/src/lib/general/.gitignore | 3 - gnuradio-core/src/lib/general/CMakeLists.txt | 1 + gnuradio-core/src/lib/general/Makefile.am | 3 + gnuradio-core/src/lib/general/general.i | 2 + gnuradio-core/src/lib/general/general_generated.i | 2 - gnuradio-core/src/lib/general/gr_add_ff.cc | 70 +++++++++++++++++++++++ gnuradio-core/src/lib/general/gr_add_ff.h | 56 ++++++++++++++++++ gnuradio-core/src/lib/general/gr_add_ff.i | 32 +++++++++++ 8 files changed, 164 insertions(+), 5 deletions(-) create mode 100644 gnuradio-core/src/lib/general/gr_add_ff.cc create mode 100644 gnuradio-core/src/lib/general/gr_add_ff.h create mode 100644 gnuradio-core/src/lib/general/gr_add_ff.i (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/.gitignore b/gnuradio-core/src/lib/general/.gitignore index b04ffe4ae..795dc793c 100644 --- a/gnuradio-core/src/lib/general/.gitignore +++ b/gnuradio-core/src/lib/general/.gitignore @@ -125,9 +125,6 @@ /gr_add_const_vss.cc /gr_add_const_vss.h /gr_add_const_vss.i -/gr_add_ff.cc -/gr_add_ff.h -/gr_add_ff.i /gr_add_ii.cc /gr_add_ii.h /gr_add_ii.i diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index 301465361..ab35aa66a 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -178,6 +178,7 @@ endif(ENABLE_PYTHON) ######################################################################## set(gr_core_general_triple_threats complex_vec_test + gr_add_ff gr_additive_scrambler_bb gr_agc_cc gr_agc_ff diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index b452a5107..89152d663 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -37,6 +37,7 @@ EXTRA_DIST += \ libgeneral_la_SOURCES = \ complex_vec_test.cc \ + gr_add_ff.cc \ gr_additive_scrambler_bb.cc \ gr_agc_cc.cc \ gr_agc_ff.cc \ @@ -192,6 +193,7 @@ libgeneral_qa_la_SOURCES = \ grinclude_HEADERS = \ gr_core_api.h \ complex_vec_test.h \ + gr_add.h \ gr_additive_scrambler_bb.h \ gr_agc_cc.h \ gr_agc_ff.h \ @@ -364,6 +366,7 @@ noinst_HEADERS = \ swiginclude_HEADERS = \ complex_vec_test.i \ general.i \ + gr_add.i \ gr_additive_scrambler_bb.i \ gr_agc_cc.i \ gr_agc_ff.i \ diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 8e1be02f9..c384ecfbb 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -140,6 +140,7 @@ #include #include #include +#include %} %include "gri_control_loop.i" @@ -260,3 +261,4 @@ %include "gr_burst_tagger.i" %include "gr_cpm.i" %include "gr_correlate_access_code_tag_bb.i" +%include "gr_add_ff.i" diff --git a/gnuradio-core/src/lib/general/general_generated.i b/gnuradio-core/src/lib/general/general_generated.i index 82f9a6006..e12f2b0ec 100644 --- a/gnuradio-core/src/lib/general/general_generated.i +++ b/gnuradio-core/src/lib/general/general_generated.i @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -85,7 +84,6 @@ %include %include %include -%include %include %include %include diff --git a/gnuradio-core/src/lib/general/gr_add_ff.cc b/gnuradio-core/src/lib/general/gr_add_ff.cc new file mode 100644 index 000000000..a5db5ec5c --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_add_ff.cc @@ -0,0 +1,70 @@ +/* -*- 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 +#include +#include + +gr_add_ff_sptr +gr_make_add_ff(size_t vlen) +{ + return gnuradio::get_initial_sptr(new gr_add_ff(vlen)); +} + +gr_add_ff::gr_add_ff (size_t vlen) + : gr_sync_block("add_ff", + gr_make_io_signature (1, -1, sizeof(float)*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 +gr_add_ff::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + float *out = (float *) output_items[0]; + 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); + } + else { + 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_add_ff.h b/gnuradio-core/src/lib/general/gr_add_ff.h new file mode 100644 index 000000000..6421f8da2 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_add_ff.h @@ -0,0 +1,56 @@ +/* -*- 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_ADD_FF_H +#define INCLUDED_GR_ADD_FF_H + +#include +#include + +class gr_add_ff; +typedef boost::shared_ptr gr_add_ff_sptr; + +GR_CORE_API gr_add_ff_sptr +gr_make_add_ff (size_t vlen=1); + +/*! + * \brief Add streams of complex values + * \ingroup math_blk + */ + +class GR_CORE_API gr_add_ff : public gr_sync_block +{ + private: + friend GR_CORE_API gr_add_ff_sptr + gr_make_add_ff (size_t vlen); + gr_add_ff (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_ADD_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_add_ff.i b/gnuradio-core/src/lib/general/gr_add_ff.i new file mode 100644 index 000000000..3c30640b1 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_add_ff.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,add_ff) + +gr_add_ff_sptr +gr_make_add_ff (size_t vlen=1); + +class gr_add_ff : public gr_sync_block +{ +public: + +}; -- cgit From f34b496341ceb73baffee6f8bf84ed197ffeeaf0 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 6 Feb 2012 22:02:56 -0500 Subject: core: added Volk-optimized gr_multiply_conjugate_cc at one block with QA code. --- gnuradio-core/src/lib/general/CMakeLists.txt | 1 + gnuradio-core/src/lib/general/Makefile.am | 3 + gnuradio-core/src/lib/general/general.i | 2 + gnuradio-core/src/lib/general/gr_add_ff.cc | 4 -- .../src/lib/general/gr_multiply_conjugate_cc.cc | 69 ++++++++++++++++++++++ .../src/lib/general/gr_multiply_conjugate_cc.h | 57 ++++++++++++++++++ .../src/lib/general/gr_multiply_conjugate_cc.i | 32 ++++++++++ 7 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc create mode 100644 gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h create mode 100644 gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i (limited to 'gnuradio-core/src/lib/general') 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 #include #include +#include #include #include #include @@ -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 +#include +#include + +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 +#include + +class gr_multiply_conjugate_cc; +typedef boost::shared_ptr +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: + +}; -- cgit From 75bb99df4720789749c059a0207507a3cbdd3855 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 7 Feb 2012 17:49:36 -0500 Subject: core: using volk for conjugate block and added QA code for it. --- gnuradio-core/src/lib/general/gr_conjugate_cc.cc | 27 +++++++----------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_conjugate_cc.cc index 59c3bae89..d2b20ffe6 100644 --- a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc +++ b/gnuradio-core/src/lib/general/gr_conjugate_cc.cc @@ -28,6 +28,7 @@ #include #include +#include gr_conjugate_cc_sptr gr_make_conjugate_cc () @@ -40,6 +41,9 @@ gr_conjugate_cc::gr_conjugate_cc () gr_make_io_signature (1, 1, sizeof (gr_complex)), gr_make_io_signature (1, 1, sizeof (gr_complex))) { + const int alignment_multiple = + volk_get_alignment() / sizeof(gr_complex); + set_alignment(alignment_multiple); } int @@ -50,26 +54,11 @@ gr_conjugate_cc::work (int noutput_items, gr_complex *iptr = (gr_complex *) input_items[0]; gr_complex *optr = (gr_complex *) output_items[0]; - int size = noutput_items; - - while (size >= 8){ - optr[0] = conj(iptr[0]); - optr[1] = conj(iptr[1]); - optr[2] = conj(iptr[2]); - optr[3] = conj(iptr[3]); - optr[4] = conj(iptr[4]); - optr[5] = conj(iptr[5]); - optr[6] = conj(iptr[6]); - optr[7] = conj(iptr[7]); - size -= 8; - optr += 8; - iptr += 8; + if(is_unaligned()) { + volk_32fc_conjugate_32fc_u(optr, iptr, noutput_items); } - - while (size-- > 0) { - *optr = conj(*iptr); - iptr++; - optr++; + else { + volk_32fc_conjugate_32fc_a(optr, iptr, noutput_items); } return noutput_items; -- cgit From 5a07519b2685fabab3e75380657a53d2161dc1a2 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 7 Feb 2012 22:17:28 -0500 Subject: core: fixed alignment call for char_to_short. --- gnuradio-core/src/lib/general/gr_char_to_short.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.cc b/gnuradio-core/src/lib/general/gr_char_to_short.cc index 40ffa9338..13375412c 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_short.cc +++ b/gnuradio-core/src/lib/general/gr_char_to_short.cc @@ -41,7 +41,7 @@ gr_char_to_short::gr_char_to_short (size_t vlen) d_vlen(vlen) { const int alignment_multiple = - volk_get_alignment() / sizeof(float); + volk_get_alignment() / sizeof(short); set_alignment(alignment_multiple); } -- cgit From f671319ca9ccef8fb1590e676ff6bcb85d7ca5a1 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 11 Feb 2012 09:06:45 -0500 Subject: core: reverting float_to_int to non-Volk due to precision/wrapping issues. Using the Volk function causes too much of a change in the output values right now. Will have to relook at it for the right thing to do. Keeping the use of vlen and scale, though. --- gnuradio-core/src/lib/general/gr_float_to_int.cc | 18 ++++++++++++++---- gnuradio-core/src/lib/general/gri_float_to_int.cc | 4 ++-- gnuradio-core/src/lib/general/gri_float_to_int.h | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.cc b/gnuradio-core/src/lib/general/gr_float_to_int.cc index 28214538f..b69591043 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_int.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_int.cc @@ -26,6 +26,7 @@ #include #include +#include #include gr_float_to_int_sptr @@ -56,12 +57,17 @@ gr_float_to_int::set_scale(float scale) { d_scale = scale; } - int gr_float_to_int::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { + // Disable the Volk for now. There is a problem for large 32-bit ints that + // are not properly represented by the precisions of a single float, which + // can cause wrapping from large, positive numbers to negative. + // In gri_float_to_int, the value is first promoted to a 64-bit + // value, clipped, then converted to a float. +#if 0 const float *in = (const float *) input_items[0]; int32_t *out = (int32_t *) output_items[0]; @@ -71,9 +77,13 @@ gr_float_to_int::work (int noutput_items, else { volk_32f_s32f_convert_32i_a(out, in, d_scale, d_vlen*noutput_items); } +#else + const float *in = (const float *) input_items[0]; + int *out = (int *) output_items[0]; + + gri_float_to_int (in, out, d_scale, d_vlen*noutput_items); + +#endif return noutput_items; } - - - diff --git a/gnuradio-core/src/lib/general/gri_float_to_int.cc b/gnuradio-core/src/lib/general/gri_float_to_int.cc index 5271e60e2..0b0b10dfe 100644 --- a/gnuradio-core/src/lib/general/gri_float_to_int.cc +++ b/gnuradio-core/src/lib/general/gri_float_to_int.cc @@ -34,10 +34,10 @@ static const int64_t MIN_INT = -2147483647; // -(2^31)-1 void -gri_float_to_int (const float *in, int *out, int nsamples) +gri_float_to_int (const float *in, int *out, float scale, int nsamples) { for (int i = 0; i < nsamples; i++){ - int64_t r = llrintf(in[i]); + int64_t r = llrintf(scale * in[i]); if (r < MIN_INT) r = MIN_INT; else if (r > MAX_INT) diff --git a/gnuradio-core/src/lib/general/gri_float_to_int.h b/gnuradio-core/src/lib/general/gri_float_to_int.h index a2f6ea877..d8b98efc1 100644 --- a/gnuradio-core/src/lib/general/gri_float_to_int.h +++ b/gnuradio-core/src/lib/general/gri_float_to_int.h @@ -28,6 +28,6 @@ /*! * convert array of floats to int with rounding and saturation. */ -GR_CORE_API void gri_float_to_int (const float *in, int *out, int nsamples); +GR_CORE_API void gri_float_to_int (const float *in, int *out, float scale, int nsamples); #endif /* INCLUDED_GRI_FLOAT_TO_INT_H */ -- cgit From 2597fe8ed82ee04c161c9f08534ae1b90d2b7d88 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 13 Feb 2012 14:50:14 -0500 Subject: core: change alignment requirement. --- gnuradio-core/src/lib/general/gr_char_to_short.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.cc b/gnuradio-core/src/lib/general/gr_char_to_short.cc index 13375412c..8b6cd0be1 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_short.cc +++ b/gnuradio-core/src/lib/general/gr_char_to_short.cc @@ -41,7 +41,7 @@ gr_char_to_short::gr_char_to_short (size_t vlen) d_vlen(vlen) { const int alignment_multiple = - volk_get_alignment() / sizeof(short); + volk_get_alignment() / sizeof(char); set_alignment(alignment_multiple); } -- cgit From 2eaa0a6e1e57cfc374c258c317ecb469fc49bf53 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Tue, 14 Feb 2012 15:37:57 -0800 Subject: build: fix autotools for gnuradio-core volkification --- gnuradio-core/src/lib/general/Makefile.am | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index ea3b31fd3..5b4a702e1 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -129,8 +129,8 @@ libgeneral_la_SOURCES = \ gr_reverse.cc \ gr_rms_cf.cc \ gr_rms_ff.cc \ + gr_short_to_char.cc \ gr_short_to_float.cc \ - gr_short_to_int.cc \ gr_int_to_float.cc \ gr_simple_correlator.cc \ gr_simple_framer.cc \ @@ -194,8 +194,8 @@ libgeneral_qa_la_SOURCES = \ grinclude_HEADERS = \ gr_core_api.h \ complex_vec_test.h \ - gr_add.h \ gr_additive_scrambler_bb.h \ + gr_add_ff.h \ gr_agc_cc.h \ gr_agc_ff.h \ gr_agc2_cc.h \ @@ -339,7 +339,7 @@ grinclude_HEADERS = \ gri_int_to_float.h \ gri_lfsr_15_1_0.h \ gri_lfsr_32k.h \ - gri_short_to_char.h \ + gri_short_to_float.h \ gri_uchar_to_float.h \ malloc16.h \ random.h \ @@ -368,8 +368,8 @@ noinst_HEADERS = \ swiginclude_HEADERS = \ complex_vec_test.i \ general.i \ - gr_add.i \ gr_additive_scrambler_bb.i \ + gr_add_ff.i \ gr_agc_cc.i \ gr_agc_ff.i \ gr_agc2_cc.i \ -- cgit