Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote branch 'tom/safe_align'

  • Loading branch information...
commit 0a6f1494b8e462c13c8c48c69680832967ebec72 2 parents 088ca3e + e8d6448
@jmcorgan jmcorgan authored
Showing with 5,123 additions and 303 deletions.
  1. +3 −4 config/grc_volk.m4
  2. +10 −0 docs/doxygen/other/main_page.dox
  3. +161 −0 docs/doxygen/other/volk_guide.dox
  4. +0 −6 gnuradio-core/src/guile/tests/gengen_ctors.test
  5. +4 −0 gnuradio-core/src/lib/CMakeLists.txt
  6. +1 −0  gnuradio-core/src/lib/Makefile.am
  7. +2 −1  gnuradio-core/src/lib/filter/gr_fft_filter_ccc.cc
  8. +1 −1  gnuradio-core/src/lib/filter/gr_fft_filter_fff.cc
  9. +2 −3 gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc
  10. +2 −3 gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc
  11. +0 −15 gnuradio-core/src/lib/general/.gitignore
  12. +9 −1 gnuradio-core/src/lib/general/CMakeLists.txt
  13. +25 −1 gnuradio-core/src/lib/general/Makefile.am
  14. +16 −0 gnuradio-core/src/lib/general/general.i
  15. +0 −10 gnuradio-core/src/lib/general/general_generated.i
  16. +66 −0 gnuradio-core/src/lib/general/gr_add_ff.cc
  17. +56 −0 gnuradio-core/src/lib/general/gr_add_ff.h
  18. +32 −0 gnuradio-core/src/lib/general/gr_add_ff.i
  19. +28 −11 gnuradio-core/src/lib/general/gr_char_to_float.cc
  20. +11 −3 gnuradio-core/src/lib/general/gr_char_to_float.h
  21. +5 −2 gnuradio-core/src/lib/general/gr_char_to_float.i
  22. +64 −0 gnuradio-core/src/lib/general/gr_char_to_short.cc
  23. +56 −0 gnuradio-core/src/lib/general/gr_char_to_short.h
  24. +30 −0 gnuradio-core/src/lib/general/gr_char_to_short.i
  25. +62 −17 gnuradio-core/src/lib/general/gr_complex_to_xxx.cc
  26. +3 −2 gnuradio-core/src/lib/general/gr_complex_to_xxx.h
  27. +8 −19 gnuradio-core/src/lib/general/gr_conjugate_cc.cc
  28. +30 −9 gnuradio-core/src/lib/general/gr_float_to_char.cc
  29. +12 −4 gnuradio-core/src/lib/general/gr_float_to_char.h
  30. +6 −3 gnuradio-core/src/lib/general/gr_float_to_char.i
  31. +43 −12 gnuradio-core/src/lib/general/gr_float_to_int.cc
  32. +12 −4 gnuradio-core/src/lib/general/gr_float_to_int.h
  33. +6 −3 gnuradio-core/src/lib/general/gr_float_to_int.i
  34. +30 −9 gnuradio-core/src/lib/general/gr_float_to_short.cc
  35. +11 −4 gnuradio-core/src/lib/general/gr_float_to_short.h
  36. +6 −3 gnuradio-core/src/lib/general/gr_float_to_short.i
  37. +18 −9 gnuradio-core/src/lib/general/gr_int_to_float.cc
  38. +12 −4 gnuradio-core/src/lib/general/gr_int_to_float.h
  39. +5 −3 gnuradio-core/src/lib/general/gr_int_to_float.i
  40. +69 −0 gnuradio-core/src/lib/general/gr_multiply_cc.cc
  41. +56 −0 gnuradio-core/src/lib/general/gr_multiply_cc.h
  42. +32 −0 gnuradio-core/src/lib/general/gr_multiply_cc.i
  43. +69 −0 gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc
  44. +57 −0 gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h
  45. +32 −0 gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i
  46. +80 −0 gnuradio-core/src/lib/general/gr_multiply_const_cc.cc
  47. +60 −0 gnuradio-core/src/lib/general/gr_multiply_const_cc.h
  48. +33 −0 gnuradio-core/src/lib/general/gr_multiply_const_cc.i
  49. +80 −0 gnuradio-core/src/lib/general/gr_multiply_const_ff.cc
  50. +60 −0 gnuradio-core/src/lib/general/gr_multiply_const_ff.h
  51. +33 −0 gnuradio-core/src/lib/general/gr_multiply_const_ff.i
  52. +69 −0 gnuradio-core/src/lib/general/gr_multiply_ff.cc
  53. +56 −0 gnuradio-core/src/lib/general/gr_multiply_ff.h
  54. +32 −0 gnuradio-core/src/lib/general/gr_multiply_ff.i
  55. +67 −0 gnuradio-core/src/lib/general/gr_short_to_char.cc
  56. +56 −0 gnuradio-core/src/lib/general/gr_short_to_char.h
  57. +31 −0 gnuradio-core/src/lib/general/gr_short_to_char.i
  58. +29 −9 gnuradio-core/src/lib/general/gr_short_to_float.cc
  59. +13 −5 gnuradio-core/src/lib/general/gr_short_to_float.h
  60. +6 −3 gnuradio-core/src/lib/general/gr_short_to_float.i
  61. +2 −2 gnuradio-core/src/lib/general/gri_float_to_int.cc
  62. +1 −1  gnuradio-core/src/lib/general/gri_float_to_int.h
  63. +0 −15 gnuradio-core/src/lib/gengen/.gitignore
  64. +3 −3 gnuradio-core/src/lib/gengen/CMakeLists.txt
  65. +0 −15 gnuradio-core/src/lib/gengen/Makefile.gen
  66. +4 −4 gnuradio-core/src/lib/gengen/generate_common.py
  67. +30 −0 gnuradio-core/src/lib/runtime/gr_block.cc
  68. +28 −0 gnuradio-core/src/lib/runtime/gr_block.h
  69. +54 −1 gnuradio-core/src/lib/runtime/gr_block_executor.cc
  70. +4 −0 gnuradio-core/src/python/gnuradio/gr/Makefile.am
  71. +34 −0 gnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py
  72. +1 −1  gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py
  73. +53 −0 gnuradio-core/src/python/gnuradio/gr/qa_conjugate.py
  74. +82 −0 gnuradio-core/src/python/gnuradio/gr/qa_float_to_char.py
  75. +21 −1 gnuradio-core/src/python/gnuradio/gr/qa_float_to_int.py
  76. +86 −0 gnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py
  77. +64 −0 gnuradio-core/src/python/gnuradio/gr/qa_float_to_uchar.py
  78. +20 −0 gnuradio-core/src/python/gnuradio/gr/qa_int_to_float.py
  79. +57 −0 gnuradio-core/src/python/gnuradio/gr/qa_multiply_conjugate.py
  80. +69 −0 gnuradio-core/src/python/gnuradio/gr/qa_short_to_char.py
  81. +70 −0 gnuradio-core/src/python/gnuradio/gr/qa_short_to_float.py
  82. +252 −0 gnuradio-examples/python/volk_benchmark/README
  83. +152 −0 gnuradio-examples/python/volk_benchmark/volk_math.py
  84. +169 −0 gnuradio-examples/python/volk_benchmark/volk_plot.py
  85. +171 −0 gnuradio-examples/python/volk_benchmark/volk_test_funcs.py
  86. +182 −0 gnuradio-examples/python/volk_benchmark/volk_types.py
  87. +7 −0 volk/apps/CMakeLists.txt
  88. +16 −2 volk/apps/volk_profile.cc
  89. +15 −1 volk/include/volk/Makefile.am
  90. +50 −11 volk/include/volk/volk_32f_s32f_convert_16i_a.h
  91. +50 −11 volk/include/volk/volk_32f_s32f_convert_16i_u.h
  92. +53 −7 volk/include/volk/volk_32f_s32f_convert_32i_a.h
  93. +40 −5 volk/include/volk/volk_32f_s32f_convert_32i_u.h
  94. +45 −8 volk/include/volk/volk_32f_s32f_convert_8i_a.h
  95. +45 −8 volk/include/volk/volk_32f_s32f_convert_8i_u.h
  96. +75 −0 volk/include/volk/volk_32f_s32f_multiply_32f_a.h
  97. +102 −0 volk/include/volk/volk_32f_s32f_multiply_32f_u.h
  98. +66 −0 volk/include/volk/volk_32f_x2_add_32f_u.h
  99. +106 −0 volk/include/volk/volk_32f_x2_multiply_32f_u.h
  100. +64 −0 volk/include/volk/volk_32fc_conjugate_32fc_a.h
  101. +64 −0 volk/include/volk/volk_32fc_conjugate_32fc_u.h
  102. +68 −0 volk/include/volk/volk_32fc_deinterleave_imag_32f_a.h
  103. +118 −0 volk/include/volk/volk_32fc_magnitude_32f_u.h
  104. +114 −0 volk/include/volk/volk_32fc_magnitude_squared_32f_a.h
  105. +114 −0 volk/include/volk/volk_32fc_magnitude_squared_32f_u.h
  106. +58 −13 volk/include/volk/volk_32fc_s32fc_multiply_32fc_a.h
  107. +87 −0 volk/include/volk/volk_32fc_s32fc_multiply_32fc_u.h
  108. +0 −1  volk/include/volk/volk_32fc_x2_multiply_32fc_a.h
  109. +77 −0 volk/include/volk/volk_32fc_x2_multiply_32fc_u.h
  110. +81 −0 volk/include/volk/volk_32fc_x2_multiply_conjugate_32fc_a.h
  111. +81 −0 volk/include/volk/volk_32fc_x2_multiply_conjugate_32fc_u.h
  112. +5 −3 volk/include/volk/volk_64u_popcnt_a.h
  113. +28 −4 volk/lib/qa_utils.cc
  114. +4 −1 volk/lib/qa_utils.h
  115. +13 −2 volk/lib/testqa.cc
View
7 config/grc_volk.m4
@@ -26,11 +26,10 @@ AC_DEFUN([GRC_VOLK],[
dnl Test if $enable_volk is:
dnl yes : if the --enable code passed muster and all dependencies are met
dnl no : otherwise, then do not set variables
- if test $passed != with && test x$enable_volk == xyes; then
+ if test $passed != with && test x$enable_volk != xno; then
dnl how and where to find INCLUDES and LA
- volk_INCLUDES="-I\${abs_top_srcdir}/volk/include"
- volk_LA="\${abs_top_builddir}/volk/lib/libvolk.la \
- \${abs_top_builddir}/volk/lib/libvolk_runtime.la"
+ volk_INCLUDES="-I\${abs_top_srcdir}/volk/gen/include -I\${abs_top_srcdir}/volk/include"
+ volk_LA="\${abs_top_builddir}/volk/lib/libvolk.la"
fi
dnl volk uses a subsidiary configure.ac
View
10 docs/doxygen/other/main_page.dox
@@ -38,4 +38,14 @@ More details on packages in GNU Radio:
\li \ref page_uhd
\li \ref page_vocoder
\li \ref page_pfb
+
+\section volk_main Using Volk in GNU Radio
+
+The \ref volk_guide page provides an overview of how to incorporate
+and use Volk in GNU Radio blocks.
+
+Many blocks have already been converted to use Volk in their calls, so
+they can also serve as examples. See the gr_complex_to_xxx.h file for
+examples of various blocks that make use of Volk.
+
*/
View
161 docs/doxygen/other/volk_guide.dox
@@ -0,0 +1,161 @@
+/*! \page volk_guide Instructions for using Volk in GNU Radio
+
+\section volk_intro Introduction
+
+Volk is the Vector-Optimized Library of Kernels. It is a library that
+contains kernels of hand-written SIMD code for different mathematical
+operations. Since each SIMD architecture can be greatly different and
+no compiler has yet come along to handle vectorization properly or
+highly efficiently, Volk approaches the problem differently. For each
+architecture or platform that a developer wishes to vectorize for, a
+new proto-kernel is added to Volk. At runtime, Volk will select the
+correct proto-kernel. In this way, the users of Volk call a kernel for
+performing the operation that is platform/architecture agnostic. This
+allows us to write portable SIMD code.
+
+Volk kernels are always defined with a 'generic' proto-kernel, which
+is written in plain C. With the generic kernel, the kernel becomes
+portable to any platform. Kernels are then extended by adding
+proto-kernels for new platforms in which they are desired.
+
+A good example of a Volk kernel with multiple proto-kernels defined is
+the volk_32f_s32f_multiply_32f_a. This kernel implements a scalar
+multiplication of a vector of floating point numbers (each item in the
+vector is multiplied by the same value). This kernel has the following
+proto-kernels that are defined for 'generic,' 'avx,' 'sse,' and 'orc.'
+
+\code
+ void volk_32f_s32f_multiply_32f_a_generic
+ void volk_32f_s32f_multiply_32f_a_sse
+ void volk_32f_s32f_multiply_32f_a_avx
+ void volk_32f_s32f_multiply_32f_a_orc
+\endcode
+
+These proto-kernels means that on platforms with AVX support, Volk can
+select this option or the SSE option, depending on which is faster. On
+other platforms, the ORC SIMD compiler might provide a solution. If
+all else fails, Volk can fall back on the generic proto-kernel, which
+will always work.
+
+Just a note on ORC. ORC is a SIMD compiler library that uses a generic
+assembly-like language for SIMD commands. Based on the available SIMD
+architecture of a system, it will try and compile a good
+solution. Tests show that the results of ORC proto-kernels are
+generally better than the generic versions but often not as good as
+the hand-tuned proto-kernels for a specific SIMD architecture. This
+is, of course, to be expected, and ORC provides a nice intermediary
+step to performance improvements until a specific hand-tuned
+proto-kernel can be made for a given platform.
+
+See <a
+href="http://gnuradio.org/redmine/projects/gnuradio/wiki/Volk">Volk on
+gnuradio.org</a> for details on the Volk naming scheme.
+
+
+\section volk_alignment Setting and Using Memory Alignment Information
+
+For Volk to work as best as possible, we want to use memory-aligned
+SIMD calls, which means we have to have some way of knowing and
+controlling the alignment of the buffers passed to gr_block's work
+function. We set the alignment requirement for SIMD aligned memory
+calls with:
+
+\code
+ const int alignment_multiple =
+ volk_get_alignment() / output_item_size;
+ set_alignment(alignment_multiple);
+\endcode
+
+The Volk function 'volk_get_alignment' provides the alignment of the
+the machine architecture. We then base the alignment on the number of
+output items required to maintain the alignment, so we divide the
+number of alignment bytes by the number of bytes in an output items
+(sizeof(float), sizeof(gr_complex), etc.). This value is then set per
+block with the 'set_alignment' function.
+
+Because the scheduler tries to optimize throughput, the number of
+items available per call to work will change and depends on the
+availability of the read and write buffers. This means that it
+sometimes cannot produce a buffer that is properly memory
+aligned. This is an inevitable consequence of the scheduler
+system. Instead of requiring alignment, the scheduler enforces the
+alignment as much as possible, and when a buffer becomes unaligned,
+the scheduler will work to correct it as much as possible. If a
+block's buffers are unaligned, then, the scheduler sets a flag to
+indicate as much so that the block can then decide what best to
+do. The next section discusses the use of the aligned/unaligned
+information in a gr_block's work function.
+
+
+\section volk_work Using Alignment Properties in Work()
+
+The buffers passed to work/general_work in a gr_block are not
+guaranteed to be aligned, but they will mostly be aligned whenever
+possible. When not aligned, the 'is_unaligned()' flag will be set. So
+a block can know if its buffers are aligned and make the right
+decisions. This looks like:
+
+\code
+int
+gr_some_block::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];
+
+ if(is_unaligned()) {
+ // do something with unaligned data. This can either be a manual
+ // handling of the items or a call to an unaligned Volk function.
+ volk_32f_something_32f_u(out, in, noutput_items);
+ }
+ else {
+ // Buffers are aligned; can call the aligned Volk function.
+ volk_32f_something_32f_a(out, in, noutput_items);
+ }
+
+ return noutput_items;
+}
+\endcode
+
+
+
+\section volk_tuning Tuning Volk Performance
+
+VOLK comes with a profiler that will build a config file for the best
+SIMD architecture for your processor. Run volk_profile that is
+installed into $PREFIX/bin. This program tests all known VOLK kernels
+for each architecture supported by the processor. When finished, it
+will write to $HOME/.volk/volk_config the best architecture for the
+VOLK function. This file is read when using a function to know the
+best version of the function to execute.
+
+\subsection volk_hand_tuning Hand-Tuning Performance
+
+If you know a particular architecture works best for your processor,
+you can specify the particular architecture to use in the VOLK
+preferences file: $HOME/.volk/volk_config
+
+The file looks like:
+
+\code
+ volk_<FUNCTION_NAME> <ARCHITECTURE>
+\endcode
+
+Where the "FUNCTION_NAME" is the particular function that you want to
+over-ride the default value and "ARCHITECTURE" is the VOLK SIMD
+architecture to use (generic, sse, sse2, sse3, avx, etc.). For
+example, the following config file tells VOLK to use SSE3 for the
+aligned and unaligned versions of a function that multiplies two
+complex streams together.
+
+\code
+ volk_32fc_x2_multiply_32fc_a sse3
+ volk_32fc_x2_multiply_32fc_u sse3
+\endcode
+
+\b Tip: if benchmarking GNU Radio blocks, it can be useful to have a
+volk_config file that sets all architectures to 'generic' as a way to
+test the vectorized versus non-vectorized implementations.
+
+*/
View
6 gnuradio-core/src/guile/tests/gengen_ctors.test
@@ -161,12 +161,6 @@
;;; ./gengen/gr_moving_average_ss.h
(pass-if (true? (gr:moving-average-ss 1 0 4096)))
-;;; ./gengen/gr_multiply_cc.h
-(pass-if (true? (gr:multiply-cc 1)))
-
-;;; ./gengen/gr_multiply_const_cc.h
-(pass-if (true? (gr:multiply-const-cc 1)))
-
;;; ./gengen/gr_multiply_const_ff.h
(pass-if (true? (gr:multiply-const-ff 1)))
View
4 gnuradio-core/src/lib/CMakeLists.txt
@@ -42,6 +42,7 @@ list(APPEND test_gnuradio_core_sources bug_work_around_6.cc)
# Setup the include and linker paths
########################################################################
include_directories(${GNURADIO_CORE_INCLUDE_DIRS})
+include_directories(${VOLK_INCLUDE_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
@@ -73,6 +74,9 @@ if(LINUX)
list(APPEND gnuradio_core_libs rt)
endif()
+# Link against libvolk
+list(APPEND gnuradio_core_libs volk)
+
add_library(gnuradio-core SHARED ${gnuradio_core_sources})
target_link_libraries(gnuradio-core ${gnuradio_core_libs})
GR_LIBRARY_FOO(gnuradio-core RUNTIME_COMPONENT "core_runtime" DEVEL_COMPONENT "core_devel")
View
1  gnuradio-core/src/lib/Makefile.am
@@ -51,6 +51,7 @@ libgnuradio_core_la_LIBADD = \
runtime/libruntime.la \
hier/libhier.la \
$(GRUEL_LA) \
+ $(VOLK_LA) \
$(FFTW3F_LIBS) \
$(GSL_LIBS) \
$(CBLAS_LIBS) \
View
3  gnuradio-core/src/lib/filter/gr_fft_filter_ccc.cc
@@ -30,7 +30,6 @@
#endif
#include <gr_fft_filter_ccc.h>
-//#include <gri_fft_filter_ccc_sse.h>
#include <gri_fft_filter_ccc_generic.h>
#include <gr_io_signature.h>
#include <gri_fft.h>
@@ -61,11 +60,13 @@ gr_fft_filter_ccc::gr_fft_filter_ccc (int decimation,
d_updated(false)
{
set_history(1);
+
#if 1 // don't enable the sse version until handling it is worked out
d_filter = new gri_fft_filter_ccc_generic(decimation, taps, nthreads);
#else
d_filter = new gri_fft_filter_ccc_sse(decimation, taps);
#endif
+
d_new_taps = taps;
d_nsamples = d_filter->set_taps(taps);
set_output_multiple(d_nsamples);
View
2  gnuradio-core/src/lib/filter/gr_fft_filter_fff.cc
@@ -26,7 +26,6 @@
#include <gr_fft_filter_fff.h>
#include <gri_fft_filter_fff_generic.h>
-//#include <gri_fft_filter_fff_sse.h>
#include <gr_io_signature.h>
#include <assert.h>
#include <stdexcept>
@@ -59,6 +58,7 @@ gr_fft_filter_fff::gr_fft_filter_fff (int decimation,
#else
d_filter = new gri_fft_filter_fff_sse(decimation, taps);
#endif
+
d_new_taps = taps;
d_nsamples = d_filter->set_taps(taps);
set_output_multiple(d_nsamples);
View
5 gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.cc
@@ -26,6 +26,7 @@
#include <gri_fft_filter_ccc_generic.h>
#include <gri_fft.h>
+#include <volk/volk.h>
#include <assert.h>
#include <stdexcept>
#include <cstdio>
@@ -154,9 +155,7 @@ gri_fft_filter_ccc_generic::filter (int nitems, const gr_complex *input, gr_comp
gr_complex *b = &d_xformed_taps[0];
gr_complex *c = d_invfft->get_inbuf();
- for (j = 0; j < d_fftsize; j+=1) { // filter in the freq domain
- c[j] = a[j] * b[j];
- }
+ volk_32fc_x2_multiply_32fc_a(c, a, b, d_fftsize);
d_invfft->execute(); // compute inv xform
View
5 gnuradio-core/src/lib/filter/gri_fft_filter_fff_generic.cc
@@ -26,6 +26,7 @@
#include <gri_fft_filter_fff_generic.h>
#include <gri_fft.h>
+#include <volk/volk.h>
#include <assert.h>
#include <stdexcept>
#include <cstdio>
@@ -141,9 +142,7 @@ gri_fft_filter_fff_generic::filter (int nitems, const float *input, float *outpu
gr_complex *b = &d_xformed_taps[0];
gr_complex *c = d_invfft->get_inbuf();
- for (j = 0; j < d_fftsize/2+1; j++) { // filter in the freq domain
- c[j] = a[j] * b[j];
- }
+ volk_32fc_x2_multiply_32fc_a(c, a, b, d_fftsize/2+1);
d_invfft->execute(); // compute inv xform
View
15 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
@@ -158,24 +155,12 @@
/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
/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
View
10 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
#
@@ -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
@@ -187,6 +188,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 +231,11 @@ set(gr_core_general_triple_threats
gr_kludge_copy
gr_lfsr_32k_source_s
gr_map_bb
+ gr_multiply_cc
+ gr_multiply_ff
+ gr_multiply_const_cc
+ gr_multiply_const_ff
+ gr_multiply_conjugate_cc
gr_nlog10_ff
gr_nop
gr_null_sink
@@ -256,6 +263,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
View
26 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
#
@@ -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 \
@@ -46,6 +47,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 \
@@ -93,6 +95,11 @@ libgeneral_la_SOURCES = \
gr_lfsr_32k_source_s.cc \
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_multiply_conjugate_cc.cc \
gr_nlog10_ff.cc \
gr_nop.cc \
gr_null_sink.cc \
@@ -122,6 +129,7 @@ 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_int_to_float.cc \
gr_simple_correlator.cc \
@@ -187,6 +195,7 @@ grinclude_HEADERS = \
gr_core_api.h \
complex_vec_test.h \
gr_additive_scrambler_bb.h \
+ gr_add_ff.h \
gr_agc_cc.h \
gr_agc_ff.h \
gr_agc2_cc.h \
@@ -195,6 +204,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 \
@@ -246,6 +256,11 @@ grinclude_HEADERS = \
gr_map_bb.h \
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_multiply_conjugate_cc.h \
gr_nco.h \
gr_nlog10_ff.h \
gr_nop.h \
@@ -276,6 +291,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 \
@@ -353,6 +369,7 @@ swiginclude_HEADERS = \
complex_vec_test.i \
general.i \
gr_additive_scrambler_bb.i \
+ gr_add_ff.i \
gr_agc_cc.i \
gr_agc_ff.i \
gr_agc2_cc.i \
@@ -361,6 +378,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 \
@@ -403,6 +421,11 @@ swiginclude_HEADERS = \
gr_kludge_copy.i \
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_multiply_conjugate_cc.i \
gr_nlog10_ff.i \
gr_nop.i \
gr_null_sink.i \
@@ -430,6 +453,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 \
View
16 gnuradio-core/src/lib/general/general.i
@@ -44,8 +44,10 @@
#include <gr_float_to_char.h>
#include <gr_float_to_uchar.h>
#include <gr_short_to_float.h>
+#include <gr_short_to_char.h>
#include <gr_int_to_float.h>
#include <gr_char_to_float.h>
+#include <gr_char_to_short.h>
#include <gr_uchar_to_float.h>
#include <gr_frequency_modulator_fc.h>
#include <gr_phase_modulator_fc.h>
@@ -104,6 +106,11 @@
#include <gr_diff_decoder_bb.h>
#include <gr_framer_sink_1.h>
#include <gr_map_bb.h>
+#include <gr_multiply_cc.h>
+#include <gr_multiply_ff.h>
+#include <gr_multiply_const_cc.h>
+#include <gr_multiply_const_ff.h>
+#include <gr_multiply_conjugate_cc.h>
#include <gr_feval.h>
#include <gr_pwr_squelch_cc.h>
#include <gr_pwr_squelch_ff.h>
@@ -134,6 +141,7 @@
#include <gr_burst_tagger.h>
#include <gr_cpm.h>
#include <gr_correlate_access_code_tag_bb.h>
+#include <gr_add_ff.h>
%}
%include "gri_control_loop.i"
@@ -158,8 +166,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 +228,11 @@
%include "gr_diff_decoder_bb.i"
%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_multiply_conjugate_cc.i"
%include "gr_feval.i"
%include "gr_pwr_squelch_cc.i"
%include "gr_pwr_squelch_ff.i"
@@ -248,3 +263,4 @@
%include "gr_burst_tagger.i"
%include "gr_cpm.i"
%include "gr_correlate_access_code_tag_bb.i"
+%include "gr_add_ff.i"
View
10 gnuradio-core/src/lib/general/general_generated.i
@@ -12,7 +12,6 @@
#include <gr_add_const_vff.h>
#include <gr_add_const_vii.h>
#include <gr_add_const_vss.h>
-#include <gr_add_ff.h>
#include <gr_add_ii.h>
#include <gr_add_ss.h>
#include <gr_add_vcc.h>
@@ -29,16 +28,12 @@
#include <gr_divide_ff.h>
#include <gr_divide_ii.h>
#include <gr_divide_ss.h>
-#include <gr_multiply_cc.h>
-#include <gr_multiply_const_cc.h>
-#include <gr_multiply_const_ff.h>
#include <gr_multiply_const_ii.h>
#include <gr_multiply_const_ss.h>
#include <gr_multiply_const_vcc.h>
#include <gr_multiply_const_vff.h>
#include <gr_multiply_const_vii.h>
#include <gr_multiply_const_vss.h>
-#include <gr_multiply_ff.h>
#include <gr_multiply_ii.h>
#include <gr_multiply_ss.h>
#include <gr_multiply_vcc.h>
@@ -89,7 +84,6 @@
%include <gr_add_const_vff.i>
%include <gr_add_const_vii.i>
%include <gr_add_const_vss.i>
-%include <gr_add_ff.i>
%include <gr_add_ii.i>
%include <gr_add_ss.i>
%include <gr_add_vcc.i>
@@ -106,16 +100,12 @@
%include <gr_divide_ff.i>
%include <gr_divide_ii.i>
%include <gr_divide_ss.i>
-%include <gr_multiply_cc.i>
-%include <gr_multiply_const_cc.i>
-%include <gr_multiply_const_ff.i>
%include <gr_multiply_const_ii.i>
%include <gr_multiply_const_ss.i>
%include <gr_multiply_const_vcc.i>
%include <gr_multiply_const_vff.i>
%include <gr_multiply_const_vii.i>
%include <gr_multiply_const_vss.i>
-%include <gr_multiply_ff.i>
%include <gr_multiply_ii.i>
%include <gr_multiply_ss.i>
%include <gr_multiply_vcc.i>
View
66 gnuradio-core/src/lib/general/gr_add_ff.cc
@@ -0,0 +1,66 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_add_ff.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+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));
+ 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;
+}
View
56 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 <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_add_ff;
+typedef boost::shared_ptr<gr_add_ff> 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 */
View
32 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:
+
+};
View
39 gnuradio-core/src/lib/general/gr_char_to_float.cc
@@ -26,30 +26,47 @@
#include <gr_char_to_float.h>
#include <gr_io_signature.h>
-#include <gri_char_to_float.h>
+#include <volk/volk.h>
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;
}
View
14 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> 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);
View
7 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);
};
View
64 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 <gr_char_to_short.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+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(char);
+ 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;
+}
View
56 gnuradio-core/src/lib/general/gr_char_to_short.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_CHAR_TO_SHORT_H
+#define INCLUDED_GR_CHAR_TO_SHORT_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_char_to_short;
+typedef boost::shared_ptr<gr_char_to_short> 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
+{
+ 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);
+
+ 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 */
View
30 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
+{
+
+};
View
79 gnuradio-core/src/lib/general/gr_complex_to_xxx.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2008,2010 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2010,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -27,6 +27,7 @@
#include <gr_complex_to_xxx.h>
#include <gr_io_signature.h>
#include <gr_math.h>
+#include <volk/volk.h>
// ----------------------------------------------------------------
@@ -42,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
@@ -56,16 +60,26 @@ gr_complex_to_float::work (int noutput_items,
switch (output_items.size ()){
case 1:
- for (int i = 0; i < noi; i++){
- out0[i] = in[i].real ();
+ 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);
}
break;
case 2:
out1 = (float *) output_items[1];
- for (int i = 0; i < noi; i++){
- out0[i] = in[i].real ();
- out1[i] = in[i].imag ();
+ 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);
}
break;
@@ -90,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
@@ -101,9 +118,15 @@ gr_complex_to_real::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] = in[i].real ();
+ 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);
}
+
return noutput_items;
}
@@ -121,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
@@ -132,9 +158,15 @@ gr_complex_to_imag::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] = in[i].imag ();
+ 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);
}
+
return noutput_items;
}
@@ -152,6 +184,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 +198,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 +218,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 +232,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(is_unaligned()) {
+ volk_32fc_magnitude_squared_32f_u(out, in, noi);
+ }
+ else {
+ volk_32fc_magnitude_squared_32f_a(out, in, noi);
}
+
return noutput_items;
}
@@ -216,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
@@ -227,9 +270,11 @@ gr_complex_to_arg::work (int noutput_items,
float *out = (float *) output_items[0];
int noi = noutput_items * d_vlen;
+ // 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]);
}
+
return noutput_items;
}
View
5 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,
View
27 gnuradio-core/src/lib/general/gr_conjugate_cc.cc
@@ -28,6 +28,7 @@
#include <gr_conjugate_cc.h>
#include <gr_io_signature.h>
+#include <volk/volk.h>
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;
View
39 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
*
@@ -26,19 +26,35 @@
#include <gr_float_to_char.h>
#include <gr_io_signature.h>
-#include <gri_float_to_char.h>
+#include <volk/volk.h>
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);
+}
+
+float
+gr_float_to_char::scale() const
+{
+ return d_scale;
+}
+
+void
+gr_float_to_char::set_scale(float scale)
+{
+ d_scale = scale;
}
int
@@ -47,9 +63,14 @@ gr_float_to_char::work (int noutput_items,
gr_vector_void_star &output_items)
{
const float *in = (const float *) input_items[0];
- char *out = (char *) output_items[0];
+ int8_t *out = (int8_t *) output_items[0];
- gri_float_to_char (in, out, noutput_items);
+ if(is_unaligned()) {
+ 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, d_vlen*noutput_items);
+ }
return noutput_items;
}
View
16 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> 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);
View
9 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,12 @@
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);
};
View
55 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
*
@@ -27,32 +27,63 @@
#include <gr_float_to_int.h>
#include <gr_io_signature.h>
#include <gri_float_to_int.h>
+#include <volk/volk.h>
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);
}
+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)
{
+ // 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];
+
+ if(is_unaligned()) {
+ 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, 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);
+ gri_float_to_int (in, out, d_scale, d_vlen*noutput_items);
+
+#endif
return noutput_items;
}
-
-
-
View
16 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> 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);
View
9 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,12 @@
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);
};
View
39 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
*
@@ -26,19 +26,35 @@
#include <gr_float_to_short.h>
#include <gr_io_signature.h>
-#include <gri_float_to_short.h>
+#include <volk/volk.h>
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);
+}
+
+float
+gr_float_to_short::scale() const
+{
+ return d_scale;
+}
+
+void
+gr_float_to_short::set_scale(float scale)
+{
+ d_scale = scale;
}
int
@@ -49,8 +65,13 @@ 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(is_unaligned()) {
+ 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, d_vlen*noutput_items);
+ }
+
return noutput_items;
}
View
15 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> 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);
View
9 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,12 @@
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);
};
View
27 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
*
@@ -26,19 +26,23 @@
#include <gr_int_to_float.h>
#include <gr_io_signature.h>
-#include <gri_int_to_float.h>
+#include <volk/volk.h>
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,9 +52,14 @@ 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(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);
+ }
+
return noutput_items;
}
View
16 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> 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);
View
8 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);
};
View
69 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 <gr_multiply_cc.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+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;
+}
+
+
+
View
56 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 <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_multiply_cc;
+typedef boost::shared_ptr<gr_multiply_cc> 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 */
View
32 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:
+
+};
View
69 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