GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_32i_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_32i_s32f_convert_32f_u_H
24 #define INCLUDED_volk_32i_s32f_convert_32f_u_H
25 
26 #include <inttypes.h>
27 #include <stdio.h>
28 
29 #ifdef LV_HAVE_SSE2
30 #include <emmintrin.h>
31 
32  /*!
33  \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
34  \param inputVector The 32 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_32i_s32f_convert_32f_u_sse2(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
41  unsigned int number = 0;
42  const unsigned int quarterPoints = num_points / 4;
43 
44  float* outputVectorPtr = outputVector;
45  const float iScalar = 1.0 / scalar;
46  __m128 invScalar = _mm_set_ps1(iScalar);
47  int32_t* inputPtr = (int32_t*)inputVector;
48  __m128i inputVal;
49  __m128 ret;
50 
51  for(;number < quarterPoints; number++){
52 
53  // Load the 4 values
54  inputVal = _mm_loadu_si128((__m128i*)inputPtr);
55 
56  ret = _mm_cvtepi32_ps(inputVal);
57  ret = _mm_mul_ps(ret, invScalar);
58 
59  _mm_storeu_ps(outputVectorPtr, ret);
60 
61  outputVectorPtr += 4;
62  inputPtr += 4;
63  }
64 
65  number = quarterPoints * 4;
66  for(; number < num_points; number++){
67  outputVector[number] =((float)(inputVector[number])) * iScalar;
68  }
69 }
70 #endif /* LV_HAVE_SSE2 */
71 
72 
73 #ifdef LV_HAVE_GENERIC
74  /*!
75  \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
76  \param inputVector The 32 bit input data buffer
77  \param outputVector The floating point output data buffer
78  \param scalar The value divided against each point in the output buffer
79  \param num_points The number of data values to be converted
80  \note Output buffer does NOT need to be properly aligned
81  */
82 static inline void volk_32i_s32f_convert_32f_generic(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
83  float* outputVectorPtr = outputVector;
84  const int32_t* inputVectorPtr = inputVector;
85  unsigned int number = 0;
86  const float iScalar = 1.0 / scalar;
87 
88  for(number = 0; number < num_points; number++){
89  *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
90  }
91 }
92 #endif /* LV_HAVE_GENERIC */
93 
94 
95 
96 
97 #endif /* INCLUDED_volk_32i_s32f_convert_32f_u_H */
98 #ifndef INCLUDED_volk_32i_s32f_convert_32f_a_H
99 #define INCLUDED_volk_32i_s32f_convert_32f_a_H
100 
101 #include <inttypes.h>
102 #include <stdio.h>
103 
104 #ifdef LV_HAVE_SSE2
105 #include <emmintrin.h>
106 
107  /*!
108  \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
109  \param inputVector The 32 bit input data buffer
110  \param outputVector The floating point output data buffer
111  \param scalar The value divided against each point in the output buffer
112  \param num_points The number of data values to be converted
113  */
114 static inline void volk_32i_s32f_convert_32f_a_sse2(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
115  unsigned int number = 0;
116  const unsigned int quarterPoints = num_points / 4;
117 
118  float* outputVectorPtr = outputVector;
119  const float iScalar = 1.0 / scalar;
120  __m128 invScalar = _mm_set_ps1(iScalar);
121  int32_t* inputPtr = (int32_t*)inputVector;
122  __m128i inputVal;
123  __m128 ret;
124 
125  for(;number < quarterPoints; number++){
126 
127  // Load the 4 values
128  inputVal = _mm_load_si128((__m128i*)inputPtr);
129 
130  ret = _mm_cvtepi32_ps(inputVal);
131  ret = _mm_mul_ps(ret, invScalar);
132 
133  _mm_store_ps(outputVectorPtr, ret);
134 
135  outputVectorPtr += 4;
136  inputPtr += 4;
137  }
138 
139  number = quarterPoints * 4;
140  for(; number < num_points; number++){
141  outputVector[number] =((float)(inputVector[number])) * iScalar;
142  }
143 }
144 #endif /* LV_HAVE_SSE2 */
145 
146 
147 #ifdef LV_HAVE_GENERIC
148  /*!
149  \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
150  \param inputVector The 32 bit input data buffer
151  \param outputVector The floating point output data buffer
152  \param scalar The value divided against each point in the output buffer
153  \param num_points The number of data values to be converted
154  */
155 static inline void volk_32i_s32f_convert_32f_a_generic(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
156  float* outputVectorPtr = outputVector;
157  const int32_t* inputVectorPtr = inputVector;
158  unsigned int number = 0;
159  const float iScalar = 1.0 / scalar;
160 
161  for(number = 0; number < num_points; number++){
162  *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
163  }
164 }
165 #endif /* LV_HAVE_GENERIC */
166 
167 
168 
169 
170 #endif /* INCLUDED_volk_32i_s32f_convert_32f_a_H */
signed int int32_t
Definition: stdint.h:77