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