GNU Radio 3.6.5 C++ API

volk_8i_s32f_convert_32f_a.h

Go to the documentation of this file.
00001 #ifndef INCLUDED_volk_8i_s32f_convert_32f_a_H
00002 #define INCLUDED_volk_8i_s32f_convert_32f_a_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 8 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
00012     \param inputVector The 8 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_8i_s32f_convert_32f_a_sse4_1(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points){
00018     unsigned int number = 0;
00019     const unsigned int sixteenthPoints = num_points / 16;
00020 
00021     float* outputVectorPtr = outputVector;
00022     const float iScalar = 1.0 / scalar;
00023     __m128 invScalar = _mm_set_ps1(iScalar);
00024     const int8_t* inputVectorPtr = inputVector;
00025     __m128 ret;
00026     __m128i inputVal;
00027     __m128i interimVal;
00028 
00029     for(;number < sixteenthPoints; number++){
00030       inputVal = _mm_load_si128((__m128i*)inputVectorPtr);
00031 
00032       interimVal = _mm_cvtepi8_epi32(inputVal);
00033       ret = _mm_cvtepi32_ps(interimVal);
00034       ret = _mm_mul_ps(ret, invScalar);
00035       _mm_store_ps(outputVectorPtr, ret);
00036       outputVectorPtr += 4;
00037 
00038       inputVal = _mm_srli_si128(inputVal, 4);
00039       interimVal = _mm_cvtepi8_epi32(inputVal);
00040       ret = _mm_cvtepi32_ps(interimVal);
00041       ret = _mm_mul_ps(ret, invScalar);
00042       _mm_store_ps(outputVectorPtr, ret);
00043       outputVectorPtr += 4;
00044 
00045       inputVal = _mm_srli_si128(inputVal, 4);
00046       interimVal = _mm_cvtepi8_epi32(inputVal);
00047       ret = _mm_cvtepi32_ps(interimVal);
00048       ret = _mm_mul_ps(ret, invScalar);
00049       _mm_store_ps(outputVectorPtr, ret);
00050       outputVectorPtr += 4;
00051 
00052       inputVal = _mm_srli_si128(inputVal, 4);
00053       interimVal = _mm_cvtepi8_epi32(inputVal);
00054       ret = _mm_cvtepi32_ps(interimVal);
00055       ret = _mm_mul_ps(ret, invScalar);
00056       _mm_store_ps(outputVectorPtr, ret);
00057       outputVectorPtr += 4;
00058 
00059       inputVectorPtr += 16;
00060     }
00061 
00062     number = sixteenthPoints * 16;
00063     for(; number < num_points; number++){
00064       outputVector[number] = (float)(inputVector[number]) * iScalar;
00065     }
00066 }
00067 #endif /* LV_HAVE_SSE4_1 */
00068 
00069 #ifdef LV_HAVE_GENERIC
00070   /*!
00071     \brief Converts the input 8 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
00072     \param inputVector The 8 bit input data buffer
00073     \param outputVector The floating point output data buffer
00074     \param scalar The value divided against each point in the output buffer
00075     \param num_points The number of data values to be converted
00076   */
00077 static inline void volk_8i_s32f_convert_32f_a_generic(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points){
00078   float* outputVectorPtr = outputVector;
00079   const int8_t* inputVectorPtr = inputVector;
00080   unsigned int number = 0;
00081   const float iScalar = 1.0 / scalar;
00082 
00083   for(number = 0; number < num_points; number++){
00084     *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
00085   }
00086 }
00087 #endif /* LV_HAVE_GENERIC */
00088 
00089 #ifdef LV_HAVE_ORC
00090   /*!
00091     \brief Converts the input 8 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
00092     \param inputVector The 8 bit input data buffer
00093     \param outputVector The floating point output data buffer
00094     \param scalar The value divided against each point in the output buffer
00095     \param num_points The number of data values to be converted
00096   */
00097 extern void volk_8i_s32f_convert_32f_a_orc_impl(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points);
00098 static inline void volk_8i_s32f_convert_32f_a_orc(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points){
00099     float invscalar = 1.0 / scalar;
00100     volk_8i_s32f_convert_32f_a_orc_impl(outputVector, inputVector, invscalar, num_points);
00101 }
00102 #endif /* LV_HAVE_ORC */
00103 
00104 
00105 
00106 #endif /* INCLUDED_VOLK_8s_CONVERT_32f_ALIGNED8_H */