GNU Radio Manual and C++ API Reference  3.7.4.1
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
volk_16i_s32f_convert_32f.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_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 */
123 #ifndef INCLUDED_volk_16i_s32f_convert_32f_a_H
124 #define INCLUDED_volk_16i_s32f_convert_32f_a_H
125 
126 #include <inttypes.h>
127 #include <stdio.h>
128 
129 #ifdef LV_HAVE_SSE4_1
130 #include <smmintrin.h>
131 
132  /*!
133  \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
134  \param inputVector The 16 bit input data buffer
135  \param outputVector The floating point output data buffer
136  \param scalar The value divided against each point in the output buffer
137  \param num_points The number of data values to be converted
138  */
139 static inline void volk_16i_s32f_convert_32f_a_sse4_1(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){
140  unsigned int number = 0;
141  const unsigned int eighthPoints = num_points / 8;
142 
143  float* outputVectorPtr = outputVector;
144  __m128 invScalar = _mm_set_ps1(1.0/scalar);
145  int16_t* inputPtr = (int16_t*)inputVector;
146  __m128i inputVal;
147  __m128i inputVal2;
148  __m128 ret;
149 
150  for(;number < eighthPoints; number++){
151 
152  // Load the 8 values
153  inputVal = _mm_loadu_si128((__m128i*)inputPtr);
154 
155  // Shift the input data to the right by 64 bits ( 8 bytes )
156  inputVal2 = _mm_srli_si128(inputVal, 8);
157 
158  // Convert the lower 4 values into 32 bit words
159  inputVal = _mm_cvtepi16_epi32(inputVal);
160  inputVal2 = _mm_cvtepi16_epi32(inputVal2);
161 
162  ret = _mm_cvtepi32_ps(inputVal);
163  ret = _mm_mul_ps(ret, invScalar);
164  _mm_storeu_ps(outputVectorPtr, ret);
165  outputVectorPtr += 4;
166 
167  ret = _mm_cvtepi32_ps(inputVal2);
168  ret = _mm_mul_ps(ret, invScalar);
169  _mm_storeu_ps(outputVectorPtr, ret);
170 
171  outputVectorPtr += 4;
172 
173  inputPtr += 8;
174  }
175 
176  number = eighthPoints * 8;
177  for(; number < num_points; number++){
178  outputVector[number] =((float)(inputVector[number])) / scalar;
179  }
180 }
181 #endif /* LV_HAVE_SSE4_1 */
182 
183 #ifdef LV_HAVE_SSE
184 #include <xmmintrin.h>
185 
186  /*!
187  \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
188  \param inputVector The 16 bit input data buffer
189  \param outputVector The floating point output data buffer
190  \param scalar The value divided against each point in the output buffer
191  \param num_points The number of data values to be converted
192  */
193 static inline void volk_16i_s32f_convert_32f_a_sse(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){
194  unsigned int number = 0;
195  const unsigned int quarterPoints = num_points / 4;
196 
197  float* outputVectorPtr = outputVector;
198  __m128 invScalar = _mm_set_ps1(1.0/scalar);
199  int16_t* inputPtr = (int16_t*)inputVector;
200  __m128 ret;
201 
202  for(;number < quarterPoints; number++){
203  ret = _mm_set_ps((float)(inputPtr[3]), (float)(inputPtr[2]), (float)(inputPtr[1]), (float)(inputPtr[0]));
204 
205  ret = _mm_mul_ps(ret, invScalar);
206  _mm_storeu_ps(outputVectorPtr, ret);
207 
208  inputPtr += 4;
209  outputVectorPtr += 4;
210  }
211 
212  number = quarterPoints * 4;
213  for(; number < num_points; number++){
214  outputVector[number] = (float)(inputVector[number]) / scalar;
215  }
216 }
217 #endif /* LV_HAVE_SSE */
218 
219 #ifdef LV_HAVE_GENERIC
220  /*!
221  \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
222  \param inputVector The 16 bit input data buffer
223  \param outputVector The floating point output data buffer
224  \param scalar The value divided against each point in the output buffer
225  \param num_points The number of data values to be converted
226  */
227 static inline void volk_16i_s32f_convert_32f_a_generic(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){
228  float* outputVectorPtr = outputVector;
229  const int16_t* inputVectorPtr = inputVector;
230  unsigned int number = 0;
231 
232  for(number = 0; number < num_points; number++){
233  *outputVectorPtr++ = ((float)(*inputVectorPtr++)) / scalar;
234  }
235 }
236 #endif /* LV_HAVE_GENERIC */
237 
238 
239 
240 
241 #endif /* INCLUDED_volk_16i_s32f_convert_32f_a_H */
signed short int16_t
Definition: stdint.h:76