GNU Radio 3.6.4.2 C++ API
volk_32i_s32f_convert_32f.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_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 */
00076 #ifndef INCLUDED_volk_32i_s32f_convert_32f_a_H
00077 #define INCLUDED_volk_32i_s32f_convert_32f_a_H
00078 
00079 #include <inttypes.h>
00080 #include <stdio.h>
00081 
00082 #ifdef LV_HAVE_SSE2
00083 #include <emmintrin.h>
00084 
00085   /*!
00086     \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
00087     \param inputVector The 32 bit input data buffer
00088     \param outputVector The floating point output data buffer
00089     \param scalar The value divided against each point in the output buffer
00090     \param num_points The number of data values to be converted
00091   */
00092 static inline void volk_32i_s32f_convert_32f_a_sse2(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
00093     unsigned int number = 0;
00094     const unsigned int quarterPoints = num_points / 4;
00095 
00096      float* outputVectorPtr = outputVector;
00097      const float iScalar = 1.0 / scalar;
00098     __m128 invScalar = _mm_set_ps1(iScalar);
00099     int32_t* inputPtr = (int32_t*)inputVector;
00100     __m128i inputVal;
00101     __m128 ret;
00102 
00103     for(;number < quarterPoints; number++){
00104 
00105       // Load the 4 values
00106       inputVal = _mm_load_si128((__m128i*)inputPtr);
00107 
00108       ret = _mm_cvtepi32_ps(inputVal);
00109       ret = _mm_mul_ps(ret, invScalar);
00110 
00111       _mm_store_ps(outputVectorPtr, ret);
00112 
00113       outputVectorPtr += 4;
00114       inputPtr += 4;
00115     }
00116 
00117     number = quarterPoints * 4;
00118     for(; number < num_points; number++){
00119       outputVector[number] =((float)(inputVector[number])) * iScalar;
00120     }
00121 }
00122 #endif /* LV_HAVE_SSE2 */
00123 
00124 
00125 #ifdef LV_HAVE_GENERIC
00126   /*!
00127     \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
00128     \param inputVector The 32 bit input data buffer
00129     \param outputVector The floating point output data buffer
00130     \param scalar The value divided against each point in the output buffer
00131     \param num_points The number of data values to be converted
00132   */
00133 static inline void volk_32i_s32f_convert_32f_a_generic(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
00134   float* outputVectorPtr = outputVector;
00135   const int32_t* inputVectorPtr = inputVector;
00136   unsigned int number = 0;
00137   const float iScalar = 1.0 / scalar;
00138 
00139   for(number = 0; number < num_points; number++){
00140     *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
00141   }
00142 }
00143 #endif /* LV_HAVE_GENERIC */
00144 
00145 
00146 
00147 
00148 #endif /* INCLUDED_volk_32i_s32f_convert_32f_a_H */