GNU Radio Manual and C++ API Reference  3.7.4.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_ORC
139  /*!
140  \brief Multiplies the input complex vector with the input lv_32fc_t vector and store their results in the third vector
141  \param cVector The vector where the results will be stored
142  \param aVector The complex vector to be multiplied
143  \param bVector The vectors containing the lv_32fc_t values to be multiplied against each complex value in aVector
144  \param num_points The number of values in aVector and bVector to be multiplied together and stored into cVector
145  */
146 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);
147 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){
148  volk_32fc_32f_multiply_32fc_a_orc_impl(cVector, aVector, bVector, num_points);
149 }
150 #endif /* LV_HAVE_GENERIC */
151 
152 
153 
154 #endif /* INCLUDED_volk_32fc_32f_multiply_32fc_a_H */
float complex lv_32fc_t
Definition: volk_complex.h:56