GNU Radio 3.5.3.1 C++ API
volk_32i_s32f_convert_32f_a.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_32i_s32f_convert_32f_a_H
2 #define INCLUDED_volk_32i_s32f_convert_32f_a_H
3 
4 #include <inttypes.h>
5 #include <stdio.h>
6 
7 #ifdef LV_HAVE_SSE2
8 #include <emmintrin.h>
9 
10  /*!
11  \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
12  \param inputVector The 32 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  */
17 static inline void volk_32i_s32f_convert_32f_a_sse2(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
18  unsigned int number = 0;
19  const unsigned int quarterPoints = num_points / 4;
20 
21  float* outputVectorPtr = outputVector;
22  const float iScalar = 1.0 / scalar;
23  __m128 invScalar = _mm_set_ps1(iScalar);
24  int32_t* inputPtr = (int32_t*)inputVector;
25  __m128i inputVal;
26  __m128 ret;
27 
28  for(;number < quarterPoints; number++){
29 
30  // Load the 4 values
31  inputVal = _mm_load_si128((__m128i*)inputPtr);
32 
33  ret = _mm_cvtepi32_ps(inputVal);
34  ret = _mm_mul_ps(ret, invScalar);
35 
36  _mm_store_ps(outputVectorPtr, ret);
37 
38  outputVectorPtr += 4;
39  inputPtr += 4;
40  }
41 
42  number = quarterPoints * 4;
43  for(; number < num_points; number++){
44  outputVector[number] =((float)(inputVector[number])) * iScalar;
45  }
46 }
47 #endif /* LV_HAVE_SSE2 */
48 
49 
50 #ifdef LV_HAVE_GENERIC
51  /*!
52  \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
53  \param inputVector The 32 bit input data buffer
54  \param outputVector The floating point output data buffer
55  \param scalar The value divided against each point in the output buffer
56  \param num_points The number of data values to be converted
57  */
58 static inline void volk_32i_s32f_convert_32f_a_generic(float* outputVector, const int32_t* inputVector, const float scalar, unsigned int num_points){
59  float* outputVectorPtr = outputVector;
60  const int32_t* inputVectorPtr = inputVector;
61  unsigned int number = 0;
62  const float iScalar = 1.0 / scalar;
63 
64  for(number = 0; number < num_points; number++){
65  *outputVectorPtr++ = ((float)(*inputVectorPtr++)) * iScalar;
66  }
67 }
68 #endif /* LV_HAVE_GENERIC */
69 
70 
71 
72 
73 #endif /* INCLUDED_volk_32i_s32f_convert_32f_a_H */