GNU Radio 3.6.5 C++ API

volk_32i_s32f_convert_32f_a.h

Go to the documentation of this file.
00001 #ifndef INCLUDED_volk_32i_s32f_convert_32f_a_H
00002 #define INCLUDED_volk_32i_s32f_convert_32f_a_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   */
00017 static inline void volk_32i_s32f_convert_32f_a_sse2(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
00018     unsigned int number = 0;
00019     const unsigned int quarterPoints = num_points / 4;
00020 
00021      float* outputVectorPtr = outputVector;
00022      const float iScalar = 1.0 / scalar;
00023     __m128 invScalar = _mm_set_ps1(iScalar);
00024     int32_t* inputPtr = (int32_t*)inputVector;
00025     __m128i inputVal;
00026     __m128 ret;
00027 
00028     for(;number < quarterPoints; number++){
00029 
00030       // Load the 4 values
00031       inputVal = _mm_load_si128((__m128i*)inputPtr);
00032 
00033       ret = _mm_cvtepi32_ps(inputVal);
00034       ret = _mm_mul_ps(ret, invScalar);
00035 
00036       _mm_store_ps(outputVectorPtr, ret);
00037 
00038       outputVectorPtr += 4;
00039       inputPtr += 4;
00040     }
00041 
00042     number = quarterPoints * 4;
00043     for(; number < num_points; number++){
00044       outputVector[number] =((float)(inputVector[number])) * iScalar;
00045     }
00046 }
00047 #endif /* LV_HAVE_SSE2 */
00048 
00049 
00050 #ifdef LV_HAVE_GENERIC
00051   /*!
00052     \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
00053     \param inputVector The 32 bit input data buffer
00054     \param outputVector The floating point output data buffer
00055     \param scalar The value divided against each point in the output buffer
00056     \param num_points The number of data values to be converted
00057   */
00058 static inline void volk_32i_s32f_convert_32f_a_generic(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
00059   float* outputVectorPtr = outputVector;
00060   const int32_t* inputVectorPtr = inputVector;
00061   unsigned int number = 0;
00062   const float iScalar = 1.0 / scalar;
00063 
00064   for(number = 0; number < num_points; number++){
00065     *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
00066   }
00067 }
00068 #endif /* LV_HAVE_GENERIC */
00069 
00070 
00071 
00072 
00073 #endif /* INCLUDED_volk_32i_s32f_convert_32f_a_H */