From 86f12cd1c1c606bbfbc6f0ddbd98166fe9251a13 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 23 May 2011 13:37:05 -0700 Subject: uhd: added scaling factor to conversion routines --- host/lib/convert/convert_common.hpp | 40 +++++++++++++-------------------- host/lib/convert/convert_with_neon.cpp | 8 +++---- host/lib/convert/convert_with_sse2.cpp | 16 ++++++------- host/lib/convert/gen_convert_general.py | 8 +++---- 4 files changed, 32 insertions(+), 40 deletions(-) (limited to 'host/lib/convert') diff --git a/host/lib/convert/convert_common.hpp b/host/lib/convert/convert_common.hpp index c2ca233d9..7f513b124 100644 --- a/host/lib/convert/convert_common.hpp +++ b/host/lib/convert/convert_common.hpp @@ -27,7 +27,7 @@ static void fcn( \ const uhd::convert::input_type &inputs, \ const uhd::convert::output_type &outputs, \ - size_t nsamps \ + size_t nsamps, double scale_factor \ ); \ UHD_STATIC_BLOCK(register_##fcn##_##prio){ \ uhd::convert::register_converter(#fcn, fcn, prio); \ @@ -35,7 +35,7 @@ static void fcn( \ const uhd::convert::input_type &inputs, \ const uhd::convert::output_type &outputs, \ - size_t nsamps \ + size_t nsamps, double scale_factor \ ) /*********************************************************************** @@ -50,7 +50,7 @@ typedef boost::uint32_t item32_t; /*********************************************************************** * Convert complex short buffer to items32 **********************************************************************/ -static UHD_INLINE item32_t sc16_to_item32(sc16_t num){ +static UHD_INLINE item32_t sc16_to_item32(sc16_t num, double){ boost::uint16_t real = num.real(); boost::uint16_t imag = num.imag(); return (item32_t(real) << 16) | (item32_t(imag) << 0); @@ -59,7 +59,7 @@ static UHD_INLINE item32_t sc16_to_item32(sc16_t num){ /*********************************************************************** * Convert items32 buffer to complex short **********************************************************************/ -static UHD_INLINE sc16_t item32_to_sc16(item32_t item){ +static UHD_INLINE sc16_t item32_to_sc16(item32_t item, double){ return sc16_t( boost::int16_t(item >> 16), boost::int16_t(item >> 0) @@ -69,46 +69,38 @@ static UHD_INLINE sc16_t item32_to_sc16(item32_t item){ /*********************************************************************** * Convert complex float buffer to items32 (no swap) **********************************************************************/ -static const float shorts_per_float = float(32767); - -static UHD_INLINE item32_t fc32_to_item32(fc32_t num){ - boost::uint16_t real = boost::int16_t(num.real()*shorts_per_float); - boost::uint16_t imag = boost::int16_t(num.imag()*shorts_per_float); +static UHD_INLINE item32_t fc32_to_item32(fc32_t num, float scale_factor){ + boost::uint16_t real = boost::int16_t(num.real()*scale_factor); + boost::uint16_t imag = boost::int16_t(num.imag()*scale_factor); return (item32_t(real) << 16) | (item32_t(imag) << 0); } /*********************************************************************** * Convert items32 buffer to complex float **********************************************************************/ -static const float floats_per_short = float(1.0/shorts_per_float); - -static UHD_INLINE fc32_t item32_to_fc32(item32_t item){ +static UHD_INLINE fc32_t item32_to_fc32(item32_t item, float scale_factor){ return fc32_t( - float(boost::int16_t(item >> 16)*floats_per_short), - float(boost::int16_t(item >> 0)*floats_per_short) + float(boost::int16_t(item >> 16)*scale_factor), + float(boost::int16_t(item >> 0)*scale_factor) ); } /*********************************************************************** * Convert complex double buffer to items32 (no swap) **********************************************************************/ -static const double shorts_per_double = double(32767); - -static UHD_INLINE item32_t fc64_to_item32(fc64_t num){ - boost::uint16_t real = boost::int16_t(num.real()*shorts_per_double); - boost::uint16_t imag = boost::int16_t(num.imag()*shorts_per_double); +static UHD_INLINE item32_t fc64_to_item32(fc64_t num, double scale_factor){ + boost::uint16_t real = boost::int16_t(num.real()*scale_factor); + boost::uint16_t imag = boost::int16_t(num.imag()*scale_factor); return (item32_t(real) << 16) | (item32_t(imag) << 0); } /*********************************************************************** * Convert items32 buffer to complex double **********************************************************************/ -static const double doubles_per_short = double(1.0/shorts_per_double); - -static UHD_INLINE fc64_t item32_to_fc64(item32_t item){ +static UHD_INLINE fc64_t item32_to_fc64(item32_t item, double scale_factor){ return fc64_t( - float(boost::int16_t(item >> 16)*doubles_per_short), - float(boost::int16_t(item >> 0)*doubles_per_short) + float(boost::int16_t(item >> 16)*scale_factor), + float(boost::int16_t(item >> 0)*scale_factor) ); } diff --git a/host/lib/convert/convert_with_neon.cpp b/host/lib/convert/convert_with_neon.cpp index 3d677db5b..e5f08cad9 100644 --- a/host/lib/convert/convert_with_neon.cpp +++ b/host/lib/convert/convert_with_neon.cpp @@ -26,7 +26,7 @@ DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_CUSTOM){ size_t i; - float32x4_t Q0 = vdupq_n_f32(shorts_per_float); + float32x4_t Q0 = vdupq_n_f32(float(scale_factor)); for (i=0; i < (nsamps & ~0x03); i+=2) { float32x4_t Q1 = vld1q_f32(reinterpret_cast(&input[i])); float32x4_t Q2 = vmulq_f32(Q1, Q0); @@ -37,7 +37,7 @@ DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_CUSTOM){ } for (; i < nsamps; i++) - output[i] = fc32_to_item32(input[i]); + output[i] = fc32_to_item32(input[i], float(scale_factor)); } DECLARE_CONVERTER(convert_item32_1_to_fc32_1_nswap, PRIORITY_CUSTOM){ @@ -46,7 +46,7 @@ DECLARE_CONVERTER(convert_item32_1_to_fc32_1_nswap, PRIORITY_CUSTOM){ size_t i; - float32x4_t Q1 = vdupq_n_f32(floats_per_short); + float32x4_t Q1 = vdupq_n_f32(float(scale_factor)); for (i=0; i < (nsamps & ~0x03); i+=2) { int16x4_t D0 = vld1_s16(reinterpret_cast(&input[i])); int16x4_t D1 = vrev32_s16(D0); @@ -57,5 +57,5 @@ DECLARE_CONVERTER(convert_item32_1_to_fc32_1_nswap, PRIORITY_CUSTOM){ } for (; i < nsamps; i++) - output[i] = item32_to_fc32(input[i]); + output[i] = item32_to_fc32(input[i], float(scale_factor)); } diff --git a/host/lib/convert/convert_with_sse2.cpp b/host/lib/convert/convert_with_sse2.cpp index 96ee9134c..52beea24a 100644 --- a/host/lib/convert/convert_with_sse2.cpp +++ b/host/lib/convert/convert_with_sse2.cpp @@ -25,7 +25,7 @@ DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_CUSTOM){ const fc32_t *input = reinterpret_cast(inputs[0]); item32_t *output = reinterpret_cast(outputs[0]); - __m128 scalar = _mm_set_ps1(shorts_per_float); + __m128 scalar = _mm_set_ps1(float(scale_factor)); //convert blocks of samples with intrinsics size_t i = 0; for (; i < (nsamps & ~0x3); i+=4){ @@ -48,7 +48,7 @@ DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_CUSTOM){ //convert remainder for (; i < nsamps; i++){ - output[i] = fc32_to_item32(input[i]); + output[i] = fc32_to_item32(input[i], float(scale_factor)); } } @@ -56,7 +56,7 @@ DECLARE_CONVERTER(convert_fc32_1_to_item32_1_bswap, PRIORITY_CUSTOM){ const fc32_t *input = reinterpret_cast(inputs[0]); item32_t *output = reinterpret_cast(outputs[0]); - __m128 scalar = _mm_set_ps1(shorts_per_float); + __m128 scalar = _mm_set_ps1(float(scale_factor)); //convert blocks of samples with intrinsics size_t i = 0; for (; i < (nsamps & ~0x3); i+=4){ @@ -78,7 +78,7 @@ DECLARE_CONVERTER(convert_fc32_1_to_item32_1_bswap, PRIORITY_CUSTOM){ //convert remainder for (; i < nsamps; i++){ - output[i] = uhd::byteswap(fc32_to_item32(input[i])); + output[i] = uhd::byteswap(fc32_to_item32(input[i], float(scale_factor))); } } @@ -86,7 +86,7 @@ DECLARE_CONVERTER(convert_item32_1_to_fc32_1_nswap, PRIORITY_CUSTOM){ const item32_t *input = reinterpret_cast(inputs[0]); fc32_t *output = reinterpret_cast(outputs[0]); - __m128 scalar = _mm_set_ps1(floats_per_short/(1 << 16)); + __m128 scalar = _mm_set_ps1(float(scale_factor)/(1 << 16)); __m128i zeroi = _mm_setzero_si128(); //convert blocks of samples with intrinsics @@ -111,7 +111,7 @@ DECLARE_CONVERTER(convert_item32_1_to_fc32_1_nswap, PRIORITY_CUSTOM){ //convert remainder for (; i < nsamps; i++){ - output[i] = item32_to_fc32(input[i]); + output[i] = item32_to_fc32(input[i], float(scale_factor)); } } @@ -119,7 +119,7 @@ DECLARE_CONVERTER(convert_item32_1_to_fc32_1_bswap, PRIORITY_CUSTOM){ const item32_t *input = reinterpret_cast(inputs[0]); fc32_t *output = reinterpret_cast(outputs[0]); - __m128 scalar = _mm_set_ps1(floats_per_short/(1 << 16)); + __m128 scalar = _mm_set_ps1(float(scale_factor)/(1 << 16)); __m128i zeroi = _mm_setzero_si128(); //convert blocks of samples with intrinsics @@ -143,6 +143,6 @@ DECLARE_CONVERTER(convert_item32_1_to_fc32_1_bswap, PRIORITY_CUSTOM){ //convert remainder for (; i < nsamps; i++){ - output[i] = item32_to_fc32(uhd::byteswap(input[i])); + output[i] = item32_to_fc32(uhd::byteswap(input[i]), float(scale_factor)); } } diff --git a/host/lib/convert/gen_convert_general.py b/host/lib/convert/gen_convert_general.py index f03448047..8c3138bda 100644 --- a/host/lib/convert/gen_convert_general.py +++ b/host/lib/convert/gen_convert_general.py @@ -34,7 +34,7 @@ DECLARE_CONVERTER(convert_$(cpu_type)_1_to_item32_1_$(swap), PRIORITY_GENERAL){ item32_t *output = reinterpret_cast(outputs[0]); for (size_t i = 0; i < nsamps; i++){ - output[i] = $(swap_fcn)($(cpu_type)_to_item32(input[i])); + output[i] = $(swap_fcn)($(cpu_type)_to_item32(input[i], float(scale_factor))); } } @@ -43,7 +43,7 @@ DECLARE_CONVERTER(convert_item32_1_to_$(cpu_type)_1_$(swap), PRIORITY_GENERAL){ $(cpu_type)_t *output = reinterpret_cast<$(cpu_type)_t *>(outputs[0]); for (size_t i = 0; i < nsamps; i++){ - output[i] = item32_to_$(cpu_type)($(swap_fcn)(input[i])); + output[i] = item32_to_$(cpu_type)($(swap_fcn)(input[i]), float(scale_factor)); } } """ @@ -56,7 +56,7 @@ DECLARE_CONVERTER(convert_$(cpu_type)_$(width)_to_item32_1_$(swap), PRIORITY_GEN for (size_t i = 0, j = 0; i < nsamps; i++){ #for $w in range($width) - output[j++] = $(swap_fcn)($(cpu_type)_to_item32(input$(w)[i])); + output[j++] = $(swap_fcn)($(cpu_type)_to_item32(input$(w)[i], float(scale_factor))); #end for } } @@ -69,7 +69,7 @@ DECLARE_CONVERTER(convert_item32_1_to_$(cpu_type)_$(width)_$(swap), PRIORITY_GEN for (size_t i = 0, j = 0; i < nsamps; i++){ #for $w in range($width) - output$(w)[i] = item32_to_$(cpu_type)($(swap_fcn)(input[j++])); + output$(w)[i] = item32_to_$(cpu_type)($(swap_fcn)(input[j++]), float(scale_factor)); #end for } } -- cgit v1.2.3 From 29735b8e67138147ca5327b098274fa2bd2a44ca Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 23 May 2011 18:49:08 -0700 Subject: UHD: Orc implementation added and CMake magic put in. Won't link. --- host/lib/convert/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ host/lib/convert/convert_orc.orc | 11 +++++++++++ host/lib/convert/convert_with_orc.cpp | 30 ++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 host/lib/convert/convert_orc.orc create mode 100644 host/lib/convert/convert_with_orc.cpp (limited to 'host/lib/convert') diff --git a/host/lib/convert/CMakeLists.txt b/host/lib/convert/CMakeLists.txt index d189aa687..5b05bb72a 100644 --- a/host/lib/convert/CMakeLists.txt +++ b/host/lib/convert/CMakeLists.txt @@ -54,6 +54,37 @@ IF(HAVE_ARM_NEON_H) ) ENDIF(HAVE_ARM_NEON_H) +######################################################################## +# Look for Orc support +######################################################################## +FIND_PACKAGE(PkgConfig) +IF(PKG_CONFIG_FOUND) +PKG_CHECK_MODULES(ORC "orc-0.4") +ENDIF(PKG_CONFIG_FOUND) + +FIND_PROGRAM(ORCC_EXECUTABLE orcc) + +IF(ORC_FOUND AND ORCC_EXECUTABLE) + INCLUDE_DIRECTORIES(${ORC_INCLUDE_DIRS}) + LINK_DIRECTORIES(${ORC_LIBRARY_DIRS}) + + SET(orcc_src ${CMAKE_CURRENT_SOURCE_DIR}/convert_orc.orc) + + GET_FILENAME_COMPONENT(orc_file_name_we ${orcc_src} NAME_WE) + SET(orcc_gen ${CMAKE_CURRENT_BINARY_DIR}/${orc_file_name_we}.c) + MESSAGE(STATUS "orcc_gen is ${orcc_gen}, orcc_src is ${orcc_src}") + ADD_CUSTOM_COMMAND( + COMMAND ${ORCC_EXECUTABLE} --implementation -o ${orcc_gen} ${orcc_src} + DEPENDS ${orcc_src} OUTPUT ${orcc_gen} + ) + LIBUHD_APPEND_SOURCES(${orcc_gen}) + LIBUHD_APPEND_SOURCES( + ${CMAKE_CURRENT_SOURCE_DIR}/convert_with_orc.cpp + ) +ELSE() + MESSAGE(STATUS "Orc not found, disabling orc support...") +ENDIF(ORC_FOUND AND ORCC_EXECUTABLE) + ######################################################################## # Convert types generation ######################################################################## diff --git a/host/lib/convert/convert_orc.orc b/host/lib/convert/convert_orc.orc new file mode 100644 index 000000000..5704d4b58 --- /dev/null +++ b/host/lib/convert/convert_orc.orc @@ -0,0 +1,11 @@ +.function _convert_fc32_1_to_item32_1_nswap_orc +.source 8 src +.dest 4 dst +.floatparam 4 scalar +.temp 8 scaled +.temp 4 converted + +x2 mulf scaled, src, scalar +x2 convfw converted, scaled +swapl converted, converted +x2 swapw dst, converted diff --git a/host/lib/convert/convert_with_orc.cpp b/host/lib/convert/convert_with_orc.cpp new file mode 100644 index 000000000..dded22b9d --- /dev/null +++ b/host/lib/convert/convert_with_orc.cpp @@ -0,0 +1,30 @@ +// +// Copyright 2011 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 this program. If not, see . +// + +#include "convert_common.hpp" +#include +#include + +using namespace uhd::convert; + +extern "C" { +extern void _convert_fc32_1_to_item32_1_nswap_orc(void *, const void *, float, int); +} + +DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_LIBORC){ + _convert_fc32_1_to_item32_1_nswap_orc(outputs[0], inputs[0], scale_factor, nsamps); +} -- cgit v1.2.3 From 75d0a41c3a7a2c7cd62a6c6b27e648d5617d488e Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 23 May 2011 19:06:43 -0700 Subject: UHD: Orc conversion routine works --- host/lib/convert/CMakeLists.txt | 2 ++ host/lib/convert/convert_orc.orc | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'host/lib/convert') diff --git a/host/lib/convert/CMakeLists.txt b/host/lib/convert/CMakeLists.txt index 5b05bb72a..e8d933f34 100644 --- a/host/lib/convert/CMakeLists.txt +++ b/host/lib/convert/CMakeLists.txt @@ -67,6 +67,7 @@ FIND_PROGRAM(ORCC_EXECUTABLE orcc) IF(ORC_FOUND AND ORCC_EXECUTABLE) INCLUDE_DIRECTORIES(${ORC_INCLUDE_DIRS}) LINK_DIRECTORIES(${ORC_LIBRARY_DIRS}) + ENABLE_LANGUAGE(C) SET(orcc_src ${CMAKE_CURRENT_SOURCE_DIR}/convert_orc.orc) @@ -81,6 +82,7 @@ IF(ORC_FOUND AND ORCC_EXECUTABLE) LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/convert_with_orc.cpp ) + LIBUHD_APPEND_LIBS(${ORC_LIBRARIES}) ELSE() MESSAGE(STATUS "Orc not found, disabling orc support...") ENDIF(ORC_FOUND AND ORCC_EXECUTABLE) diff --git a/host/lib/convert/convert_orc.orc b/host/lib/convert/convert_orc.orc index 5704d4b58..c1c3d3c24 100644 --- a/host/lib/convert/convert_orc.orc +++ b/host/lib/convert/convert_orc.orc @@ -3,9 +3,11 @@ .dest 4 dst .floatparam 4 scalar .temp 8 scaled -.temp 4 converted +.temp 8 converted +.temp 4 short x2 mulf scaled, src, scalar -x2 convfw converted, scaled -swapl converted, converted -x2 swapw dst, converted +x2 convfl converted, scaled +x2 convlw short, converted +swapl short, short +x2 swapw dst, short -- cgit v1.2.3 From 3dca19a3e7f56c64423789ee025f16150b1a2cdb Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 23 May 2011 21:49:28 -0700 Subject: UHD: Fixed convert_test (scalars backwards), fixed Orc conversions (endianness backwards). --- host/include/uhd/convert.hpp | 2 +- host/lib/convert/convert_orc.orc | 13 +++++++++++++ host/lib/convert/convert_with_orc.cpp | 5 +++++ host/tests/convert_test.cpp | 10 +++++----- 4 files changed, 24 insertions(+), 6 deletions(-) (limited to 'host/lib/convert') diff --git a/host/include/uhd/convert.hpp b/host/include/uhd/convert.hpp index 99f1860ae..c30484384 100644 --- a/host/include/uhd/convert.hpp +++ b/host/include/uhd/convert.hpp @@ -40,7 +40,7 @@ namespace uhd{ namespace convert{ */ enum priority_type{ PRIORITY_GENERAL = 0, - PRIORITY_LIBORC = 1, + PRIORITY_LIBORC = 4, PRIORITY_CUSTOM = 2, PRIORITY_EMPTY = -1, }; diff --git a/host/lib/convert/convert_orc.orc b/host/lib/convert/convert_orc.orc index c1c3d3c24..83e63f22c 100644 --- a/host/lib/convert/convert_orc.orc +++ b/host/lib/convert/convert_orc.orc @@ -11,3 +11,16 @@ x2 convfl converted, scaled x2 convlw short, converted swapl short, short x2 swapw dst, short + +.function _convert_fc32_1_to_item32_1_bswap_orc +.source 8 src +.dest 4 dst +.floatparam 4 scalar +.temp 8 scaled +.temp 8 converted +.temp 4 short + +x2 mulf scaled, src, scalar +x2 convfl converted, scaled +x2 convlw short, converted +x2 swapw dst, short diff --git a/host/lib/convert/convert_with_orc.cpp b/host/lib/convert/convert_with_orc.cpp index dded22b9d..2d50351e4 100644 --- a/host/lib/convert/convert_with_orc.cpp +++ b/host/lib/convert/convert_with_orc.cpp @@ -23,8 +23,13 @@ using namespace uhd::convert; extern "C" { extern void _convert_fc32_1_to_item32_1_nswap_orc(void *, const void *, float, int); +extern void _convert_fc32_1_to_item32_1_bswap_orc(void *, const void *, float, int); } DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_LIBORC){ _convert_fc32_1_to_item32_1_nswap_orc(outputs[0], inputs[0], scale_factor, nsamps); } + +DECLARE_CONVERTER(convert_fc32_1_to_item32_1_bswap, PRIORITY_LIBORC){ + _convert_fc32_1_to_item32_1_bswap_orc(outputs[0], inputs[0], scale_factor, nsamps); +} diff --git a/host/tests/convert_test.cpp b/host/tests/convert_test.cpp index ff37d4a0a..d828ed64a 100644 --- a/host/tests/convert_test.cpp +++ b/host/tests/convert_test.cpp @@ -31,7 +31,7 @@ typedef std::complex sc16_t; typedef std::complex fc32_t; typedef std::complex fc64_t; -#define MY_CHECK_CLOSE(a, b, f) if ((std::abs(a) > (f) and std::abs(b) > (f))) \ +#define MY_CHECK_CLOSE(a, b, f) if ((std::abs(a) > (f))) \ BOOST_CHECK_CLOSE_FRACTION(a, b, f) /*********************************************************************** @@ -55,12 +55,12 @@ template static void loopback( //convert to intermediate type convert::get_converter_cpu_to_otw( io_type, otw_type, input0.size(), output0.size() - )(input0, output0, nsamps, 1/32767.); + )(input0, output0, nsamps, 32767.); //convert back to host type convert::get_converter_otw_to_cpu( io_type, otw_type, input1.size(), output1.size() - )(input1, output1, nsamps, 32767.); + )(input1, output1, nsamps, 1/32767.); } /*********************************************************************** @@ -207,12 +207,12 @@ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){ //convert float to intermediate convert::get_converter_cpu_to_otw( io_type_in, otw_type, input0.size(), output0.size() - )(input0, output0, nsamps, 1/32767.); + )(input0, output0, nsamps, 32767.); //convert intermediate to short convert::get_converter_otw_to_cpu( io_type_out, otw_type, input1.size(), output1.size() - )(input1, output1, nsamps, 32767.); + )(input1, output1, nsamps, 1/32767.); //test that the inputs and outputs match for (size_t i = 0; i < nsamps; i++){ -- cgit v1.2.3 From 00ee732c00fa74054117ef703afa1bf30bf53f50 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 23 May 2011 22:36:51 -0700 Subject: UHD: added item32<->sc16 conversions in Orc --- host/include/uhd/convert.hpp | 2 +- host/lib/convert/convert_orc.orc | 39 +++++++++++++++++++++++++++++++++-- host/lib/convert/convert_with_orc.cpp | 20 ++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) (limited to 'host/lib/convert') diff --git a/host/include/uhd/convert.hpp b/host/include/uhd/convert.hpp index c30484384..99f1860ae 100644 --- a/host/include/uhd/convert.hpp +++ b/host/include/uhd/convert.hpp @@ -40,7 +40,7 @@ namespace uhd{ namespace convert{ */ enum priority_type{ PRIORITY_GENERAL = 0, - PRIORITY_LIBORC = 4, + PRIORITY_LIBORC = 1, PRIORITY_CUSTOM = 2, PRIORITY_EMPTY = -1, }; diff --git a/host/lib/convert/convert_orc.orc b/host/lib/convert/convert_orc.orc index 83e63f22c..78718d229 100644 --- a/host/lib/convert/convert_orc.orc +++ b/host/lib/convert/convert_orc.orc @@ -5,7 +5,6 @@ .temp 8 scaled .temp 8 converted .temp 4 short - x2 mulf scaled, src, scalar x2 convfl converted, scaled x2 convlw short, converted @@ -19,8 +18,44 @@ x2 swapw dst, short .temp 8 scaled .temp 8 converted .temp 4 short - x2 mulf scaled, src, scalar x2 convfl converted, scaled x2 convlw short, converted x2 swapw dst, short + +.function _convert_item32_1_to_fc32_1_nswap_orc +.source 4 src +.dest 8 dst +.floatparam 4 scalar +.temp 4 tmp1 +.temp 8 tmp2 +x2 swapw tmp1, src +swapl tmp1, tmp1 +x2 convswl tmp2, tmp1 +x2 convlf tmp2, tmp2 +x2 mulf dst, tmp2, scalar + +.function _convert_item32_1_to_fc32_1_bswap_orc +.source 4 src +.dest 8 dst +.floatparam 4 scalar +.temp 4 tmp1 +.temp 8 tmp2 +x2 swapw tmp1, src +x2 convswl tmp2, tmp1 +x2 convlf tmp2, tmp2 +x2 mulf dst, tmp2, scalar + +.function _convert_sc16_1_to_item32_1_nswap_orc +.source 4 src +.dest 4 dst +.floatparam 4 scalar +swapl dst, src +x2 swapw dst, dst + +.function _convert_item32_1_to_sc16_1_nswap_orc +.source 4 src +.dest 4 dst +.floatparam 4 scalar +x2 swapw dst, src +swapl dst, dst diff --git a/host/lib/convert/convert_with_orc.cpp b/host/lib/convert/convert_with_orc.cpp index 2d50351e4..6f2f47784 100644 --- a/host/lib/convert/convert_with_orc.cpp +++ b/host/lib/convert/convert_with_orc.cpp @@ -24,6 +24,10 @@ using namespace uhd::convert; extern "C" { extern void _convert_fc32_1_to_item32_1_nswap_orc(void *, const void *, float, int); extern void _convert_fc32_1_to_item32_1_bswap_orc(void *, const void *, float, int); +extern void _convert_item32_1_to_fc32_1_nswap_orc(void *, const void *, float, int); +extern void _convert_item32_1_to_fc32_1_bswap_orc(void *, const void *, float, int); +extern void _convert_sc16_1_to_item32_1_nswap_orc(void *, const void *, float, int); +extern void _convert_item32_1_to_sc16_1_nswap_orc(void *, const void *, float, int); } DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_LIBORC){ @@ -33,3 +37,19 @@ DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_LIBORC){ DECLARE_CONVERTER(convert_fc32_1_to_item32_1_bswap, PRIORITY_LIBORC){ _convert_fc32_1_to_item32_1_bswap_orc(outputs[0], inputs[0], scale_factor, nsamps); } + +DECLARE_CONVERTER(convert_item32_1_to_fc32_1_nswap, PRIORITY_LIBORC){ + _convert_item32_1_to_fc32_1_nswap_orc(outputs[0], inputs[0], scale_factor, nsamps); +} + +DECLARE_CONVERTER(convert_item32_1_to_fc32_1_bswap, PRIORITY_LIBORC){ + _convert_item32_1_to_fc32_1_bswap_orc(outputs[0], inputs[0], scale_factor, nsamps); +} + +DECLARE_CONVERTER(convert_sc16_1_to_item32_1_nswap, PRIORITY_LIBORC){ + _convert_sc16_1_to_item32_1_nswap_orc(outputs[0], inputs[0], scale_factor, nsamps); +} + +DECLARE_CONVERTER(convert_item32_1_to_sc16_1_nswap, PRIORITY_LIBORC){ + _convert_item32_1_to_sc16_1_nswap_orc(outputs[0], inputs[0], scale_factor, nsamps); +} -- cgit v1.2.3 From 179505fd5b5cefa11eaf7d159506c921af725855 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 6 Jun 2011 10:27:52 -0700 Subject: use temp vars in sc16->item32 to make orcc happy --- host/lib/convert/convert_orc.orc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'host/lib/convert') diff --git a/host/lib/convert/convert_orc.orc b/host/lib/convert/convert_orc.orc index 78718d229..5450bf4db 100644 --- a/host/lib/convert/convert_orc.orc +++ b/host/lib/convert/convert_orc.orc @@ -49,13 +49,15 @@ x2 mulf dst, tmp2, scalar .function _convert_sc16_1_to_item32_1_nswap_orc .source 4 src .dest 4 dst +.temp 4 tmp .floatparam 4 scalar -swapl dst, src -x2 swapw dst, dst +swapl tmp, src +x2 swapw dst, tmp .function _convert_item32_1_to_sc16_1_nswap_orc .source 4 src .dest 4 dst .floatparam 4 scalar -x2 swapw dst, src -swapl dst, dst +.temp 4 tmp +x2 swapw tmp, src +swapl dst, tmp -- cgit v1.2.3 From a1b675a4d8e902a45ff0f58e5e018536814e16bb Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 6 Jun 2011 15:53:15 -0700 Subject: Remove unnecessary include --- host/lib/convert/convert_with_orc.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'host/lib/convert') diff --git a/host/lib/convert/convert_with_orc.cpp b/host/lib/convert/convert_with_orc.cpp index 6f2f47784..844c2595c 100644 --- a/host/lib/convert/convert_with_orc.cpp +++ b/host/lib/convert/convert_with_orc.cpp @@ -17,7 +17,6 @@ #include "convert_common.hpp" #include -#include using namespace uhd::convert; -- cgit v1.2.3 From 85ebb705fa567e8093aa68c0ad88996d434ed2bf Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Tue, 7 Jun 2011 10:53:54 -0700 Subject: NEON detection for E100 in convert/ --- host/lib/convert/CMakeLists.txt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'host/lib/convert') diff --git a/host/lib/convert/CMakeLists.txt b/host/lib/convert/CMakeLists.txt index e8d933f34..5f05b0cb8 100644 --- a/host/lib/convert/CMakeLists.txt +++ b/host/lib/convert/CMakeLists.txt @@ -26,6 +26,7 @@ MESSAGE(STATUS "") ######################################################################## IF(CMAKE_COMPILER_IS_GNUCXX) SET(EMMINTRIN_FLAGS -msse2) + SET(NEON_FLAGS "-mfloat-abi=softfp -mfpu=neon") ELSEIF(MSVC) SET(EMMINTRIN_FLAGS /arch:SSE2) ENDIF() @@ -47,13 +48,21 @@ ENDIF(HAVE_EMMINTRIN_H) ######################################################################## # Check for NEON SIMD headers ######################################################################## +SET(CMAKE_REQUIRED_FLAGS ${NEON_FLAGS}) CHECK_INCLUDE_FILE_CXX(arm_neon.h HAVE_ARM_NEON_H) -IF(HAVE_ARM_NEON_H) +UNSET(CMAKE_REQUIRED_FLAGS) +if(HAVE_ARM_NEON_H) + MESSAGE(STATUS "Enabling NEON support") + SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/convert_with_neon.cpp + PROPERTIES COMPILE_FLAGS "${NEON_FLAGS}" + ) LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/convert_with_neon.cpp ) -ENDIF(HAVE_ARM_NEON_H) - +else(HAVE_ARM_NEON_H) + MESSAGE(STATUS "Disabling NEON support") +endif(HAVE_ARM_NEON_H) ######################################################################## # Look for Orc support ######################################################################## @@ -73,7 +82,7 @@ IF(ORC_FOUND AND ORCC_EXECUTABLE) GET_FILENAME_COMPONENT(orc_file_name_we ${orcc_src} NAME_WE) SET(orcc_gen ${CMAKE_CURRENT_BINARY_DIR}/${orc_file_name_we}.c) - MESSAGE(STATUS "orcc_gen is ${orcc_gen}, orcc_src is ${orcc_src}") + MESSAGE(STATUS "Orc found, enabling Orc support") ADD_CUSTOM_COMMAND( COMMAND ${ORCC_EXECUTABLE} --implementation -o ${orcc_gen} ${orcc_src} DEPENDS ${orcc_src} OUTPUT ${orcc_gen} -- cgit v1.2.3