From a094f2a6373552c74657c73d048a938bcdeb6907 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 26 Jun 2010 00:33:37 -0700 Subject: uhd: moron alert, used incorrect bounds in simd loop, the remainder loop was doing 3/4 the work --- host/lib/transport/convert_types_impl.hpp | 4 ++-- host/lib/transport/gen_convert_types.py | 19 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'host/lib/transport') diff --git a/host/lib/transport/convert_types_impl.hpp b/host/lib/transport/convert_types_impl.hpp index ca1be175c..5958b08cb 100644 --- a/host/lib/transport/convert_types_impl.hpp +++ b/host/lib/transport/convert_types_impl.hpp @@ -99,7 +99,7 @@ static UHD_INLINE void fc32_to_item32_bswap( __m128 scalar = _mm_set_ps1(shorts_per_float); //convert blocks of samples with intrinsics - size_t i = 0; for (; i < nsamps/4; i+=4){ + size_t i = 0; for (; i < (nsamps & ~0x3); i+=4){ //load from input __m128 tmplo = _mm_loadu_ps(reinterpret_cast(input+i+0)); __m128 tmphi = _mm_loadu_ps(reinterpret_cast(input+i+2)); @@ -163,7 +163,7 @@ static UHD_INLINE void item32_to_fc32_bswap( __m128i zeroi = _mm_setzero_si128(); //convert blocks of samples with intrinsics - size_t i = 0; for (; i < nsamps/4; i+=4){ + size_t i = 0; for (; i < (nsamps & ~0x3); i+=4){ //load from input __m128i tmpi = _mm_loadu_si128(reinterpret_cast(input+i)); diff --git a/host/lib/transport/gen_convert_types.py b/host/lib/transport/gen_convert_types.py index b37fe242b..951b634d9 100755 --- a/host/lib/transport/gen_convert_types.py +++ b/host/lib/transport/gen_convert_types.py @@ -29,12 +29,6 @@ TMPL_TEXT = """ \#include \#include "convert_types_impl.hpp" -\#ifdef BOOST_BIG_ENDIAN - static const bool is_big_endian = true; -\#else - static const bool is_big_endian = false; -\#endif - using namespace uhd; /*********************************************************************** @@ -47,15 +41,20 @@ UHD_INLINE boost::uint8_t get_pred( boost::uint8_t pred = 0; switch(otw_type.byteorder){ - case otw_type_t::BO_BIG_ENDIAN: pred |= (is_big_endian)? $ph.nswap_p : $ph.bswap_p; break; - case otw_type_t::BO_LITTLE_ENDIAN: pred |= (is_big_endian)? $ph.bswap_p : $ph.nswap_p; break; + \#ifdef BOOST_BIG_ENDIAN + case otw_type_t::BO_BIG_ENDIAN: pred |= $ph.nswap_p; break; + case otw_type_t::BO_LITTLE_ENDIAN: pred |= $ph.bswap_p; break; + \#else + case otw_type_t::BO_BIG_ENDIAN: pred |= $ph.bswap_p; break; + case otw_type_t::BO_LITTLE_ENDIAN: pred |= $ph.nswap_p; break; + \#endif case otw_type_t::BO_NATIVE: pred |= $ph.nswap_p; break; - default: throw std::runtime_error("unhandled byteorder type"); + default: throw std::runtime_error("unhandled otw byteorder type"); } switch(otw_type.get_sample_size()){ case sizeof(boost::uint32_t): pred |= $ph.item32_p; break; - default: throw std::runtime_error("unhandled bit width"); + default: throw std::runtime_error("unhandled otw sample size"); } switch(io_type.tid){ -- cgit v1.2.3