61#ifndef INCLUDED_volk_32fc_x2_conjugate_dot_prod_32fc_u_H
62#define INCLUDED_volk_32fc_x2_conjugate_dot_prod_32fc_u_H
73 unsigned int num_points)
76 for (
unsigned int i = 0;
i < num_points; ++
i) {
77 res += (*input++) *
lv_conj((*taps++));
89 unsigned int num_points)
92 const unsigned int num_bytes = num_points * 8;
94 float* res = (
float*)result;
95 float* in = (
float*)input;
96 float* tp = (
float*)taps;
97 unsigned int n_2_ccomplex_blocks = num_bytes >> 4;
99 float sum0[2] = { 0, 0 };
100 float sum1[2] = { 0, 0 };
103 for (
i = 0;
i < n_2_ccomplex_blocks; ++
i) {
104 sum0[0] += in[0] * tp[0] + in[1] * tp[1];
105 sum0[1] += (-in[0] * tp[1]) + in[1] * tp[0];
106 sum1[0] += in[2] * tp[2] + in[3] * tp[3];
107 sum1[1] += (-in[2] * tp[3]) + in[3] * tp[2];
113 res[0] = sum0[0] + sum1[0];
114 res[1] = sum0[1] + sum1[1];
116 if (num_bytes >> 3 & 1) {
117 *result += input[(num_bytes >> 3) - 1] *
lv_conj(taps[(num_bytes >> 3) - 1]);
125#include <immintrin.h>
130 unsigned int num_points)
133 __m256 sum_a_mult_b_real = _mm256_setzero_ps();
134 __m256 sum_a_mult_b_imag = _mm256_setzero_ps();
136 for (
long unsigned i = 0;
i < (num_points & ~3u);
i += 4) {
148 __m256 a = _mm256_loadu_ps((
const float*)&input[
i]);
149 __m256 b = _mm256_loadu_ps((
const float*)&taps[
i]);
150 __m256 b_real = _mm256_moveldup_ps(b);
151 __m256 b_imag = _mm256_movehdup_ps(b);
154 sum_a_mult_b_real = _mm256_add_ps(sum_a_mult_b_real, _mm256_mul_ps(a, b_real));
156 sum_a_mult_b_imag = _mm256_addsub_ps(sum_a_mult_b_imag, _mm256_mul_ps(a, b_imag));
160 sum_a_mult_b_imag = _mm256_permute_ps(sum_a_mult_b_imag, _MM_SHUFFLE(2, 3, 0, 1));
162 __m256 sum = _mm256_add_ps(sum_a_mult_b_real, sum_a_mult_b_imag);
166 sum = _mm256_add_ps(sum, _mm256_permute2f128_ps(sum, sum, 0x01));
168 sum = _mm256_add_ps(sum, _mm256_permute_ps(sum, _MM_SHUFFLE(1, 0, 3, 2)));
170 __m128 lower = _mm256_extractf128_ps(sum, 0);
171 _mm_storel_pi((__m64*)result, lower);
174 for (
long unsigned i = num_points & ~3u;
i < num_points; ++
i) {
186#include <pmmintrin.h>
187#include <xmmintrin.h>
192 unsigned int num_points)
195 __m128 sum_a_mult_b_real = _mm_setzero_ps();
196 __m128 sum_a_mult_b_imag = _mm_setzero_ps();
198 for (
long unsigned i = 0;
i < (num_points & ~1u);
i += 2) {
210 __m128 a = _mm_loadu_ps((
const float*)&input[
i]);
211 __m128 b = _mm_loadu_ps((
const float*)&taps[
i]);
212 __m128 b_real = _mm_moveldup_ps(b);
213 __m128 b_imag = _mm_movehdup_ps(b);
216 sum_a_mult_b_real = _mm_add_ps(sum_a_mult_b_real, _mm_mul_ps(a, b_real));
218 sum_a_mult_b_imag = _mm_addsub_ps(sum_a_mult_b_imag, _mm_mul_ps(a, b_imag));
223 _mm_shuffle_ps(sum_a_mult_b_imag, sum_a_mult_b_imag, _MM_SHUFFLE(2, 3, 0, 1));
225 __m128 sum = _mm_add_ps(sum_a_mult_b_real, sum_a_mult_b_imag);
227 sum = _mm_add_ps(sum, _mm_shuffle_ps(sum, sum, _MM_SHUFFLE(1, 0, 3, 2)));
229 _mm_storel_pi((__m64*)result, sum);
232 if (num_points & 1u) {
248 unsigned int num_points)
251 unsigned int quarter_points = num_points / 4;
258 float32x4x2_t a_val, b_val, accumulator;
259 float32x4x2_t tmp_imag;
260 accumulator.val[0] = vdupq_n_f32(0);
261 accumulator.val[1] = vdupq_n_f32(0);
263 for (number = 0; number < quarter_points; ++number) {
264 a_val = vld2q_f32((
float*)a_ptr);
265 b_val = vld2q_f32((
float*)b_ptr);
270 tmp_imag.val[1] = vmulq_f32(a_val.val[1], b_val.val[0]);
271 tmp_imag.val[0] = vmulq_f32(a_val.val[0], b_val.val[0]);
274 tmp_imag.val[1] = vmlsq_f32(tmp_imag.val[1], a_val.val[0], b_val.val[1]);
275 tmp_imag.val[0] = vmlaq_f32(tmp_imag.val[0], a_val.val[1], b_val.val[1]);
277 accumulator.val[0] = vaddq_f32(accumulator.val[0], tmp_imag.val[0]);
278 accumulator.val[1] = vaddq_f32(accumulator.val[1], tmp_imag.val[1]);
285 vst2q_f32((
float*)accum_result, accumulator);
286 *result = accum_result[0] + accum_result[1] + accum_result[2] + accum_result[3];
289 for (number = quarter_points * 4; number < num_points; ++number) {
290 *result += (*a_ptr++) *
lv_conj(*b_ptr++);
298#ifndef INCLUDED_volk_32fc_x2_conjugate_dot_prod_32fc_a_H
299#define INCLUDED_volk_32fc_x2_conjugate_dot_prod_32fc_a_H
307#include <immintrin.h>
312 unsigned int num_points)
315 __m256 sum_a_mult_b_real = _mm256_setzero_ps();
316 __m256 sum_a_mult_b_imag = _mm256_setzero_ps();
318 for (
long unsigned i = 0;
i < (num_points & ~3u);
i += 4) {
330 __m256 a = _mm256_load_ps((
const float*)&input[
i]);
331 __m256 b = _mm256_load_ps((
const float*)&taps[
i]);
332 __m256 b_real = _mm256_moveldup_ps(b);
333 __m256 b_imag = _mm256_movehdup_ps(b);
336 sum_a_mult_b_real = _mm256_add_ps(sum_a_mult_b_real, _mm256_mul_ps(a, b_real));
338 sum_a_mult_b_imag = _mm256_addsub_ps(sum_a_mult_b_imag, _mm256_mul_ps(a, b_imag));
342 sum_a_mult_b_imag = _mm256_permute_ps(sum_a_mult_b_imag, _MM_SHUFFLE(2, 3, 0, 1));
344 __m256 sum = _mm256_add_ps(sum_a_mult_b_real, sum_a_mult_b_imag);
348 sum = _mm256_add_ps(sum, _mm256_permute2f128_ps(sum, sum, 0x01));
350 sum = _mm256_add_ps(sum, _mm256_permute_ps(sum, _MM_SHUFFLE(1, 0, 3, 2)));
352 __m128 lower = _mm256_extractf128_ps(sum, 0);
353 _mm_storel_pi((__m64*)result, lower);
356 for (
long unsigned i = num_points & ~3u;
i < num_points; ++
i) {
367#include <pmmintrin.h>
368#include <xmmintrin.h>
373 unsigned int num_points)
376 __m128 sum_a_mult_b_real = _mm_setzero_ps();
377 __m128 sum_a_mult_b_imag = _mm_setzero_ps();
379 for (
long unsigned i = 0;
i < (num_points & ~1u);
i += 2) {
391 __m128 a = _mm_load_ps((
const float*)&input[
i]);
392 __m128 b = _mm_load_ps((
const float*)&taps[
i]);
393 __m128 b_real = _mm_moveldup_ps(b);
394 __m128 b_imag = _mm_movehdup_ps(b);
397 sum_a_mult_b_real = _mm_add_ps(sum_a_mult_b_real, _mm_mul_ps(a, b_real));
399 sum_a_mult_b_imag = _mm_addsub_ps(sum_a_mult_b_imag, _mm_mul_ps(a, b_imag));
404 _mm_shuffle_ps(sum_a_mult_b_imag, sum_a_mult_b_imag, _MM_SHUFFLE(2, 3, 0, 1));
406 __m128 sum = _mm_add_ps(sum_a_mult_b_real, sum_a_mult_b_imag);
408 sum = _mm_add_ps(sum, _mm_shuffle_ps(sum, sum, _MM_SHUFFLE(1, 0, 3, 2)));
410 _mm_storel_pi((__m64*)result, sum);
413 if (num_points & 1u) {
425#include <riscv_vector.h>
428static inline void volk_32fc_x2_conjugate_dot_prod_32fc_rvv(
lv_32fc_t* result,
431 unsigned int num_points)
433 vfloat32m2_t vsumr = __riscv_vfmv_v_f_f32m2(0, __riscv_vsetvlmax_e32m2());
434 vfloat32m2_t vsumi = vsumr;
435 size_t n = num_points;
436 for (
size_t vl; n > 0; n -= vl, input += vl, taps += vl) {
437 vl = __riscv_vsetvl_e32m2(n);
438 vuint64m4_t va = __riscv_vle64_v_u64m4((
const uint64_t*)input, vl);
439 vuint64m4_t vb = __riscv_vle64_v_u64m4((
const uint64_t*)taps, vl);
440 vfloat32m2_t var = __riscv_vreinterpret_f32m2(__riscv_vnsrl(va, 0, vl));
441 vfloat32m2_t vbr = __riscv_vreinterpret_f32m2(__riscv_vnsrl(vb, 0, vl));
442 vfloat32m2_t vai = __riscv_vreinterpret_f32m2(__riscv_vnsrl(va, 32, vl));
443 vfloat32m2_t vbi = __riscv_vreinterpret_f32m2(__riscv_vnsrl(vb, 32, vl));
444 vbi = __riscv_vfneg(vbi, vl);
445 vfloat32m2_t vr = __riscv_vfnmsac(__riscv_vfmul(var, vbr, vl), vai, vbi, vl);
446 vfloat32m2_t vi = __riscv_vfmacc(__riscv_vfmul(var, vbi, vl), vai, vbr, vl);
447 vsumr = __riscv_vfadd_tu(vsumr, vsumr, vr, vl);
448 vsumi = __riscv_vfadd_tu(vsumi, vsumi, vi, vl);
450 size_t vl = __riscv_vsetvlmax_e32m1();
453 vfloat32m1_t z = __riscv_vfmv_s_f_f32m1(0, vl);
454 *result =
lv_cmake(__riscv_vfmv_f(__riscv_vfredusum(vr, z, vl)),
455 __riscv_vfmv_f(__riscv_vfredusum(vi, z, vl)));
460#include <riscv_vector.h>
463static inline void volk_32fc_x2_conjugate_dot_prod_32fc_rvvseg(
lv_32fc_t* result,
466 unsigned int num_points)
468 vfloat32m2_t vsumr = __riscv_vfmv_v_f_f32m2(0, __riscv_vsetvlmax_e32m2());
469 vfloat32m2_t vsumi = vsumr;
470 size_t n = num_points;
471 for (
size_t vl; n > 0; n -= vl, input += vl, taps += vl) {
472 vl = __riscv_vsetvl_e32m2(n);
473 vfloat32m2x2_t va = __riscv_vlseg2e32_v_f32m2x2((
const float*)input, vl);
474 vfloat32m2x2_t vb = __riscv_vlseg2e32_v_f32m2x2((
const float*)taps, vl);
475 vfloat32m2_t var = __riscv_vget_f32m2(va, 0), vai = __riscv_vget_f32m2(va, 1);
476 vfloat32m2_t vbr = __riscv_vget_f32m2(vb, 0), vbi = __riscv_vget_f32m2(vb, 1);
477 vbi = __riscv_vfneg(vbi, vl);
478 vfloat32m2_t vr = __riscv_vfnmsac(__riscv_vfmul(var, vbr, vl), vai, vbi, vl);
479 vfloat32m2_t vi = __riscv_vfmacc(__riscv_vfmul(var, vbi, vl), vai, vbr, vl);
480 vsumr = __riscv_vfadd_tu(vsumr, vsumr, vr, vl);
481 vsumi = __riscv_vfadd_tu(vsumi, vsumi, vi, vl);
483 size_t vl = __riscv_vsetvlmax_e32m1();
486 vfloat32m1_t z = __riscv_vfmv_s_f_f32m1(0, vl);
487 *result =
lv_cmake(__riscv_vfmv_f(__riscv_vfredusum(vr, z, vl)),
488 __riscv_vfmv_f(__riscv_vfredusum(vi, z, vl)));
static void volk_32fc_x2_conjugate_dot_prod_32fc_a_sse3(lv_32fc_t *result, const lv_32fc_t *input, const lv_32fc_t *taps, unsigned int num_points)
Definition volk_32fc_x2_conjugate_dot_prod_32fc.h:370
static void volk_32fc_x2_conjugate_dot_prod_32fc_a_avx(lv_32fc_t *result, const lv_32fc_t *input, const lv_32fc_t *taps, unsigned int num_points)
Definition volk_32fc_x2_conjugate_dot_prod_32fc.h:309
static void volk_32fc_x2_conjugate_dot_prod_32fc_generic(lv_32fc_t *result, const lv_32fc_t *input, const lv_32fc_t *taps, unsigned int num_points)
Definition volk_32fc_x2_conjugate_dot_prod_32fc.h:70
static void volk_32fc_x2_conjugate_dot_prod_32fc_u_avx(lv_32fc_t *result, const lv_32fc_t *input, const lv_32fc_t *taps, unsigned int num_points)
Definition volk_32fc_x2_conjugate_dot_prod_32fc.h:127
static void volk_32fc_x2_conjugate_dot_prod_32fc_block(lv_32fc_t *result, const lv_32fc_t *input, const lv_32fc_t *taps, unsigned int num_points)
Definition volk_32fc_x2_conjugate_dot_prod_32fc.h:86
static 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_points)
Definition volk_32fc_x2_conjugate_dot_prod_32fc.h:189
static void volk_32fc_x2_conjugate_dot_prod_32fc_neon(lv_32fc_t *result, const lv_32fc_t *input, const lv_32fc_t *taps, unsigned int num_points)
Definition volk_32fc_x2_conjugate_dot_prod_32fc.h:245
#define __VOLK_PREFETCH(addr)
Definition volk_common.h:68
#define lv_cimag(x)
Definition volk_complex.h:98
#define lv_conj(x)
Definition volk_complex.h:100
#define lv_cmake(r, i)
Definition volk_complex.h:77
#define lv_creal(x)
Definition volk_complex.h:96
float complex lv_32fc_t
Definition volk_complex.h:74
for i
Definition volk_config_fixed.tmpl.h:13
#define RISCV_SHRINK2(op, T, S, v)
Definition volk_rvv_intrinsics.h:19