diff options
author | Tom Rondeau | 2010-12-07 18:50:28 -0500 |
---|---|---|
committer | Tom Rondeau | 2010-12-07 18:50:28 -0500 |
commit | 239144659b29c0a5ecd83a34e0e57387a1060ed7 (patch) | |
tree | 3476e1c123da4696c64cc1756ddec5d971bcf9f2 /volk/include/volk/volk_16s_convert_8s_unaligned16.h | |
parent | e13783aeb84a2c3656c3344a8d52fa2c9ee38a00 (diff) | |
download | gnuradio-239144659b29c0a5ecd83a34e0e57387a1060ed7.tar.gz gnuradio-239144659b29c0a5ecd83a34e0e57387a1060ed7.tar.bz2 gnuradio-239144659b29c0a5ecd83a34e0e57387a1060ed7.zip |
Initial checkin for VOLK - Vector-Optimized Library of Kernels. This is a new SIMD library.
It currently stands by itself under the GNU Radio tree and can be used separately. We will integrate the build process into GNU Raio and start building off of its functionality over time.
Diffstat (limited to 'volk/include/volk/volk_16s_convert_8s_unaligned16.h')
-rw-r--r-- | volk/include/volk/volk_16s_convert_8s_unaligned16.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/volk/include/volk/volk_16s_convert_8s_unaligned16.h b/volk/include/volk/volk_16s_convert_8s_unaligned16.h new file mode 100644 index 000000000..ca925de86 --- /dev/null +++ b/volk/include/volk/volk_16s_convert_8s_unaligned16.h @@ -0,0 +1,71 @@ +#ifndef INCLUDED_VOLK_16s_CONVERT_8s_UNALIGNED16_H +#define INCLUDED_VOLK_16s_CONVERT_8s_UNALIGNED16_H + +#include <inttypes.h> +#include <stdio.h> + +#if LV_HAVE_SSE2 +#include <emmintrin.h> +/*! + \brief Converts the input 16 bit integer data into 8 bit integer data + \param inputVector The 16 bit input data buffer + \param outputVector The 8 bit output data buffer + \param num_points The number of data values to be converted + \note Input and output buffers do NOT need to be properly aligned +*/ +static inline void volk_16s_convert_8s_unaligned16_sse2(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){ + unsigned int number = 0; + const unsigned int sixteenthPoints = num_points / 16; + + int8_t* outputVectorPtr = outputVector; + int16_t* inputPtr = (int16_t*)inputVector; + __m128i inputVal1; + __m128i inputVal2; + __m128i ret; + + for(;number < sixteenthPoints; number++){ + + // Load the 16 values + inputVal1 = _mm_loadu_si128((__m128i*)inputPtr); inputPtr += 8; + inputVal2 = _mm_loadu_si128((__m128i*)inputPtr); inputPtr += 8; + + inputVal1 = _mm_srai_epi16(inputVal1, 8); + inputVal2 = _mm_srai_epi16(inputVal2, 8); + + ret = _mm_packs_epi16(inputVal1, inputVal2); + + _mm_storeu_si128((__m128i*)outputVectorPtr, ret); + + outputVectorPtr += 16; + } + + number = sixteenthPoints * 16; + for(; number < num_points; number++){ + outputVector[number] =(int8_t)(inputVector[number] >> 8); + } +} +#endif /* LV_HAVE_SSE2 */ + +#ifdef LV_HAVE_GENERIC +/*! + \brief Converts the input 16 bit integer data into 8 bit integer data + \param inputVector The 16 bit input data buffer + \param outputVector The 8 bit output data buffer + \param num_points The number of data values to be converted + \note Input and output buffers do NOT need to be properly aligned +*/ +static inline void volk_16s_convert_8s_unaligned16_generic(int8_t* outputVector, const int16_t* inputVector, unsigned int num_points){ + int8_t* outputVectorPtr = outputVector; + const int16_t* inputVectorPtr = inputVector; + unsigned int number = 0; + + for(number = 0; number < num_points; number++){ + *outputVectorPtr++ = ((int8_t)(*inputVectorPtr++ >> 8)); + } +} +#endif /* LV_HAVE_GENERIC */ + + + + +#endif /* INCLUDED_VOLK_16s_CONVERT_8s_UNALIGNED16_H */ |