GNU Radio Manual and C++ API Reference  3.7.5.1
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
volk_32fc_32f_multiply_32fc.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_32fc_32f_multiply_32fc_a_H
2 #define INCLUDED_volk_32fc_32f_multiply_32fc_a_H
3 
4 #include <inttypes.h>
5 #include <stdio.h>
6 
7 #ifdef LV_HAVE_AVX
8 #include <immintrin.h>
9  /*!
10  \brief Multiplies the input complex vector with the input float vector and store their results in the third vector
11  \param cVector The vector where the results will be stored
12  \param aVector The complex vector to be multiplied
13  \param bVector The vectors containing the float values to be multiplied against each complex value in aVector
14  \param num_points The number of values in aVector and bVector to be multiplied together and stored into cVector
15  */
16 static inline void volk_32fc_32f_multiply_32fc_a_avx(lv_32fc_t* cVector, const lv_32fc_t* aVector, const float* bVector, unsigned int num_points)
17 {
18  unsigned int number = 0;
19  const unsigned int eighthPoints = num_points / 8;
20 
21  lv_32fc_t* cPtr = cVector;
22  const lv_32fc_t* aPtr = aVector;
23  const float* bPtr= bVector;
24 
25  __m256 aVal1, aVal2, bVal, bVal1, bVal2, cVal1, cVal2;
26 
27  __m256i permute_mask = _mm256_set_epi32(3, 3, 2, 2, 1, 1, 0, 0);
28 
29  for(;number < eighthPoints; number++){
30 
31  aVal1 = _mm256_load_ps((float *)aPtr);
32  aPtr += 4;
33 
34  aVal2 = _mm256_load_ps((float *)aPtr);
35  aPtr += 4;
36 
37  bVal = _mm256_load_ps(bPtr); // b0|b1|b2|b3|b4|b5|b6|b7
38  bPtr += 8;
39 
40  bVal1 = _mm256_permute2f128_ps(bVal, bVal, 0x00); // b0|b1|b2|b3|b0|b1|b2|b3
41  bVal2 = _mm256_permute2f128_ps(bVal, bVal, 0x11); // b4|b5|b6|b7|b4|b5|b6|b7
42 
43  bVal1 = _mm256_permutevar_ps(bVal1, permute_mask); // b0|b0|b1|b1|b2|b2|b3|b3
44  bVal2 = _mm256_permutevar_ps(bVal2, permute_mask); // b4|b4|b5|b5|b6|b6|b7|b7
45 
46  cVal1 = _mm256_mul_ps(aVal1, bVal1);
47  cVal2 = _mm256_mul_ps(aVal2, bVal2);
48 
49  _mm256_store_ps((float*)cPtr,cVal1); // Store the results back into the C container
50  cPtr += 4;
51 
52  _mm256_store_ps((float*)cPtr,cVal2); // Store the results back into the C container
53  cPtr += 4;
54  }
55 
56  number = eighthPoints * 8;
57  for(;number < num_points; ++number){
58  *cPtr++ = (*aPtr++) * (*bPtr++);
59  }
60 }
61 #endif /* LV_HAVE_AVX */
62 
63 
64 
65 #ifdef LV_HAVE_SSE
66 #include <xmmintrin.h>
67  /*!
68  \brief Multiplies the input complex vector with the input float vector and store their results in the third vector
69  \param cVector The vector where the results will be stored
70  \param aVector The complex vector to be multiplied
71  \param bVector The vectors containing the float values to be multiplied against each complex value in aVector
72  \param num_points The number of values in aVector and bVector to be multiplied together and stored into cVector
73  */
74 static inline void volk_32fc_32f_multiply_32fc_a_sse(lv_32fc_t* cVector, const lv_32fc_t* aVector, const float* bVector, unsigned int num_points)
75 {
76  unsigned int number = 0;
77  const unsigned int quarterPoints = num_points / 4;
78 
79  lv_32fc_t* cPtr = cVector;
80  const lv_32fc_t* aPtr = aVector;
81  const float* bPtr= bVector;
82 
83  __m128 aVal1, aVal2, bVal, bVal1, bVal2, cVal;
84  for(;number < quarterPoints; number++){
85 
86  aVal1 = _mm_load_ps((const float*)aPtr);
87  aPtr += 2;
88 
89  aVal2 = _mm_load_ps((const float*)aPtr);
90  aPtr += 2;
91 
92  bVal = _mm_load_ps(bPtr);
93  bPtr += 4;
94 
95  bVal1 = _mm_shuffle_ps(bVal, bVal, _MM_SHUFFLE(1,1,0,0));
96  bVal2 = _mm_shuffle_ps(bVal, bVal, _MM_SHUFFLE(3,3,2,2));
97 
98  cVal = _mm_mul_ps(aVal1, bVal1);
99 
100  _mm_store_ps((float*)cPtr,cVal); // Store the results back into the C container
101  cPtr += 2;
102 
103  cVal = _mm_mul_ps(aVal2, bVal2);
104 
105  _mm_store_ps((float*)cPtr,cVal); // Store the results back into the C container
106 
107  cPtr += 2;
108  }
109 
110  number = quarterPoints * 4;
111  for(;number < num_points; number++){
112  *cPtr++ = (*aPtr++) * (*bPtr);
113  bPtr++;
114  }
115 }
116 #endif /* LV_HAVE_SSE */
117 
118 #ifdef LV_HAVE_GENERIC
119  /*!
120  \brief Multiplies the input complex vector with the input lv_32fc_t vector and store their results in the third vector
121  \param cVector The vector where the results will be stored
122  \param aVector The complex vector to be multiplied
123  \param bVector The vectors containing the lv_32fc_t values to be multiplied against each complex value in aVector
124  \param num_points The number of values in aVector and bVector to be multiplied together and stored into cVector
125  */
126 static inline void volk_32fc_32f_multiply_32fc_generic(lv_32fc_t* cVector, const lv_32fc_t* aVector, const float* bVector, unsigned int num_points){
127  lv_32fc_t* cPtr = cVector;
128  const lv_32fc_t* aPtr = aVector;
129  const float* bPtr= bVector;
130  unsigned int number = 0;
131 
132  for(number = 0; number < num_points; number++){
133  *cPtr++ = (*aPtr++) * (*bPtr++);
134  }
135 }
136 #endif /* LV_HAVE_GENERIC */
137 
138 #ifdef LV_HAVE_NEON
139 #include <arm_neon.h>
140  /*!
141  \brief Multiplies the input complex vector with the input lv_32fc_t vector and store their results in the third vector
142  \param cVector The vector where the results will be stored
143  \param aVector The complex vector to be multiplied
144  \param bVector The vectors containing the lv_32fc_t values to be multiplied against each complex value in aVector
145  \param num_points The number of values in aVector and bVector to be multiplied together and stored into cVector
146  */
147 static inline void volk_32fc_32f_multiply_32fc_neon(lv_32fc_t* cVector, const lv_32fc_t* aVector, const float* bVector, unsigned int num_points){
148  lv_32fc_t* cPtr = cVector;
149  const lv_32fc_t* aPtr = aVector;
150  const float* bPtr= bVector;
151  unsigned int number = 0;
152  unsigned int quarter_points = num_points / 4;
153 
154  float32x4x2_t inputVector, outputVector;
155  float32x4_t tapsVector;
156  for(number = 0; number < quarter_points; number++){
157  inputVector = vld2q_f32((float*)aPtr);
158  tapsVector = vld1q_f32(bPtr);
159 
160  outputVector.val[0] = vmulq_f32(inputVector.val[0], tapsVector);
161  outputVector.val[1] = vmulq_f32(inputVector.val[1], tapsVector);
162 
163  vst2q_f32((float*)cPtr, outputVector);
164  aPtr += 4;
165  bPtr += 4;
166  cPtr += 4;
167  }
168 
169  for(number = quarter_points * 4; number < num_points; number++){
170  *cPtr++ = (*aPtr++) * (*bPtr++);
171  }
172 }
173 #endif /* LV_HAVE_NEON */
174 
175 #ifdef LV_HAVE_ORC
176  /*!
177  \brief Multiplies the input complex vector with the input lv_32fc_t vector and store their results in the third vector
178  \param cVector The vector where the results will be stored
179  \param aVector The complex vector to be multiplied
180  \param bVector The vectors containing the lv_32fc_t values to be multiplied against each complex value in aVector
181  \param num_points The number of values in aVector and bVector to be multiplied together and stored into cVector
182  */
183 extern void volk_32fc_32f_multiply_32fc_a_orc_impl(lv_32fc_t* cVector, const lv_32fc_t* aVector, const float* bVector, unsigned int num_points);
184 static inline void volk_32fc_32f_multiply_32fc_u_orc(lv_32fc_t* cVector, const lv_32fc_t* aVector, const float* bVector, unsigned int num_points){
185  volk_32fc_32f_multiply_32fc_a_orc_impl(cVector, aVector, bVector, num_points);
186 }
187 #endif /* LV_HAVE_GENERIC */
188 
189 
190 
191 #endif /* INCLUDED_volk_32fc_32f_multiply_32fc_a_H */
float complex lv_32fc_t
Definition: volk_complex.h:56