GNU Radio C++ API
volk_8i_s32f_convert_32f_u.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_8i_s32f_convert_32f_u_H
2 #define INCLUDED_volk_8i_s32f_convert_32f_u_H
3 
4 #include <inttypes.h>
5 #include <stdio.h>
6 
7 #ifdef LV_HAVE_SSE4_1
8 #include <smmintrin.h>
9 
10  /*!
11  \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
12  \param inputVector The 8 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_8i_s32f_convert_32f_u_sse4_1(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points){
19  unsigned int number = 0;
20  const unsigned int sixteenthPoints = num_points / 16;
21 
22  float* outputVectorPtr = outputVector;
23  const float iScalar = 1.0 / scalar;
24  __m128 invScalar = _mm_set_ps1( iScalar );
25  const int8_t* inputVectorPtr = inputVector;
26  __m128 ret;
27  __m128i inputVal;
28  __m128i interimVal;
29 
30  for(;number < sixteenthPoints; number++){
31  inputVal = _mm_loadu_si128((__m128i*)inputVectorPtr);
32 
33  interimVal = _mm_cvtepi8_epi32(inputVal);
34  ret = _mm_cvtepi32_ps(interimVal);
35  ret = _mm_mul_ps(ret, invScalar);
36  _mm_storeu_ps(outputVectorPtr, ret);
37  outputVectorPtr += 4;
38 
39  inputVal = _mm_srli_si128(inputVal, 4);
40  interimVal = _mm_cvtepi8_epi32(inputVal);
41  ret = _mm_cvtepi32_ps(interimVal);
42  ret = _mm_mul_ps(ret, invScalar);
43  _mm_storeu_ps(outputVectorPtr, ret);
44  outputVectorPtr += 4;
45 
46  inputVal = _mm_srli_si128(inputVal, 4);
47  interimVal = _mm_cvtepi8_epi32(inputVal);
48  ret = _mm_cvtepi32_ps(interimVal);
49  ret = _mm_mul_ps(ret, invScalar);
50  _mm_storeu_ps(outputVectorPtr, ret);
51  outputVectorPtr += 4;
52 
53  inputVal = _mm_srli_si128(inputVal, 4);
54  interimVal = _mm_cvtepi8_epi32(inputVal);
55  ret = _mm_cvtepi32_ps(interimVal);
56  ret = _mm_mul_ps(ret, invScalar);
57  _mm_storeu_ps(outputVectorPtr, ret);
58  outputVectorPtr += 4;
59 
60  inputVectorPtr += 16;
61  }
62 
63  number = sixteenthPoints * 16;
64  for(; number < num_points; number++){
65  outputVector[number] = (float)(inputVector[number]) * iScalar;
66  }
67 }
68 #endif /* LV_HAVE_SSE4_1 */
69 
70 #ifdef LV_HAVE_GENERIC
71  /*!
72  \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
73  \param inputVector The 8 bit input data buffer
74  \param outputVector The floating point output data buffer
75  \param scalar The value divided against each point in the output buffer
76  \param num_points The number of data values to be converted
77  \note Output buffer does NOT need to be properly aligned
78  */
79 static inline void volk_8i_s32f_convert_32f_u_generic(float* outputVector, const int8_t* inputVector, const float scalar, unsigned int num_points){
80  float* outputVectorPtr = outputVector;
81  const int8_t* inputVectorPtr = inputVector;
82  unsigned int number = 0;
83  const float iScalar = 1.0 / scalar;
84 
85  for(number = 0; number < num_points; number++){
86  *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
87  }
88 }
89 #endif /* LV_HAVE_GENERIC */
90 
91 
92 
93 
94 #endif /* INCLUDED_VOLK_8s_CONVERT_32f_UNALIGNED8_H */