From dd782308940e4b206e798eb2f0fa203b6e8c7f07 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 12 Nov 2011 15:45:52 -0800 Subject: convert: made conversion functions into classes so they can keep state --- host/include/uhd/convert.hpp | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/convert.hpp b/host/include/uhd/convert.hpp index c42edfdec..6cc729819 100644 --- a/host/include/uhd/convert.hpp +++ b/host/include/uhd/convert.hpp @@ -20,17 +20,35 @@ #include #include +#include #include #include #include namespace uhd{ namespace convert{ - typedef uhd::ref_vector output_type; - typedef uhd::ref_vector input_type; + //! A conversion class that implements a conversion from inputs -> outputs. + class converter{ + public: + typedef boost::shared_ptr sptr; + typedef uhd::ref_vector output_type; + typedef uhd::ref_vector input_type; - //! input vectors, output vectors, num samples, scale factor - typedef boost::function function_type; + //! Set the scale factor (used in floating point conversions) + virtual void set_scalar(const double) = 0; + + //! The public conversion method to convert inputs -> outputs + UHD_INLINE void conv(const input_type &in, const output_type &out, const size_t num){ + if (num != 0) (*this)(in, out, num); + } + + private: + //! Callable method: input vectors, output vectors, num samples + virtual void operator()(const input_type&, const output_type&, const size_t) = 0; + }; + + //! Conversion factory function typedef + typedef boost::function function_type; /*! * Describe the priority of a converter function. @@ -43,7 +61,8 @@ namespace uhd{ namespace convert{ PRIORITY_GENERAL = 0, PRIORITY_LIBORC = 1, PRIORITY_SIMD = 2, - PRIORITY_CUSTOM = 3, + PRIORITY_TABLE = 3, + PRIORITY_CUSTOM = 4, PRIORITY_EMPTY = -1, }; @@ -62,19 +81,19 @@ namespace uhd{ namespace convert{ /*! * Register a converter function. * \param id identify the conversion - * \param fcn a pointer to the converter + * \param fcn makes a new converter * \param prio the function priority */ UHD_API void register_converter( const id_type &id, - function_type fcn, - priority_type prio + const function_type &fcn, + const priority_type prio ); /*! - * Get a converter function. + * Get a converter factory function. * \param id identify the conversion - * \return the converter function + * \return the converter factory function */ UHD_API function_type get_converter(const id_type &id); -- cgit v1.2.3 From aed619727e47bf2353164ac1788a6e3479b2fe16 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 15 Nov 2011 06:12:28 +0000 Subject: convert: move priorities to implementation, different for arm --- host/include/uhd/convert.hpp | 17 ++--------------- host/lib/convert/CMakeLists.txt | 6 +----- host/lib/convert/convert_common.hpp | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 20 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/convert.hpp b/host/include/uhd/convert.hpp index 6cc729819..f906ff0e9 100644 --- a/host/include/uhd/convert.hpp +++ b/host/include/uhd/convert.hpp @@ -50,21 +50,8 @@ namespace uhd{ namespace convert{ //! Conversion factory function typedef typedef boost::function function_type; - /*! - * Describe the priority of a converter function. - * A higher priority function takes precedence. - * The general case function are the lowest. - * Next comes the liborc implementations. - * Custom intrinsics implementations are highest. - */ - enum priority_type{ - PRIORITY_GENERAL = 0, - PRIORITY_LIBORC = 1, - PRIORITY_SIMD = 2, - PRIORITY_TABLE = 3, - PRIORITY_CUSTOM = 4, - PRIORITY_EMPTY = -1, - }; + //! Priority of conversion routines + typedef int priority_type; //! Identify a conversion routine in the registry struct id_type : boost::equality_comparable{ diff --git a/host/lib/convert/CMakeLists.txt b/host/lib/convert/CMakeLists.txt index 1fe92d93a..98907dc29 100644 --- a/host/lib/convert/CMakeLists.txt +++ b/host/lib/convert/CMakeLists.txt @@ -91,11 +91,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX) UNSET(CMAKE_REQUIRED_FLAGS) ENDIF(CMAKE_COMPILER_IS_GNUCXX) -IF(HAVE_ARM_NEON_H AND ENABLE_ORC) - #prefer orc support, its faster than the current intrinsic implementations - MESSAGE(STATUS "Enabled conversion support with ORC.") -ELSEIF(HAVE_ARM_NEON_H) - MESSAGE(STATUS "Enabled conversion support with NEON intrinsics.") +IF(HAVE_ARM_NEON_H) SET_SOURCE_FILES_PROPERTIES( ${CMAKE_CURRENT_SOURCE_DIR}/convert_with_neon.cpp PROPERTIES COMPILE_FLAGS "${NEON_FLAGS}" diff --git a/host/lib/convert/convert_common.hpp b/host/lib/convert/convert_common.hpp index f963e29ee..cc287114a 100644 --- a/host/lib/convert/convert_common.hpp +++ b/host/lib/convert/convert_common.hpp @@ -45,6 +45,22 @@ #define DECLARE_CONVERTER(in_form, num_in, out_form, num_out, prio) \ _DECLARE_CONVERTER(__convert_##in_form##_##num_in##_##out_form##_##num_out##_##prio, in_form, num_in, out_form, num_out, prio) +/*********************************************************************** + * Setup priorities + **********************************************************************/ +static const int PRIORITY_GENERAL = 0; +static const int PRIORITY_EMPTY = -1; + +#ifdef __ARM_NEON__ +static const int PRIORITY_LIBORC = 3; +static const int PRIORITY_SIMD = 1; //neon conversions could be implemented better, orc wins +static const int PRIORITY_TABLE = 2; //tables require large cache, so they are slower on arm +#else +static const int PRIORITY_LIBORC = 1; +static const int PRIORITY_SIMD = 2; +static const int PRIORITY_TABLE = 3; +#endif + /*********************************************************************** * Typedefs **********************************************************************/ -- cgit v1.2.3