summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-02-10 19:01:32 -0800
committerJosh Blum <josh@joshknows.com>2011-02-10 19:01:32 -0800
commit3e7284014cb04bc66ae50004267aed4e4ada2d14 (patch)
tree7225214982416ce7244b85a41b6c77f39e905ec1 /host
parentb844bcc92ca53c6d9c7898a54de546b900b9dbdb (diff)
downloaduhd-3e7284014cb04bc66ae50004267aed4e4ada2d14.tar.gz
uhd-3e7284014cb04bc66ae50004267aed4e4ada2d14.tar.bz2
uhd-3e7284014cb04bc66ae50004267aed4e4ada2d14.zip
uhd: misc speedups w/ look up tables
use a look up table for io type size (in the case its used in the fast-path) move the static const pred table in vrt unpacker to the global level, for some reason this was incurring a malloc (perhaps because there were 2 tables).
Diffstat (limited to 'host')
-rwxr-xr-xhost/lib/transport/gen_vrt_if_packet.py3
-rw-r--r--host/lib/types/types.cpp19
2 files changed, 14 insertions, 8 deletions
diff --git a/host/lib/transport/gen_vrt_if_packet.py b/host/lib/transport/gen_vrt_if_packet.py
index 3ba562d68..427217eb6 100755
--- a/host/lib/transport/gen_vrt_if_packet.py
+++ b/host/lib/transport/gen_vrt_if_packet.py
@@ -66,6 +66,8 @@ static pred_table_type get_pred_unpack_table(void){
return table;
}
+static const pred_table_type pred_unpack_table(get_pred_unpack_table());
+
########################################################################
#def gen_code($XE_MACRO, $suffix)
########################################################################
@@ -168,7 +170,6 @@ void vrt::if_hdr_unpack_$(suffix)(
//if_packet_info.sob = bool(vrt_hdr_word & $hex(0x1 << 25)); //not implemented
//if_packet_info.eob = bool(vrt_hdr_word & $hex(0x1 << 24)); //not implemented
- static const pred_table_type pred_unpack_table(get_pred_unpack_table());
const pred_type pred = pred_unpack_table[pred_table_index(vrt_hdr_word)];
switch(pred){
diff --git a/host/lib/types/types.cpp b/host/lib/types/types.cpp
index c1be2ff6d..bf308a0b3 100644
--- a/host/lib/types/types.cpp
+++ b/host/lib/types/types.cpp
@@ -22,6 +22,7 @@
#include <boost/cstdint.hpp>
#include <stdexcept>
#include <complex>
+#include <vector>
using namespace uhd;
@@ -66,14 +67,18 @@ otw_type_t::otw_type_t(void):
/***********************************************************************
* io type
**********************************************************************/
+static std::vector<size_t> get_tid_size_table(void){
+ std::vector<size_t> table(128, 0);
+ table[size_t(io_type_t::COMPLEX_FLOAT64)] = sizeof(std::complex<double>);
+ table[size_t(io_type_t::COMPLEX_FLOAT32)] = sizeof(std::complex<float>);
+ table[size_t(io_type_t::COMPLEX_INT16)] = sizeof(std::complex<boost::int16_t>);
+ table[size_t(io_type_t::COMPLEX_INT8)] = sizeof(std::complex<boost::int8_t>);
+ return table;
+}
+
static size_t tid_to_size(io_type_t::tid_t tid){
- switch(tid){
- case io_type_t::COMPLEX_FLOAT64: return sizeof(std::complex<double>);
- case io_type_t::COMPLEX_FLOAT32: return sizeof(std::complex<float>);
- case io_type_t::COMPLEX_INT16: return sizeof(std::complex<boost::int16_t>);
- case io_type_t::COMPLEX_INT8: return sizeof(std::complex<boost::int8_t>);
- default: throw std::runtime_error("unknown io type tid");
- }
+ static const std::vector<size_t> size_table(get_tid_size_table());
+ return size_table[size_t(tid) & 0x7f];
}
io_type_t::io_type_t(tid_t tid)