GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_8i_s32f_convert_32f.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2014 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_volk_8i_s32f_convert_32f_u_H
24 #define INCLUDED_volk_8i_s32f_convert_32f_u_H
25 
26 #include <inttypes.h>
27 #include <stdio.h>
28 
29 #ifdef LV_HAVE_SSE4_1
30 #include <smmintrin.h>
31 
32  /*!
33  \brief Converts the input 8 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
34  \param inputVector The 8 bit input data buffer
35  \param outputVector The floating point output data buffer
36  \param scalar The value divided against each point in the output buffer
37  \param num_points The number of data values to be converted
38  \note Output buffer does NOT need to be properly aligned
39  */
40 static inline void volk_8i_s32f_convert_32f_u_sse4_1(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points){
41  unsigned int number = 0;
42  const unsigned int sixteenthPoints = num_points / 16;
43 
44  float* outputVectorPtr = outputVector;
45  const float iScalar = 1.0 / scalar;
46  __m128 invScalar = _mm_set_ps1( iScalar );
47  const int8_t* inputVectorPtr = inputVector;
48  __m128 ret;
49  __m128i inputVal;
50  __m128i interimVal;
51 
52  for(;number < sixteenthPoints; number++){
53  inputVal = _mm_loadu_si128((__m128i*)inputVectorPtr);
54 
55  interimVal = _mm_cvtepi8_epi32(inputVal);
56  ret = _mm_cvtepi32_ps(interimVal);
57  ret = _mm_mul_ps(ret, invScalar);
58  _mm_storeu_ps(outputVectorPtr, ret);
59  outputVectorPtr += 4;
60 
61  inputVal = _mm_srli_si128(inputVal, 4);
62  interimVal = _mm_cvtepi8_epi32(inputVal);
63  ret = _mm_cvtepi32_ps(interimVal);
64  ret = _mm_mul_ps(ret, invScalar);
65  _mm_storeu_ps(outputVectorPtr, ret);
66  outputVectorPtr += 4;
67 
68  inputVal = _mm_srli_si128(inputVal, 4);
69  interimVal = _mm_cvtepi8_epi32(inputVal);
70  ret = _mm_cvtepi32_ps(interimVal);
71  ret = _mm_mul_ps(ret, invScalar);
72  _mm_storeu_ps(outputVectorPtr, ret);
73  outputVectorPtr += 4;
74 
75  inputVal = _mm_srli_si128(inputVal, 4);
76  interimVal = _mm_cvtepi8_epi32(inputVal);
77  ret = _mm_cvtepi32_ps(interimVal);
78  ret = _mm_mul_ps(ret, invScalar);
79  _mm_storeu_ps(outputVectorPtr, ret);
80  outputVectorPtr += 4;
81 
82  inputVectorPtr += 16;
83  }
84 
85  number = sixteenthPoints * 16;
86  for(; number < num_points; number++){
87  outputVector[number] = (float)(inputVector[number]) * iScalar;
88  }
89 }
90 #endif /* LV_HAVE_SSE4_1 */
91 
92 #ifdef LV_HAVE_GENERIC
93  /*!
94  \brief Converts the input 8 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
95  \param inputVector The 8 bit input data buffer
96  \param outputVector The floating point output data buffer
97  \param scalar The value divided against each point in the output buffer
98  \param num_points The number of data values to be converted
99  \note Output buffer does NOT need to be properly aligned
100  */
101 static inline void volk_8i_s32f_convert_32f_generic(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points){
102  float* outputVectorPtr = outputVector;
103  const int8_t* inputVectorPtr = inputVector;
104  unsigned int number = 0;
105  const float iScalar = 1.0 / scalar;
106 
107  for(number = 0; number < num_points; number++){
108  *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
109  }
110 }
111 #endif /* LV_HAVE_GENERIC */
112 
113 
114 
115 
116 #endif /* INCLUDED_VOLK_8s_CONVERT_32f_UNALIGNED8_H */
117 #ifndef INCLUDED_volk_8i_s32f_convert_32f_a_H
118 #define INCLUDED_volk_8i_s32f_convert_32f_a_H
119 
120 #include <inttypes.h>
121 #include <stdio.h>
122 
123 #ifdef LV_HAVE_SSE4_1
124 #include <smmintrin.h>
125 
126  /*!
127  \brief Converts the input 8 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
128  \param inputVector The 8 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_8i_s32f_convert_32f_a_sse4_1(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points){
134  unsigned int number = 0;
135  const unsigned int sixteenthPoints = num_points / 16;
136 
137  float* outputVectorPtr = outputVector;
138  const float iScalar = 1.0 / scalar;
139  __m128 invScalar = _mm_set_ps1(iScalar);
140  const int8_t* inputVectorPtr = inputVector;
141  __m128 ret;
142  __m128i inputVal;
143  __m128i interimVal;
144 
145  for(;number < sixteenthPoints; number++){
146  inputVal = _mm_load_si128((__m128i*)inputVectorPtr);
147 
148  interimVal = _mm_cvtepi8_epi32(inputVal);
149  ret = _mm_cvtepi32_ps(interimVal);
150  ret = _mm_mul_ps(ret, invScalar);
151  _mm_store_ps(outputVectorPtr, ret);
152  outputVectorPtr += 4;
153 
154  inputVal = _mm_srli_si128(inputVal, 4);
155  interimVal = _mm_cvtepi8_epi32(inputVal);
156  ret = _mm_cvtepi32_ps(interimVal);
157  ret = _mm_mul_ps(ret, invScalar);
158  _mm_store_ps(outputVectorPtr, ret);
159  outputVectorPtr += 4;
160 
161  inputVal = _mm_srli_si128(inputVal, 4);
162  interimVal = _mm_cvtepi8_epi32(inputVal);
163  ret = _mm_cvtepi32_ps(interimVal);
164  ret = _mm_mul_ps(ret, invScalar);
165  _mm_store_ps(outputVectorPtr, ret);
166  outputVectorPtr += 4;
167 
168  inputVal = _mm_srli_si128(inputVal, 4);
169  interimVal = _mm_cvtepi8_epi32(inputVal);
170  ret = _mm_cvtepi32_ps(interimVal);
171  ret = _mm_mul_ps(ret, invScalar);
172  _mm_store_ps(outputVectorPtr, ret);
173  outputVectorPtr += 4;
174 
175  inputVectorPtr += 16;
176  }
177 
178  number = sixteenthPoints * 16;
179  for(; number < num_points; number++){
180  outputVector[number] = (float)(inputVector[number]) * iScalar;
181  }
182 }
183 #endif /* LV_HAVE_SSE4_1 */
184 
185 #ifdef LV_HAVE_GENERIC
186  /*!
187  \brief Converts the input 8 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
188  \param inputVector The 8 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_8i_s32f_convert_32f_a_generic(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points){
194  float* outputVectorPtr = outputVector;
195  const int8_t* inputVectorPtr = inputVector;
196  unsigned int number = 0;
197  const float iScalar = 1.0 / scalar;
198 
199  for(number = 0; number < num_points; number++){
200  *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
201  }
202 }
203 #endif /* LV_HAVE_GENERIC */
204 
205 #ifdef LV_HAVE_ORC
206  /*!
207  \brief Converts the input 8 bit integer data into floating point data, and divides the each floating point output data point by the scalar value
208  \param inputVector The 8 bit input data buffer
209  \param outputVector The floating point output data buffer
210  \param scalar The value divided against each point in the output buffer
211  \param num_points The number of data values to be converted
212  */
213 extern void volk_8i_s32f_convert_32f_a_orc_impl(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points);
214 static inline void volk_8i_s32f_convert_32f_u_orc(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points){
215  float invscalar = 1.0 / scalar;
216  volk_8i_s32f_convert_32f_a_orc_impl(outputVector, inputVector, invscalar, num_points);
217 }
218 #endif /* LV_HAVE_ORC */
219 
220 
221 
222 #endif /* INCLUDED_VOLK_8s_CONVERT_32f_ALIGNED8_H */
signed char int8_t
Definition: stdint.h:75