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_32i_s32f_convert_32f.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_32i_s32f_convert_32f_u_H
2 #define INCLUDED_volk_32i_s32f_convert_32f_u_H
3 
4 #include <inttypes.h>
5 #include <stdio.h>
6 
7 #ifdef LV_HAVE_SSE2
8 #include <emmintrin.h>
9 
10  /*!
11  \brief Converts the input 32 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
12  \param inputVector The 32 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_32i_s32f_convert_32f_u_sse2(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
19  unsigned int number = 0;
20  const unsigned int quarterPoints = num_points / 4;
21 
22  float* outputVectorPtr = outputVector;
23  const float iScalar = 1.0 / scalar;
24  __m128 invScalar = _mm_set_ps1(iScalar);
25  int32_t* inputPtr = (int32_t*)inputVector;
26  __m128i inputVal;
27  __m128 ret;
28 
29  for(;number < quarterPoints; number++){
30 
31  // Load the 4 values
32  inputVal = _mm_loadu_si128((__m128i*)inputPtr);
33 
34  ret = _mm_cvtepi32_ps(inputVal);
35  ret = _mm_mul_ps(ret, invScalar);
36 
37  _mm_storeu_ps(outputVectorPtr, ret);
38 
39  outputVectorPtr += 4;
40  inputPtr += 4;
41  }
42 
43  number = quarterPoints * 4;
44  for(; number < num_points; number++){
45  outputVector[number] =((float)(inputVector[number])) * iScalar;
46  }
47 }
48 #endif /* LV_HAVE_SSE2 */
49 
50 
51 #ifdef LV_HAVE_GENERIC
52  /*!
53  \brief Converts the input 32 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
54  \param inputVector The 32 bit input data buffer
55  \param outputVector The floating point output data buffer
56  \param scalar The value divided against each point in the output buffer
57  \param num_points The number of data values to be converted
58  \note Output buffer does NOT need to be properly aligned
59  */
60 static inline void volk_32i_s32f_convert_32f_generic(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
61  float* outputVectorPtr = outputVector;
62  const int32_t* inputVectorPtr = inputVector;
63  unsigned int number = 0;
64  const float iScalar = 1.0 / scalar;
65 
66  for(number = 0; number < num_points; number++){
67  *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
68  }
69 }
70 #endif /* LV_HAVE_GENERIC */
71 
72 
73 
74 
75 #endif /* INCLUDED_volk_32i_s32f_convert_32f_u_H */
76 #ifndef INCLUDED_volk_32i_s32f_convert_32f_a_H
77 #define INCLUDED_volk_32i_s32f_convert_32f_a_H
78 
79 #include <inttypes.h>
80 #include <stdio.h>
81 
82 #ifdef LV_HAVE_SSE2
83 #include <emmintrin.h>
84 
85  /*!
86  \brief Converts the input 32 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
87  \param inputVector The 32 bit input data buffer
88  \param outputVector The floating point output data buffer
89  \param scalar The value divided against each point in the output buffer
90  \param num_points The number of data values to be converted
91  */
92 static inline void volk_32i_s32f_convert_32f_a_sse2(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
93  unsigned int number = 0;
94  const unsigned int quarterPoints = num_points / 4;
95 
96  float* outputVectorPtr = outputVector;
97  const float iScalar = 1.0 / scalar;
98  __m128 invScalar = _mm_set_ps1(iScalar);
99  int32_t* inputPtr = (int32_t*)inputVector;
100  __m128i inputVal;
101  __m128 ret;
102 
103  for(;number < quarterPoints; number++){
104 
105  // Load the 4 values
106  inputVal = _mm_load_si128((__m128i*)inputPtr);
107 
108  ret = _mm_cvtepi32_ps(inputVal);
109  ret = _mm_mul_ps(ret, invScalar);
110 
111  _mm_store_ps(outputVectorPtr, ret);
112 
113  outputVectorPtr += 4;
114  inputPtr += 4;
115  }
116 
117  number = quarterPoints * 4;
118  for(; number < num_points; number++){
119  outputVector[number] =((float)(inputVector[number])) * iScalar;
120  }
121 }
122 #endif /* LV_HAVE_SSE2 */
123 
124 
125 #ifdef LV_HAVE_GENERIC
126  /*!
127  \brief Converts the input 32 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
128  \param inputVector The 32 bit input data buffer
129  \param outputVector The floating point output data buffer
130  \param scalar The value divided against each point in the output buffer
131  \param num_points The number of data values to be converted
132  */
133 static inline void volk_32i_s32f_convert_32f_a_generic(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
134  float* outputVectorPtr = outputVector;
135  const int32_t* inputVectorPtr = inputVector;
136  unsigned int number = 0;
137  const float iScalar = 1.0 / scalar;
138 
139  for(number = 0; number < num_points; number++){
140  *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
141  }
142 }
143 #endif /* LV_HAVE_GENERIC */
144 
145 
146 
147 
148 #endif /* INCLUDED_volk_32i_s32f_convert_32f_a_H */
signed int int32_t
Definition: stdint.h:77