GNU Radio 3.6.5 C++ API
|
00001 #ifndef INCLUDED_volk_16i_s32f_convert_32f_a_H 00002 #define INCLUDED_volk_16i_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 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 */ 00017 static inline void volk_16i_s32f_convert_32f_a_sse4_1(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){ 00018 unsigned int number = 0; 00019 const unsigned int eighthPoints = num_points / 8; 00020 00021 float* outputVectorPtr = outputVector; 00022 __m128 invScalar = _mm_set_ps1(1.0/scalar); 00023 int16_t* inputPtr = (int16_t*)inputVector; 00024 __m128i inputVal; 00025 __m128i inputVal2; 00026 __m128 ret; 00027 00028 for(;number < eighthPoints; number++){ 00029 00030 // Load the 8 values 00031 inputVal = _mm_loadu_si128((__m128i*)inputPtr); 00032 00033 // Shift the input data to the right by 64 bits ( 8 bytes ) 00034 inputVal2 = _mm_srli_si128(inputVal, 8); 00035 00036 // Convert the lower 4 values into 32 bit words 00037 inputVal = _mm_cvtepi16_epi32(inputVal); 00038 inputVal2 = _mm_cvtepi16_epi32(inputVal2); 00039 00040 ret = _mm_cvtepi32_ps(inputVal); 00041 ret = _mm_mul_ps(ret, invScalar); 00042 _mm_storeu_ps(outputVectorPtr, ret); 00043 outputVectorPtr += 4; 00044 00045 ret = _mm_cvtepi32_ps(inputVal2); 00046 ret = _mm_mul_ps(ret, invScalar); 00047 _mm_storeu_ps(outputVectorPtr, ret); 00048 00049 outputVectorPtr += 4; 00050 00051 inputPtr += 8; 00052 } 00053 00054 number = eighthPoints * 8; 00055 for(; number < num_points; number++){ 00056 outputVector[number] =((float)(inputVector[number])) / scalar; 00057 } 00058 } 00059 #endif /* LV_HAVE_SSE4_1 */ 00060 00061 #ifdef LV_HAVE_SSE 00062 #include <xmmintrin.h> 00063 00064 /*! 00065 \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 00066 \param inputVector The 16 bit input data buffer 00067 \param outputVector The floating point output data buffer 00068 \param scalar The value divided against each point in the output buffer 00069 \param num_points The number of data values to be converted 00070 */ 00071 static inline void volk_16i_s32f_convert_32f_a_sse(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){ 00072 unsigned int number = 0; 00073 const unsigned int quarterPoints = num_points / 4; 00074 00075 float* outputVectorPtr = outputVector; 00076 __m128 invScalar = _mm_set_ps1(1.0/scalar); 00077 int16_t* inputPtr = (int16_t*)inputVector; 00078 __m128 ret; 00079 00080 for(;number < quarterPoints; number++){ 00081 ret = _mm_set_ps((float)(inputPtr[3]), (float)(inputPtr[2]), (float)(inputPtr[1]), (float)(inputPtr[0])); 00082 00083 ret = _mm_mul_ps(ret, invScalar); 00084 _mm_storeu_ps(outputVectorPtr, ret); 00085 00086 inputPtr += 4; 00087 outputVectorPtr += 4; 00088 } 00089 00090 number = quarterPoints * 4; 00091 for(; number < num_points; number++){ 00092 outputVector[number] = (float)(inputVector[number]) / scalar; 00093 } 00094 } 00095 #endif /* LV_HAVE_SSE */ 00096 00097 #ifdef LV_HAVE_GENERIC 00098 /*! 00099 \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 00100 \param inputVector The 16 bit input data buffer 00101 \param outputVector The floating point output data buffer 00102 \param scalar The value divided against each point in the output buffer 00103 \param num_points The number of data values to be converted 00104 */ 00105 static inline void volk_16i_s32f_convert_32f_a_generic(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){ 00106 float* outputVectorPtr = outputVector; 00107 const int16_t* inputVectorPtr = inputVector; 00108 unsigned int number = 0; 00109 00110 for(number = 0; number < num_points; number++){ 00111 *outputVectorPtr++ = ((float)(*inputVectorPtr++)) / scalar; 00112 } 00113 } 00114 #endif /* LV_HAVE_GENERIC */ 00115 00116 00117 00118 00119 #endif /* INCLUDED_volk_16i_s32f_convert_32f_a_H */