summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
authorTom Rondeau2012-01-28 19:25:04 -0500
committerTom Rondeau2012-01-28 19:25:04 -0500
commitf63927a46517ea9c7e914feb9177896219b33a0d (patch)
treeb9a41b22fe629f2612669cfb096f1cbbc127163e /gnuradio-core/src/lib
parentc9a420645f16f5c28fdcf05c1c09b9a91b95e640 (diff)
downloadgnuradio-f63927a46517ea9c7e914feb9177896219b33a0d.tar.gz
gnuradio-f63927a46517ea9c7e914feb9177896219b33a0d.tar.bz2
gnuradio-f63927a46517ea9c7e914feb9177896219b33a0d.zip
core: more conversion work to Volk for type converters.
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/general/gr_char_to_float.cc39
-rw-r--r--gnuradio-core/src/lib/general/gr_char_to_float.h14
-rw-r--r--gnuradio-core/src/lib/general/gr_char_to_float.i7
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.cc30
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.h16
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.i8
-rw-r--r--gnuradio-core/src/lib/general/gr_short_to_char.i3
-rw-r--r--gnuradio-core/src/lib/general/gr_short_to_float.cc1
8 files changed, 85 insertions, 33 deletions
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 <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;
}
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> 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 <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,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> 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;
}