-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvolk_8i_s32f_convert_32f.h
238 lines (197 loc) · 6.81 KB
/
volk_8i_s32f_convert_32f.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/* -*- c++ -*- */
/*
* Copyright 2012, 2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
/*!
* \page volk_8i_s32f_convert_32f
*
* \b Overview
*
* Convert the input vector of 8-bit chars to a vector of floats. The
* floats are then divided by the scalar factor. shorts.
*
* <b>Dispatcher Prototype</b>
* \code
* void volk_8i_s32f_convert_32f(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points)
* \endcode
*
* \b Inputs
* \li inputVector: The input vector of 8-bit chars.
* \li scalar: the scaling factor used to divide the results of the conversion.
* \li num_points: The number of values.
*
* \b Outputs
* \li outputVector: The output 16-bit shorts.
*
* \b Example
* \code
* int N = 10000;
*
* volk_8i_s32f_convert_32f();
*
* volk_free(x);
* \endcode
*/
#ifndef INCLUDED_volk_8i_s32f_convert_32f_u_H
#define INCLUDED_volk_8i_s32f_convert_32f_u_H
#include <inttypes.h>
#include <stdio.h>
#ifdef LV_HAVE_SSE4_1
#include <smmintrin.h>
static inline void
volk_8i_s32f_convert_32f_u_sse4_1(float* outputVector, const int8_t* inputVector,
const float scalar, unsigned int num_points)
{
unsigned int number = 0;
const unsigned int sixteenthPoints = num_points / 16;
float* outputVectorPtr = outputVector;
const float iScalar = 1.0 / scalar;
__m128 invScalar = _mm_set_ps1( iScalar );
const int8_t* inputVectorPtr = inputVector;
__m128 ret;
__m128i inputVal;
__m128i interimVal;
for(;number < sixteenthPoints; number++){
inputVal = _mm_loadu_si128((__m128i*)inputVectorPtr);
interimVal = _mm_cvtepi8_epi32(inputVal);
ret = _mm_cvtepi32_ps(interimVal);
ret = _mm_mul_ps(ret, invScalar);
_mm_storeu_ps(outputVectorPtr, ret);
outputVectorPtr += 4;
inputVal = _mm_srli_si128(inputVal, 4);
interimVal = _mm_cvtepi8_epi32(inputVal);
ret = _mm_cvtepi32_ps(interimVal);
ret = _mm_mul_ps(ret, invScalar);
_mm_storeu_ps(outputVectorPtr, ret);
outputVectorPtr += 4;
inputVal = _mm_srli_si128(inputVal, 4);
interimVal = _mm_cvtepi8_epi32(inputVal);
ret = _mm_cvtepi32_ps(interimVal);
ret = _mm_mul_ps(ret, invScalar);
_mm_storeu_ps(outputVectorPtr, ret);
outputVectorPtr += 4;
inputVal = _mm_srli_si128(inputVal, 4);
interimVal = _mm_cvtepi8_epi32(inputVal);
ret = _mm_cvtepi32_ps(interimVal);
ret = _mm_mul_ps(ret, invScalar);
_mm_storeu_ps(outputVectorPtr, ret);
outputVectorPtr += 4;
inputVectorPtr += 16;
}
number = sixteenthPoints * 16;
for(; number < num_points; number++){
outputVector[number] = (float)(inputVector[number]) * iScalar;
}
}
#endif /* LV_HAVE_SSE4_1 */
#ifdef LV_HAVE_GENERIC
static inline void
volk_8i_s32f_convert_32f_generic(float* outputVector, const int8_t* inputVector,
const float scalar, unsigned int num_points)
{
float* outputVectorPtr = outputVector;
const int8_t* inputVectorPtr = inputVector;
unsigned int number = 0;
const float iScalar = 1.0 / scalar;
for(number = 0; number < num_points; number++){
*outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
}
}
#endif /* LV_HAVE_GENERIC */
#endif /* INCLUDED_VOLK_8s_CONVERT_32f_UNALIGNED8_H */
#ifndef INCLUDED_volk_8i_s32f_convert_32f_a_H
#define INCLUDED_volk_8i_s32f_convert_32f_a_H
#include <inttypes.h>
#include <stdio.h>
#ifdef LV_HAVE_SSE4_1
#include <smmintrin.h>
static inline void
volk_8i_s32f_convert_32f_a_sse4_1(float* outputVector, const int8_t* inputVector,
const float scalar, unsigned int num_points)
{
unsigned int number = 0;
const unsigned int sixteenthPoints = num_points / 16;
float* outputVectorPtr = outputVector;
const float iScalar = 1.0 / scalar;
__m128 invScalar = _mm_set_ps1(iScalar);
const int8_t* inputVectorPtr = inputVector;
__m128 ret;
__m128i inputVal;
__m128i interimVal;
for(;number < sixteenthPoints; number++){
inputVal = _mm_load_si128((__m128i*)inputVectorPtr);
interimVal = _mm_cvtepi8_epi32(inputVal);
ret = _mm_cvtepi32_ps(interimVal);
ret = _mm_mul_ps(ret, invScalar);
_mm_store_ps(outputVectorPtr, ret);
outputVectorPtr += 4;
inputVal = _mm_srli_si128(inputVal, 4);
interimVal = _mm_cvtepi8_epi32(inputVal);
ret = _mm_cvtepi32_ps(interimVal);
ret = _mm_mul_ps(ret, invScalar);
_mm_store_ps(outputVectorPtr, ret);
outputVectorPtr += 4;
inputVal = _mm_srli_si128(inputVal, 4);
interimVal = _mm_cvtepi8_epi32(inputVal);
ret = _mm_cvtepi32_ps(interimVal);
ret = _mm_mul_ps(ret, invScalar);
_mm_store_ps(outputVectorPtr, ret);
outputVectorPtr += 4;
inputVal = _mm_srli_si128(inputVal, 4);
interimVal = _mm_cvtepi8_epi32(inputVal);
ret = _mm_cvtepi32_ps(interimVal);
ret = _mm_mul_ps(ret, invScalar);
_mm_store_ps(outputVectorPtr, ret);
outputVectorPtr += 4;
inputVectorPtr += 16;
}
number = sixteenthPoints * 16;
for(; number < num_points; number++){
outputVector[number] = (float)(inputVector[number]) * iScalar;
}
}
#endif /* LV_HAVE_SSE4_1 */
#ifdef LV_HAVE_GENERIC
static inline void
volk_8i_s32f_convert_32f_a_generic(float* outputVector, const int8_t* inputVector,
const float scalar, unsigned int num_points)
{
float* outputVectorPtr = outputVector;
const int8_t* inputVectorPtr = inputVector;
unsigned int number = 0;
const float iScalar = 1.0 / scalar;
for(number = 0; number < num_points; number++){
*outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
}
}
#endif /* LV_HAVE_GENERIC */
#ifdef LV_HAVE_ORC
extern void
volk_8i_s32f_convert_32f_a_orc_impl(float* outputVector, const int8_t* inputVector,
const float scalar, unsigned int num_points);
static inline void
volk_8i_s32f_convert_32f_u_orc(float* outputVector, const int8_t* inputVector,
const float scalar, unsigned int num_points)
{
float invscalar = 1.0 / scalar;
volk_8i_s32f_convert_32f_a_orc_impl(outputVector, inputVector, invscalar, num_points);
}
#endif /* LV_HAVE_ORC */
#endif /* INCLUDED_VOLK_8s_CONVERT_32f_ALIGNED8_H */