GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_64f_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_64f_convert_32f_u_H
24 #define INCLUDED_volk_64f_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  \brief Converts the double values into float values
33  \param dVector The converted float vector values
34  \param fVector The double vector values to be converted
35  \param num_points The number of points in the two vectors to be converted
36  */
37 static inline void volk_64f_convert_32f_u_sse2(float* outputVector, const double* inputVector, unsigned int num_points){
38  unsigned int number = 0;
39 
40  const unsigned int quarterPoints = num_points / 4;
41 
42  const double* inputVectorPtr = (const double*)inputVector;
43  float* outputVectorPtr = outputVector;
44  __m128 ret, ret2;
45  __m128d inputVal1, inputVal2;
46 
47  for(;number < quarterPoints; number++){
48  inputVal1 = _mm_loadu_pd(inputVectorPtr); inputVectorPtr += 2;
49  inputVal2 = _mm_loadu_pd(inputVectorPtr); inputVectorPtr += 2;
50 
51  ret = _mm_cvtpd_ps(inputVal1);
52  ret2 = _mm_cvtpd_ps(inputVal2);
53 
54  ret = _mm_movelh_ps(ret, ret2);
55 
56  _mm_storeu_ps(outputVectorPtr, ret);
57  outputVectorPtr += 4;
58  }
59 
60  number = quarterPoints * 4;
61  for(; number < num_points; number++){
62  outputVector[number] = (float)(inputVector[number]);
63  }
64 }
65 #endif /* LV_HAVE_SSE2 */
66 
67 
68 #ifdef LV_HAVE_GENERIC
69 /*!
70  \brief Converts the double values into float values
71  \param dVector The converted float vector values
72  \param fVector The double vector values to be converted
73  \param num_points The number of points in the two vectors to be converted
74 */
75 static inline void volk_64f_convert_32f_generic(float* outputVector, const double* inputVector, unsigned int num_points){
76  float* outputVectorPtr = outputVector;
77  const double* inputVectorPtr = inputVector;
78  unsigned int number = 0;
79 
80  for(number = 0; number < num_points; number++){
81  *outputVectorPtr++ = ((float)(*inputVectorPtr++));
82  }
83 }
84 #endif /* LV_HAVE_GENERIC */
85 
86 
87 
88 
89 #endif /* INCLUDED_volk_64f_convert_32f_u_H */
90 #ifndef INCLUDED_volk_64f_convert_32f_a_H
91 #define INCLUDED_volk_64f_convert_32f_a_H
92 
93 #include <inttypes.h>
94 #include <stdio.h>
95 
96 #ifdef LV_HAVE_SSE2
97 #include <emmintrin.h>
98  /*!
99  \brief Converts the double values into float values
100  \param dVector The converted float vector values
101  \param fVector The double vector values to be converted
102  \param num_points The number of points in the two vectors to be converted
103  */
104 static inline void volk_64f_convert_32f_a_sse2(float* outputVector, const double* inputVector, unsigned int num_points){
105  unsigned int number = 0;
106 
107  const unsigned int quarterPoints = num_points / 4;
108 
109  const double* inputVectorPtr = (const double*)inputVector;
110  float* outputVectorPtr = outputVector;
111  __m128 ret, ret2;
112  __m128d inputVal1, inputVal2;
113 
114  for(;number < quarterPoints; number++){
115  inputVal1 = _mm_load_pd(inputVectorPtr); inputVectorPtr += 2;
116  inputVal2 = _mm_load_pd(inputVectorPtr); inputVectorPtr += 2;
117 
118  ret = _mm_cvtpd_ps(inputVal1);
119  ret2 = _mm_cvtpd_ps(inputVal2);
120 
121  ret = _mm_movelh_ps(ret, ret2);
122 
123  _mm_store_ps(outputVectorPtr, ret);
124  outputVectorPtr += 4;
125  }
126 
127  number = quarterPoints * 4;
128  for(; number < num_points; number++){
129  outputVector[number] = (float)(inputVector[number]);
130  }
131 }
132 #endif /* LV_HAVE_SSE2 */
133 
134 
135 #ifdef LV_HAVE_GENERIC
136 /*!
137  \brief Converts the double values into float values
138  \param dVector The converted float vector values
139  \param fVector The double vector values to be converted
140  \param num_points The number of points in the two vectors to be converted
141 */
142 static inline void volk_64f_convert_32f_a_generic(float* outputVector, const double* inputVector, unsigned int num_points){
143  float* outputVectorPtr = outputVector;
144  const double* inputVectorPtr = inputVector;
145  unsigned int number = 0;
146 
147  for(number = 0; number < num_points; number++){
148  *outputVectorPtr++ = ((float)(*inputVectorPtr++));
149  }
150 }
151 #endif /* LV_HAVE_GENERIC */
152 
153 
154 
155 
156 #endif /* INCLUDED_volk_64f_convert_32f_a_H */