GNU Radio Manual and C++ API Reference  3.7.7
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
volk_8i_s32f_convert_32f.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012, 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 /*!
24  * \page volk_8i_s32f_convert_32f
25  *
26  * \b Overview
27  *
28  * Convert the input vector of 8-bit chars to a vector of floats. The
29  * floats are then divided by the scalar factor. shorts.
30  *
31  * <b>Dispatcher Prototype</b>
32  * \code
33  * void volk_8i_s32f_convert_32f(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points)
34  * \endcode
35  *
36  * \b Inputs
37  * \li inputVector: The input vector of 8-bit chars.
38  * \li scalar: the scaling factor used to divide the results of the conversion.
39  * \li num_points: The number of values.
40  *
41  * \b Outputs
42  * \li outputVector: The output 16-bit shorts.
43  *
44  * \b Example
45  * \code
46  * int N = 10000;
47  *
48  * volk_8i_s32f_convert_32f();
49  *
50  * volk_free(x);
51  * \endcode
52  */
53 
54 #ifndef INCLUDED_volk_8i_s32f_convert_32f_u_H
55 #define INCLUDED_volk_8i_s32f_convert_32f_u_H
56 
57 #include <inttypes.h>
58 #include <stdio.h>
59 
60 #ifdef LV_HAVE_SSE4_1
61 #include <smmintrin.h>
62 
63 static inline void
64 volk_8i_s32f_convert_32f_u_sse4_1(float* outputVector, const int8_t* inputVector,
65  const float scalar, unsigned int num_points)
66 {
67  unsigned int number = 0;
68  const unsigned int sixteenthPoints = num_points / 16;
69 
70  float* outputVectorPtr = outputVector;
71  const float iScalar = 1.0 / scalar;
72  __m128 invScalar = _mm_set_ps1( iScalar );
73  const int8_t* inputVectorPtr = inputVector;
74  __m128 ret;
75  __m128i inputVal;
76  __m128i interimVal;
77 
78  for(;number < sixteenthPoints; number++){
79  inputVal = _mm_loadu_si128((__m128i*)inputVectorPtr);
80 
81  interimVal = _mm_cvtepi8_epi32(inputVal);
82  ret = _mm_cvtepi32_ps(interimVal);
83  ret = _mm_mul_ps(ret, invScalar);
84  _mm_storeu_ps(outputVectorPtr, ret);
85  outputVectorPtr += 4;
86 
87  inputVal = _mm_srli_si128(inputVal, 4);
88  interimVal = _mm_cvtepi8_epi32(inputVal);
89  ret = _mm_cvtepi32_ps(interimVal);
90  ret = _mm_mul_ps(ret, invScalar);
91  _mm_storeu_ps(outputVectorPtr, ret);
92  outputVectorPtr += 4;
93 
94  inputVal = _mm_srli_si128(inputVal, 4);
95  interimVal = _mm_cvtepi8_epi32(inputVal);
96  ret = _mm_cvtepi32_ps(interimVal);
97  ret = _mm_mul_ps(ret, invScalar);
98  _mm_storeu_ps(outputVectorPtr, ret);
99  outputVectorPtr += 4;
100 
101  inputVal = _mm_srli_si128(inputVal, 4);
102  interimVal = _mm_cvtepi8_epi32(inputVal);
103  ret = _mm_cvtepi32_ps(interimVal);
104  ret = _mm_mul_ps(ret, invScalar);
105  _mm_storeu_ps(outputVectorPtr, ret);
106  outputVectorPtr += 4;
107 
108  inputVectorPtr += 16;
109  }
110 
111  number = sixteenthPoints * 16;
112  for(; number < num_points; number++){
113  outputVector[number] = (float)(inputVector[number]) * iScalar;
114  }
115 }
116 #endif /* LV_HAVE_SSE4_1 */
117 
118 
119 #ifdef LV_HAVE_GENERIC
120 
121 static inline void
122 volk_8i_s32f_convert_32f_generic(float* outputVector, const int8_t* inputVector,
123  const float scalar, unsigned int num_points)
124 {
125  float* outputVectorPtr = outputVector;
126  const int8_t* inputVectorPtr = inputVector;
127  unsigned int number = 0;
128  const float iScalar = 1.0 / scalar;
129 
130  for(number = 0; number < num_points; number++){
131  *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
132  }
133 }
134 #endif /* LV_HAVE_GENERIC */
135 
136 
137 
138 #endif /* INCLUDED_VOLK_8s_CONVERT_32f_UNALIGNED8_H */
139 #ifndef INCLUDED_volk_8i_s32f_convert_32f_a_H
140 #define INCLUDED_volk_8i_s32f_convert_32f_a_H
141 
142 #include <inttypes.h>
143 #include <stdio.h>
144 
145 #ifdef LV_HAVE_SSE4_1
146 #include <smmintrin.h>
147 
148 static inline void
149 volk_8i_s32f_convert_32f_a_sse4_1(float* outputVector, const int8_t* inputVector,
150  const float scalar, unsigned int num_points)
151 {
152  unsigned int number = 0;
153  const unsigned int sixteenthPoints = num_points / 16;
154 
155  float* outputVectorPtr = outputVector;
156  const float iScalar = 1.0 / scalar;
157  __m128 invScalar = _mm_set_ps1(iScalar);
158  const int8_t* inputVectorPtr = inputVector;
159  __m128 ret;
160  __m128i inputVal;
161  __m128i interimVal;
162 
163  for(;number < sixteenthPoints; number++){
164  inputVal = _mm_load_si128((__m128i*)inputVectorPtr);
165 
166  interimVal = _mm_cvtepi8_epi32(inputVal);
167  ret = _mm_cvtepi32_ps(interimVal);
168  ret = _mm_mul_ps(ret, invScalar);
169  _mm_store_ps(outputVectorPtr, ret);
170  outputVectorPtr += 4;
171 
172  inputVal = _mm_srli_si128(inputVal, 4);
173  interimVal = _mm_cvtepi8_epi32(inputVal);
174  ret = _mm_cvtepi32_ps(interimVal);
175  ret = _mm_mul_ps(ret, invScalar);
176  _mm_store_ps(outputVectorPtr, ret);
177  outputVectorPtr += 4;
178 
179  inputVal = _mm_srli_si128(inputVal, 4);
180  interimVal = _mm_cvtepi8_epi32(inputVal);
181  ret = _mm_cvtepi32_ps(interimVal);
182  ret = _mm_mul_ps(ret, invScalar);
183  _mm_store_ps(outputVectorPtr, ret);
184  outputVectorPtr += 4;
185 
186  inputVal = _mm_srli_si128(inputVal, 4);
187  interimVal = _mm_cvtepi8_epi32(inputVal);
188  ret = _mm_cvtepi32_ps(interimVal);
189  ret = _mm_mul_ps(ret, invScalar);
190  _mm_store_ps(outputVectorPtr, ret);
191  outputVectorPtr += 4;
192 
193  inputVectorPtr += 16;
194  }
195 
196  number = sixteenthPoints * 16;
197  for(; number < num_points; number++){
198  outputVector[number] = (float)(inputVector[number]) * iScalar;
199  }
200 }
201 #endif /* LV_HAVE_SSE4_1 */
202 
203 
204 #ifdef LV_HAVE_GENERIC
205 
206 static inline void
207 volk_8i_s32f_convert_32f_a_generic(float* outputVector, const int8_t* inputVector,
208  const float scalar, unsigned int num_points)
209 {
210  float* outputVectorPtr = outputVector;
211  const int8_t* inputVectorPtr = inputVector;
212  unsigned int number = 0;
213  const float iScalar = 1.0 / scalar;
214 
215  for(number = 0; number < num_points; number++){
216  *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
217  }
218 }
219 #endif /* LV_HAVE_GENERIC */
220 
221 
222 #ifdef LV_HAVE_ORC
223 extern void
224 volk_8i_s32f_convert_32f_a_orc_impl(float* outputVector, const int8_t* inputVector,
225  const float scalar, unsigned int num_points);
226 
227 static inline void
228 volk_8i_s32f_convert_32f_u_orc(float* outputVector, const int8_t* inputVector,
229  const float scalar, unsigned int num_points)
230 {
231  float invscalar = 1.0 / scalar;
232  volk_8i_s32f_convert_32f_a_orc_impl(outputVector, inputVector, invscalar, num_points);
233 }
234 #endif /* LV_HAVE_ORC */
235 
236 
237 
238 #endif /* INCLUDED_VOLK_8s_CONVERT_32f_ALIGNED8_H */
signed char int8_t
Definition: stdint.h:75