GNU Radio 3.6.5 C++ API

volk_16i_s32f_convert_32f_u.h

Go to the documentation of this file.
00001 #ifndef INCLUDED_volk_16i_s32f_convert_32f_u_H
00002 #define INCLUDED_volk_16i_s32f_convert_32f_u_H
00003 
00004 #include <inttypes.h>
00005 #include <stdio.h>
00006 
00007 #ifdef LV_HAVE_SSE4_1
00008 #include <smmintrin.h>
00009 
00010   /*!
00011     \brief Converts the input 16 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
00012     \param inputVector The 16 bit input data buffer
00013     \param outputVector The floating point output data buffer
00014     \param scalar The value divided against each point in the output buffer
00015     \param num_points The number of data values to be converted
00016     \note Output buffer does NOT need to be properly aligned
00017   */
00018 static inline void volk_16i_s32f_convert_32f_u_sse4_1(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){
00019     unsigned int number = 0;
00020     const unsigned int eighthPoints = num_points / 8;
00021 
00022      float* outputVectorPtr = outputVector;
00023     __m128 invScalar = _mm_set_ps1(1.0/scalar);
00024     int16_t* inputPtr = (int16_t*)inputVector;
00025     __m128i inputVal;
00026     __m128i inputVal2;
00027     __m128 ret;
00028 
00029     for(;number < eighthPoints; number++){
00030 
00031       // Load the 8 values
00032       inputVal = _mm_loadu_si128((__m128i*)inputPtr);
00033 
00034       // Shift the input data to the right by 64 bits ( 8 bytes )
00035       inputVal2 = _mm_srli_si128(inputVal, 8);
00036 
00037       // Convert the lower 4 values into 32 bit words
00038       inputVal = _mm_cvtepi16_epi32(inputVal);
00039       inputVal2 = _mm_cvtepi16_epi32(inputVal2);
00040 
00041       ret = _mm_cvtepi32_ps(inputVal);
00042       ret = _mm_mul_ps(ret, invScalar);
00043       _mm_storeu_ps(outputVectorPtr, ret);
00044       outputVectorPtr += 4;
00045 
00046       ret = _mm_cvtepi32_ps(inputVal2);
00047       ret = _mm_mul_ps(ret, invScalar);
00048       _mm_storeu_ps(outputVectorPtr, ret);
00049 
00050       outputVectorPtr += 4;
00051 
00052       inputPtr += 8;
00053     }
00054 
00055     number = eighthPoints * 8;
00056     for(; number < num_points; number++){
00057       outputVector[number] =((float)(inputVector[number])) / scalar;
00058     }
00059 }
00060 #endif /* LV_HAVE_SSE4_1 */
00061 
00062 #ifdef LV_HAVE_SSE
00063 #include <xmmintrin.h>
00064 
00065   /*!
00066     \brief Converts the input 16 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
00067     \param inputVector The 16 bit input data buffer
00068     \param outputVector The floating point output data buffer
00069     \param scalar The value divided against each point in the output buffer
00070     \param num_points The number of data values to be converted
00071     \note Output buffer does NOT need to be properly aligned
00072   */
00073 static inline void volk_16i_s32f_convert_32f_u_sse(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){
00074     unsigned int number = 0;
00075     const unsigned int quarterPoints = num_points / 4;
00076 
00077     float* outputVectorPtr = outputVector;
00078     __m128 invScalar = _mm_set_ps1(1.0/scalar);
00079     int16_t* inputPtr = (int16_t*)inputVector;
00080     __m128 ret;
00081 
00082     for(;number < quarterPoints; number++){
00083       ret = _mm_set_ps((float)(inputPtr[3]), (float)(inputPtr[2]), (float)(inputPtr[1]), (float)(inputPtr[0]));
00084 
00085       ret = _mm_mul_ps(ret, invScalar);
00086       _mm_storeu_ps(outputVectorPtr, ret);
00087 
00088       inputPtr += 4;
00089       outputVectorPtr += 4;
00090     }
00091 
00092     number = quarterPoints * 4;
00093     for(; number < num_points; number++){
00094       outputVector[number] = (float)(inputVector[number]) / scalar;
00095     }
00096 }
00097 #endif /* LV_HAVE_SSE */
00098 
00099 #ifdef LV_HAVE_GENERIC
00100   /*!
00101     \brief Converts the input 16 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
00102     \param inputVector The 16 bit input data buffer
00103     \param outputVector The floating point output data buffer
00104     \param scalar The value divided against each point in the output buffer
00105     \param num_points The number of data values to be converted
00106     \note Output buffer does NOT need to be properly aligned
00107   */
00108 static inline void volk_16i_s32f_convert_32f_u_generic(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){
00109   float* outputVectorPtr = outputVector;
00110   const int16_t* inputVectorPtr = inputVector;
00111   unsigned int number = 0;
00112 
00113   for(number = 0; number < num_points; number++){
00114     *outputVectorPtr++ = ((float)(*inputVectorPtr++)) / scalar;
00115   }
00116 }
00117 #endif /* LV_HAVE_GENERIC */
00118 
00119 
00120 
00121 
00122 #endif /* INCLUDED_volk_16i_s32f_convert_32f_u_H */