GNU Radio 3.6.3.1 C++ API
volk_16i_s32f_convert_32f_u.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_16i_s32f_convert_32f_u_H
2 #define INCLUDED_volk_16i_s32f_convert_32f_u_H
3 
4 #include <inttypes.h>
5 #include <stdio.h>
6 
7 #ifdef LV_HAVE_SSE4_1
8 #include <smmintrin.h>
9 
10  /*!
11  \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
12  \param inputVector The 16 bit input data buffer
13  \param outputVector The floating point output data buffer
14  \param scalar The value divided against each point in the output buffer
15  \param num_points The number of data values to be converted
16  \note Output buffer does NOT need to be properly aligned
17  */
18 static inline void volk_16i_s32f_convert_32f_u_sse4_1(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){
19  unsigned int number = 0;
20  const unsigned int eighthPoints = num_points / 8;
21 
22  float* outputVectorPtr = outputVector;
23  __m128 invScalar = _mm_set_ps1(1.0/scalar);
24  int16_t* inputPtr = (int16_t*)inputVector;
25  __m128i inputVal;
26  __m128i inputVal2;
27  __m128 ret;
28 
29  for(;number < eighthPoints; number++){
30 
31  // Load the 8 values
32  inputVal = _mm_loadu_si128((__m128i*)inputPtr);
33 
34  // Shift the input data to the right by 64 bits ( 8 bytes )
35  inputVal2 = _mm_srli_si128(inputVal, 8);
36 
37  // Convert the lower 4 values into 32 bit words
38  inputVal = _mm_cvtepi16_epi32(inputVal);
39  inputVal2 = _mm_cvtepi16_epi32(inputVal2);
40 
41  ret = _mm_cvtepi32_ps(inputVal);
42  ret = _mm_mul_ps(ret, invScalar);
43  _mm_storeu_ps(outputVectorPtr, ret);
44  outputVectorPtr += 4;
45 
46  ret = _mm_cvtepi32_ps(inputVal2);
47  ret = _mm_mul_ps(ret, invScalar);
48  _mm_storeu_ps(outputVectorPtr, ret);
49 
50  outputVectorPtr += 4;
51 
52  inputPtr += 8;
53  }
54 
55  number = eighthPoints * 8;
56  for(; number < num_points; number++){
57  outputVector[number] =((float)(inputVector[number])) / scalar;
58  }
59 }
60 #endif /* LV_HAVE_SSE4_1 */
61 
62 #ifdef LV_HAVE_SSE
63 #include <xmmintrin.h>
64 
65  /*!
66  \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
67  \param inputVector The 16 bit input data buffer
68  \param outputVector The floating point output data buffer
69  \param scalar The value divided against each point in the output buffer
70  \param num_points The number of data values to be converted
71  \note Output buffer does NOT need to be properly aligned
72  */
73 static inline void volk_16i_s32f_convert_32f_u_sse(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){
74  unsigned int number = 0;
75  const unsigned int quarterPoints = num_points / 4;
76 
77  float* outputVectorPtr = outputVector;
78  __m128 invScalar = _mm_set_ps1(1.0/scalar);
79  int16_t* inputPtr = (int16_t*)inputVector;
80  __m128 ret;
81 
82  for(;number < quarterPoints; number++){
83  ret = _mm_set_ps((float)(inputPtr[3]), (float)(inputPtr[2]), (float)(inputPtr[1]), (float)(inputPtr[0]));
84 
85  ret = _mm_mul_ps(ret, invScalar);
86  _mm_storeu_ps(outputVectorPtr, ret);
87 
88  inputPtr += 4;
89  outputVectorPtr += 4;
90  }
91 
92  number = quarterPoints * 4;
93  for(; number < num_points; number++){
94  outputVector[number] = (float)(inputVector[number]) / scalar;
95  }
96 }
97 #endif /* LV_HAVE_SSE */
98 
99 #ifdef LV_HAVE_GENERIC
100  /*!
101  \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
102  \param inputVector The 16 bit input data buffer
103  \param outputVector The floating point output data buffer
104  \param scalar The value divided against each point in the output buffer
105  \param num_points The number of data values to be converted
106  \note Output buffer does NOT need to be properly aligned
107  */
108 static inline void volk_16i_s32f_convert_32f_u_generic(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){
109  float* outputVectorPtr = outputVector;
110  const int16_t* inputVectorPtr = inputVector;
111  unsigned int number = 0;
112 
113  for(number = 0; number < num_points; number++){
114  *outputVectorPtr++ = ((float)(*inputVectorPtr++)) / scalar;
115  }
116 }
117 #endif /* LV_HAVE_GENERIC */
118 
119 
120 
121 
122 #endif /* INCLUDED_volk_16i_s32f_convert_32f_u_H */