61#ifndef INCLUDED_volk_32fc_32f_add_32fc_u_H
62#define INCLUDED_volk_32fc_32f_add_32fc_u_H
69 unsigned int num_points)
73 const float* bPtr = bVector;
74 unsigned int number = 0;
76 for (number = 0; number < num_points; number++) {
77 *cPtr++ = (*aPtr++) + (*bPtr++);
89 unsigned int num_points)
91 unsigned int number = 0;
92 const unsigned int eighthPoints = num_points / 8;
96 const float* bPtr = bVector;
98 __m256 aVal1, aVal2, bVal, cVal1, cVal2;
99 __m256 cpx_b1, cpx_b2;
101 zero = _mm256_setzero_ps();
103 for (; number < eighthPoints; number++) {
105 aVal1 = _mm256_loadu_ps((
float*)aPtr);
106 aVal2 = _mm256_loadu_ps((
float*)(aPtr + 4));
107 bVal = _mm256_loadu_ps(bPtr);
108 cpx_b1 = _mm256_unpacklo_ps(bVal, zero);
109 cpx_b2 = _mm256_unpackhi_ps(bVal, zero);
111 tmp1 = _mm256_permute2f128_ps(cpx_b1, cpx_b2, 0x0 + (0x2 << 4));
112 tmp2 = _mm256_permute2f128_ps(cpx_b1, cpx_b2, 0x1 + (0x3 << 4));
114 cVal1 = _mm256_add_ps(aVal1, tmp1);
115 cVal2 = _mm256_add_ps(aVal2, tmp2);
117 _mm256_storeu_ps((
float*)cPtr,
119 _mm256_storeu_ps((
float*)(cPtr + 4),
127 number = eighthPoints * 8;
128 for (; number < num_points; number++) {
129 *cPtr++ = (*aPtr++) + (*bPtr++);
135#include <immintrin.h>
139 const float* bVector,
140 unsigned int num_points)
142 unsigned int number = 0;
143 const unsigned int eighthPoints = num_points / 8;
147 const float* bPtr = bVector;
149 __m256 aVal1, aVal2, bVal, cVal1, cVal2;
150 __m256 cpx_b1, cpx_b2;
152 zero = _mm256_setzero_ps();
154 for (; number < eighthPoints; number++) {
156 aVal1 = _mm256_load_ps((
float*)aPtr);
157 aVal2 = _mm256_load_ps((
float*)(aPtr + 4));
158 bVal = _mm256_load_ps(bPtr);
159 cpx_b1 = _mm256_unpacklo_ps(bVal, zero);
160 cpx_b2 = _mm256_unpackhi_ps(bVal, zero);
162 tmp1 = _mm256_permute2f128_ps(cpx_b1, cpx_b2, 0x0 + (0x2 << 4));
163 tmp2 = _mm256_permute2f128_ps(cpx_b1, cpx_b2, 0x1 + (0x3 << 4));
165 cVal1 = _mm256_add_ps(aVal1, tmp1);
166 cVal2 = _mm256_add_ps(aVal2, tmp2);
168 _mm256_store_ps((
float*)cPtr,
170 _mm256_store_ps((
float*)(cPtr + 4),
178 number = eighthPoints * 8;
179 for (; number < num_points; number++) {
180 *cPtr++ = (*aPtr++) + (*bPtr++);
190 const float* bVector,
191 unsigned int num_points)
195 const float* bPtr = bVector;
197 float32x4x4_t aVal0, aVal1;
198 float32x4x2_t bVal0, bVal1;
200 const unsigned int sixteenthPoints = num_points / 16;
201 unsigned int number = 0;
202 for (; number < sixteenthPoints; number++) {
203 aVal0 = vld4q_f32((
const float*)aPtr);
205 aVal1 = vld4q_f32((
const float*)aPtr);
209 bVal0 = vld2q_f32((
const float*)bPtr);
211 bVal1 = vld2q_f32((
const float*)bPtr);
215 aVal0.val[0] = vaddq_f32(aVal0.val[0], bVal0.val[0]);
216 aVal0.val[2] = vaddq_f32(aVal0.val[2], bVal0.val[1]);
218 aVal1.val[2] = vaddq_f32(aVal1.val[2], bVal1.val[1]);
219 aVal1.val[0] = vaddq_f32(aVal1.val[0], bVal1.val[0]);
221 vst4q_f32((
float*)(cPtr), aVal0);
223 vst4q_f32((
float*)(cPtr), aVal1);
227 for (number = sixteenthPoints * 16; number < num_points; number++) {
228 *cPtr++ = (*aPtr++) + (*bPtr++);
236static inline void volk_32fc_32f_add_32fc_neonv8(
lv_32fc_t* cVector,
238 const float* bVector,
239 unsigned int num_points)
241 const unsigned int eighthPoints = num_points / 8;
243 const float* aPtr = (
const float*)aVector;
244 const float* bPtr = bVector;
245 float* cPtr = (
float*)cVector;
247 for (
unsigned int number = 0; number < eighthPoints; number++) {
249 float32x4_t a0 = vld1q_f32(aPtr);
250 float32x4_t a1 = vld1q_f32(aPtr + 4);
251 float32x4_t a2 = vld1q_f32(aPtr + 8);
252 float32x4_t a3 = vld1q_f32(aPtr + 12);
255 float32x4_t b0 = vld1q_f32(bPtr);
256 float32x4_t b1 = vld1q_f32(bPtr + 4);
261 float32x4x2_t b0_zip = vzipq_f32(b0, vdupq_n_f32(0));
262 float32x4x2_t b1_zip = vzipq_f32(b1, vdupq_n_f32(0));
265 vst1q_f32(cPtr, vaddq_f32(a0, b0_zip.val[0]));
266 vst1q_f32(cPtr + 4, vaddq_f32(a1, b0_zip.val[1]));
267 vst1q_f32(cPtr + 8, vaddq_f32(a2, b1_zip.val[0]));
268 vst1q_f32(cPtr + 12, vaddq_f32(a3, b1_zip.val[1]));
275 for (
unsigned int number = eighthPoints * 8; number < num_points; number++) {
276 cVector[number] = aVector[number] + bVector[number];
282#include <riscv_vector.h>
284static inline void volk_32fc_32f_add_32fc_rvv(
lv_32fc_t* cVector,
286 const float* bVector,
287 unsigned int num_points)
289 size_t n = num_points;
290 for (
size_t vl; n > 0; n -= vl, cVector += vl, aVector += vl, bVector += vl) {
291 vl = __riscv_vsetvl_e32m4(n);
292 vfloat32m8_t vc = __riscv_vle32_v_f32m8((
const float*)aVector, vl * 2);
293 vuint32m4_t v = __riscv_vle32_v_u32m4((
const uint32_t*)bVector, vl);
294 vfloat32m8_t vf = __riscv_vreinterpret_f32m8(
295 __riscv_vreinterpret_u32m8(__riscv_vzext_vf2_u64m8(v, vl)));
296 __riscv_vse32((
float*)cVector, __riscv_vfadd(vc, vf, vl * 2), vl * 2);