GNU Radio 3.6.5 C++ API

volk_32i_s32f_convert_32f_u.h

Go to the documentation of this file.
00001 #ifndef INCLUDED_volk_32i_s32f_convert_32f_u_H
00002 #define INCLUDED_volk_32i_s32f_convert_32f_u_H
00003 
00004 #include <inttypes.h>
00005 #include <stdio.h>
00006 
00007 #ifdef LV_HAVE_SSE2
00008 #include <emmintrin.h>
00009 
00010   /*!
00011     \brief Converts the input 32 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
00012     \param inputVector The 32 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_32i_s32f_convert_32f_u_sse2(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
00019     unsigned int number = 0;
00020     const unsigned int quarterPoints = num_points / 4;
00021 
00022      float* outputVectorPtr = outputVector;
00023      const float iScalar = 1.0 / scalar;
00024     __m128 invScalar = _mm_set_ps1(iScalar);
00025     int32_t* inputPtr = (int32_t*)inputVector;
00026     __m128i inputVal;
00027     __m128 ret;
00028 
00029     for(;number < quarterPoints; number++){
00030 
00031       // Load the 4 values
00032       inputVal = _mm_loadu_si128((__m128i*)inputPtr);
00033 
00034       ret = _mm_cvtepi32_ps(inputVal);
00035       ret = _mm_mul_ps(ret, invScalar);
00036 
00037       _mm_storeu_ps(outputVectorPtr, ret);
00038 
00039       outputVectorPtr += 4;
00040       inputPtr += 4;
00041     }
00042 
00043     number = quarterPoints * 4;
00044     for(; number < num_points; number++){
00045       outputVector[number] =((float)(inputVector[number])) * iScalar;
00046     }
00047 }
00048 #endif /* LV_HAVE_SSE2 */
00049 
00050 
00051 #ifdef LV_HAVE_GENERIC
00052   /*!
00053     \brief Converts the input 32 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
00054     \param inputVector The 32 bit input data buffer
00055     \param outputVector The floating point output data buffer
00056     \param scalar The value divided against each point in the output buffer
00057     \param num_points The number of data values to be converted
00058     \note Output buffer does NOT need to be properly aligned
00059   */
00060 static inline void volk_32i_s32f_convert_32f_u_generic(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
00061   float* outputVectorPtr = outputVector;
00062   const int32_t* inputVectorPtr = inputVector;
00063   unsigned int number = 0;
00064   const float iScalar = 1.0 / scalar;
00065 
00066   for(number = 0; number < num_points; number++){
00067     *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
00068   }
00069 }
00070 #endif /* LV_HAVE_GENERIC */
00071 
00072 
00073 
00074 
00075 #endif /* INCLUDED_volk_32i_s32f_convert_32f_u_H */