GNU Radio Manual and C++ API Reference  3.7.4
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
volk_64f_convert_32f.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_64f_convert_32f_u_H
2 #define INCLUDED_volk_64f_convert_32f_u_H
3 
4 #include <inttypes.h>
5 #include <stdio.h>
6 
7 #ifdef LV_HAVE_SSE2
8 #include <emmintrin.h>
9  /*!
10  \brief Converts the double values into float values
11  \param dVector The converted float vector values
12  \param fVector The double vector values to be converted
13  \param num_points The number of points in the two vectors to be converted
14  */
15 static inline void volk_64f_convert_32f_u_sse2(float* outputVector, const double* inputVector, unsigned int num_points){
16  unsigned int number = 0;
17 
18  const unsigned int quarterPoints = num_points / 4;
19 
20  const double* inputVectorPtr = (const double*)inputVector;
21  float* outputVectorPtr = outputVector;
22  __m128 ret, ret2;
23  __m128d inputVal1, inputVal2;
24 
25  for(;number < quarterPoints; number++){
26  inputVal1 = _mm_loadu_pd(inputVectorPtr); inputVectorPtr += 2;
27  inputVal2 = _mm_loadu_pd(inputVectorPtr); inputVectorPtr += 2;
28 
29  ret = _mm_cvtpd_ps(inputVal1);
30  ret2 = _mm_cvtpd_ps(inputVal2);
31 
32  ret = _mm_movelh_ps(ret, ret2);
33 
34  _mm_storeu_ps(outputVectorPtr, ret);
35  outputVectorPtr += 4;
36  }
37 
38  number = quarterPoints * 4;
39  for(; number < num_points; number++){
40  outputVector[number] = (float)(inputVector[number]);
41  }
42 }
43 #endif /* LV_HAVE_SSE2 */
44 
45 
46 #ifdef LV_HAVE_GENERIC
47 /*!
48  \brief Converts the double values into float values
49  \param dVector The converted float vector values
50  \param fVector The double vector values to be converted
51  \param num_points The number of points in the two vectors to be converted
52 */
53 static inline void volk_64f_convert_32f_generic(float* outputVector, const double* inputVector, unsigned int num_points){
54  float* outputVectorPtr = outputVector;
55  const double* inputVectorPtr = inputVector;
56  unsigned int number = 0;
57 
58  for(number = 0; number < num_points; number++){
59  *outputVectorPtr++ = ((float)(*inputVectorPtr++));
60  }
61 }
62 #endif /* LV_HAVE_GENERIC */
63 
64 
65 
66 
67 #endif /* INCLUDED_volk_64f_convert_32f_u_H */
68 #ifndef INCLUDED_volk_64f_convert_32f_a_H
69 #define INCLUDED_volk_64f_convert_32f_a_H
70 
71 #include <inttypes.h>
72 #include <stdio.h>
73 
74 #ifdef LV_HAVE_SSE2
75 #include <emmintrin.h>
76  /*!
77  \brief Converts the double values into float values
78  \param dVector The converted float vector values
79  \param fVector The double vector values to be converted
80  \param num_points The number of points in the two vectors to be converted
81  */
82 static inline void volk_64f_convert_32f_a_sse2(float* outputVector, const double* inputVector, unsigned int num_points){
83  unsigned int number = 0;
84 
85  const unsigned int quarterPoints = num_points / 4;
86 
87  const double* inputVectorPtr = (const double*)inputVector;
88  float* outputVectorPtr = outputVector;
89  __m128 ret, ret2;
90  __m128d inputVal1, inputVal2;
91 
92  for(;number < quarterPoints; number++){
93  inputVal1 = _mm_load_pd(inputVectorPtr); inputVectorPtr += 2;
94  inputVal2 = _mm_load_pd(inputVectorPtr); inputVectorPtr += 2;
95 
96  ret = _mm_cvtpd_ps(inputVal1);
97  ret2 = _mm_cvtpd_ps(inputVal2);
98 
99  ret = _mm_movelh_ps(ret, ret2);
100 
101  _mm_store_ps(outputVectorPtr, ret);
102  outputVectorPtr += 4;
103  }
104 
105  number = quarterPoints * 4;
106  for(; number < num_points; number++){
107  outputVector[number] = (float)(inputVector[number]);
108  }
109 }
110 #endif /* LV_HAVE_SSE2 */
111 
112 
113 #ifdef LV_HAVE_GENERIC
114 /*!
115  \brief Converts the double values into float values
116  \param dVector The converted float vector values
117  \param fVector The double vector values to be converted
118  \param num_points The number of points in the two vectors to be converted
119 */
120 static inline void volk_64f_convert_32f_a_generic(float* outputVector, const double* inputVector, unsigned int num_points){
121  float* outputVectorPtr = outputVector;
122  const double* inputVectorPtr = inputVector;
123  unsigned int number = 0;
124 
125  for(number = 0; number < num_points; number++){
126  *outputVectorPtr++ = ((float)(*inputVectorPtr++));
127  }
128 }
129 #endif /* LV_HAVE_GENERIC */
130 
131 
132 
133 
134 #endif /* INCLUDED_volk_64f_convert_32f_a_H */