1 #ifndef INCLUDED_volk_32fc_x2_conjugate_dot_prod_32fc_u_H
2 #define INCLUDED_volk_32fc_x2_conjugate_dot_prod_32fc_u_H
11 static inline void volk_32fc_x2_conjugate_dot_prod_32fc_u_generic(
lv_32fc_t* result,
const lv_32fc_t* input,
const lv_32fc_t*
taps,
unsigned int num_bytes) {
13 float * res = (
float*) result;
14 float * in = (
float*) input;
15 float * tp = (
float*) taps;
16 unsigned int n_2_ccomplex_blocks = num_bytes >> 4;
17 unsigned int isodd = (num_bytes >> 3) &1;
21 float sum0[2] = {0,0};
22 float sum1[2] = {0,0};
26 for(i = 0; i < n_2_ccomplex_blocks; ++
i) {
28 sum0[0] += in[0] * tp[0] + in[1] * tp[1];
29 sum0[1] += (-in[0] * tp[1]) + in[1] * tp[0];
30 sum1[0] += in[2] * tp[2] + in[3] * tp[3];
31 sum1[1] += (-in[2] * tp[3]) + in[3] * tp[2];
40 res[0] = sum0[0] + sum1[0];
41 res[1] = sum0[1] + sum1[1];
45 for(i = 0; i < isodd; ++
i) {
48 *result += input[(num_bytes >> 3) - 1] *
lv_conj(taps[(num_bytes >> 3) - 1]);
62 #include <xmmintrin.h>
63 #include <pmmintrin.h>
67 static inline void volk_32fc_x2_conjugate_dot_prod_32fc_u_sse3(
lv_32fc_t* result,
const lv_32fc_t* input,
const lv_32fc_t* taps,
unsigned int num_bytes) {
82 unsigned int offset = 0;
86 __m128 in1, in2, Rv, fehg, Iv, Rs, Ivm, Is;
87 __m128 zv = {0,0,0,0};
89 halfMask.intRep[0] = halfMask.intRep[1] = 0xFFFFFFFF;
90 halfMask.intRep[2] = halfMask.intRep[3] = 0x00000000;
92 negMask.intRep[0] = negMask.intRep[2] = 0x80000000;
93 negMask.intRep[1] = negMask.intRep[3] = 0;
96 while(num_bytes >= 4*
sizeof(
float)){
98 in1 = _mm_loadu_ps( (
float*) (input+offset) );
99 in2 = _mm_loadu_ps( (
float*) (taps+offset) );
100 Rv = _mm_mul_ps(in1, in2);
101 fehg = _mm_shuffle_ps(in2, in2, _MM_SHUFFLE(2,3,0,1));
102 Iv = _mm_mul_ps(in1, fehg);
103 Rs = _mm_hadd_ps( _mm_hadd_ps(Rv, zv) ,zv);
104 Ivm = _mm_xor_ps( negMask.vec, Iv );
105 Is = _mm_hadd_ps( _mm_hadd_ps(Ivm, zv) ,zv);
106 _mm_store_ss( &Im, Is );
107 _mm_store_ss( &Re, Rs );
108 num_bytes -= 4*
sizeof(float);
121 in1 = _mm_loadu_ps( (
float*) (input+offset) );
122 in2 = _mm_loadu_ps( (
float*) (taps+offset) );
123 Rv = _mm_and_ps(_mm_mul_ps(in1, in2), halfMask.vec);
124 fehg = _mm_shuffle_ps(in2, in2, _MM_SHUFFLE(2,3,0,1));
125 Iv = _mm_and_ps(_mm_mul_ps(in1, fehg), halfMask.vec);
126 Rs = _mm_hadd_ps(_mm_hadd_ps(Rv, zv),zv);
127 Ivm = _mm_xor_ps( negMask.vec, Iv );
128 Is = _mm_hadd_ps(_mm_hadd_ps(Ivm, zv),zv);
129 _mm_store_ss( &Im, Is );
130 _mm_store_ss( &Re, Rs );