44#ifndef INCLUDED_volk_32f_s32f_32f_fm_detect_32f_a_H
45#define INCLUDED_volk_32f_s32f_32f_fm_detect_32f_a_H
54 const float* inputVector,
57 unsigned int num_points)
62 unsigned int number = 1;
66 const unsigned int eighthPoints = (num_points - 1) / 8;
68 float* outPtr = outputVector;
69 const float* inPtr = inputVector;
70 __m256 upperBound = _mm256_set1_ps(bound);
71 __m256 lowerBound = _mm256_set1_ps(-bound);
75 __m256 posBoundAdjust = _mm256_set1_ps(-2 * bound);
76 __m256 negBoundAdjust = _mm256_set1_ps(2 * bound);
78 *outPtr = *inPtr - *saveValue;
85 for (j = 1; j < ((8 < num_points) ? 8 : num_points); j++) {
86 *outPtr = *(inPtr) - *(inPtr - 1);
95 for (; number < eighthPoints; number++) {
97 next3old1 = _mm256_loadu_ps((
float*)(inPtr - 1));
98 next4 = _mm256_load_ps(inPtr);
101 next3old1 = _mm256_sub_ps(next4, next3old1);
103 boundAdjust = _mm256_cmp_ps(next3old1, upperBound, _CMP_GT_OS);
104 boundAdjust = _mm256_and_ps(boundAdjust, posBoundAdjust);
105 next4 = _mm256_cmp_ps(next3old1, lowerBound, _CMP_LT_OS);
106 next4 = _mm256_and_ps(next4, negBoundAdjust);
107 boundAdjust = _mm256_or_ps(next4, boundAdjust);
109 next3old1 = _mm256_add_ps(next3old1, boundAdjust);
110 _mm256_store_ps(outPtr, next3old1);
114 for (number = (8 > (eighthPoints * 8) ? 8 : (8 * eighthPoints)); number < num_points;
116 *outPtr = *(inPtr) - *(inPtr - 1);
118 *outPtr -= 2 * bound;
119 if (*outPtr < -bound)
120 *outPtr += 2 * bound;
125 *saveValue = inputVector[num_points - 1];
131#include <xmmintrin.h>
134 const float* inputVector,
137 unsigned int num_points)
139 if (num_points < 1) {
142 unsigned int number = 1;
146 const unsigned int quarterPoints = (num_points - 1) / 4;
148 float* outPtr = outputVector;
149 const float* inPtr = inputVector;
150 __m128 upperBound = _mm_set_ps1(bound);
151 __m128 lowerBound = _mm_set_ps1(-bound);
155 __m128 posBoundAdjust = _mm_set_ps1(-2 * bound);
156 __m128 negBoundAdjust = _mm_set_ps1(2 * bound);
158 *outPtr = *inPtr - *saveValue;
160 *outPtr -= 2 * bound;
161 if (*outPtr < -bound)
162 *outPtr += 2 * bound;
165 for (j = 1; j < ((4 < num_points) ? 4 : num_points); j++) {
166 *outPtr = *(inPtr) - *(inPtr - 1);
168 *outPtr -= 2 * bound;
169 if (*outPtr < -bound)
170 *outPtr += 2 * bound;
175 for (; number < quarterPoints; number++) {
177 next3old1 = _mm_loadu_ps((
float*)(inPtr - 1));
178 next4 = _mm_load_ps(inPtr);
181 next3old1 = _mm_sub_ps(next4, next3old1);
183 boundAdjust = _mm_cmpgt_ps(next3old1, upperBound);
184 boundAdjust = _mm_and_ps(boundAdjust, posBoundAdjust);
185 next4 = _mm_cmplt_ps(next3old1, lowerBound);
186 next4 = _mm_and_ps(next4, negBoundAdjust);
187 boundAdjust = _mm_or_ps(next4, boundAdjust);
189 next3old1 = _mm_add_ps(next3old1, boundAdjust);
190 _mm_store_ps(outPtr, next3old1);
194 for (number = (4 > (quarterPoints * 4) ? 4 : (4 * quarterPoints));
197 *outPtr = *(inPtr) - *(inPtr - 1);
199 *outPtr -= 2 * bound;
200 if (*outPtr < -bound)
201 *outPtr += 2 * bound;
206 *saveValue = inputVector[num_points - 1];
210#ifdef LV_HAVE_GENERIC
213 const float* inputVector,
216 unsigned int num_points)
218 if (num_points < 1) {
221 unsigned int number = 0;
222 float* outPtr = outputVector;
223 const float* inPtr = inputVector;
226 *outPtr = *inPtr - *saveValue;
228 *outPtr -= 2 * bound;
229 if (*outPtr < -bound)
230 *outPtr += 2 * bound;
234 for (number = 1; number < num_points; number++) {
235 *outPtr = *(inPtr) - *(inPtr - 1);
237 *outPtr -= 2 * bound;
238 if (*outPtr < -bound)
239 *outPtr += 2 * bound;
244 *saveValue = inputVector[num_points - 1];
253 const float* inputVector,
256 unsigned int num_points)
258 if (num_points < 1) {
262 float* outPtr = outputVector;
263 const float* inPtr = inputVector;
265 const float32x4_t upperBound = vdupq_n_f32(bound);
266 const float32x4_t lowerBound = vdupq_n_f32(-bound);
267 const float32x4_t posBoundAdjust = vdupq_n_f32(-2.f * bound);
268 const float32x4_t negBoundAdjust = vdupq_n_f32(2.f * bound);
271 *outPtr = *inPtr - *saveValue;
273 *outPtr -= 2 * bound;
274 if (*outPtr < -bound)
275 *outPtr += 2 * bound;
280 for (
unsigned int j = 1; j < ((4 < num_points) ? 4 : num_points); j++) {
281 *outPtr = *inPtr - *(inPtr - 1);
283 *outPtr -= 2 * bound;
284 if (*outPtr < -bound)
285 *outPtr += 2 * bound;
290 const unsigned int quarterPoints = (num_points - 1) / 4;
291 for (
unsigned int number = 1; number < quarterPoints; number++) {
293 float32x4_t curr = vld1q_f32(inPtr);
294 float32x4_t prev = vld1q_f32(inPtr - 1);
298 float32x4_t diff = vsubq_f32(curr, prev);
301 uint32x4_t aboveMask = vcgtq_f32(diff, upperBound);
302 uint32x4_t belowMask = vcltq_f32(diff, lowerBound);
304 float32x4_t adjust = vbslq_f32(aboveMask, posBoundAdjust, vdupq_n_f32(0));
305 adjust = vbslq_f32(belowMask, negBoundAdjust, adjust);
307 diff = vaddq_f32(diff, adjust);
309 vst1q_f32(outPtr, diff);
314 for (
unsigned int number = (4 > (quarterPoints * 4) ? 4 : (4 * quarterPoints));
317 *outPtr = *inPtr - *(inPtr - 1);
319 *outPtr -= 2 * bound;
320 if (*outPtr < -bound)
321 *outPtr += 2 * bound;
326 *saveValue = inputVector[num_points - 1];
334static inline void volk_32f_s32f_32f_fm_detect_32f_neonv8(
float* outputVector,
335 const float* inputVector,
338 unsigned int num_points)
340 if (num_points < 1) {
344 float* outPtr = outputVector;
345 const float* inPtr = inputVector;
347 const float32x4_t upperBound = vdupq_n_f32(bound);
348 const float32x4_t lowerBound = vdupq_n_f32(-bound);
349 const float32x4_t posBoundAdjust = vdupq_n_f32(-2.f * bound);
350 const float32x4_t negBoundAdjust = vdupq_n_f32(2.f * bound);
351 const float32x4_t zeros = vdupq_n_f32(0);
354 *outPtr = *inPtr - *saveValue;
356 *outPtr -= 2 * bound;
357 if (*outPtr < -bound)
358 *outPtr += 2 * bound;
363 for (
unsigned int j = 1; j < ((8 < num_points) ? 8 : num_points); j++) {
364 *outPtr = *inPtr - *(inPtr - 1);
366 *outPtr -= 2 * bound;
367 if (*outPtr < -bound)
368 *outPtr += 2 * bound;
374 const unsigned int eighthPoints = (num_points - 1) / 8;
375 for (
unsigned int number = 1; number < eighthPoints; number++) {
377 float32x4_t curr0 = vld1q_f32(inPtr);
378 float32x4_t prev0 = vld1q_f32(inPtr - 1);
379 float32x4_t curr1 = vld1q_f32(inPtr + 4);
380 float32x4_t prev1 = vld1q_f32(inPtr + 3);
385 float32x4_t diff0 = vsubq_f32(curr0, prev0);
386 float32x4_t diff1 = vsubq_f32(curr1, prev1);
389 uint32x4_t above0 = vcgtq_f32(diff0, upperBound);
390 uint32x4_t below0 = vcltq_f32(diff0, lowerBound);
391 float32x4_t adj0 = vbslq_f32(above0, posBoundAdjust, zeros);
392 adj0 = vbslq_f32(below0, negBoundAdjust, adj0);
393 diff0 = vaddq_f32(diff0, adj0);
396 uint32x4_t above1 = vcgtq_f32(diff1, upperBound);
397 uint32x4_t below1 = vcltq_f32(diff1, lowerBound);
398 float32x4_t adj1 = vbslq_f32(above1, posBoundAdjust, zeros);
399 adj1 = vbslq_f32(below1, negBoundAdjust, adj1);
400 diff1 = vaddq_f32(diff1, adj1);
402 vst1q_f32(outPtr, diff0);
403 vst1q_f32(outPtr + 4, diff1);
408 for (
unsigned int number = (8 > (eighthPoints * 8) ? 8 : (8 * eighthPoints));
411 *outPtr = *inPtr - *(inPtr - 1);
413 *outPtr -= 2 * bound;
414 if (*outPtr < -bound)
415 *outPtr += 2 * bound;
420 *saveValue = inputVector[num_points - 1];
427#ifndef INCLUDED_volk_32f_s32f_32f_fm_detect_32f_u_H
428#define INCLUDED_volk_32f_s32f_32f_fm_detect_32f_u_H
434#include <immintrin.h>
437 const float* inputVector,
440 unsigned int num_points)
442 if (num_points < 1) {
445 unsigned int number = 1;
449 const unsigned int eighthPoints = (num_points - 1) / 8;
451 float* outPtr = outputVector;
452 const float* inPtr = inputVector;
453 __m256 upperBound = _mm256_set1_ps(bound);
454 __m256 lowerBound = _mm256_set1_ps(-bound);
458 __m256 posBoundAdjust = _mm256_set1_ps(-2 * bound);
459 __m256 negBoundAdjust = _mm256_set1_ps(2 * bound);
461 *outPtr = *inPtr - *saveValue;
463 *outPtr -= 2 * bound;
464 if (*outPtr < -bound)
465 *outPtr += 2 * bound;
468 for (j = 1; j < ((8 < num_points) ? 8 : num_points); j++) {
469 *outPtr = *(inPtr) - *(inPtr - 1);
471 *outPtr -= 2 * bound;
472 if (*outPtr < -bound)
473 *outPtr += 2 * bound;
478 for (; number < eighthPoints; number++) {
480 next3old1 = _mm256_loadu_ps((
float*)(inPtr - 1));
481 next4 = _mm256_loadu_ps(inPtr);
484 next3old1 = _mm256_sub_ps(next4, next3old1);
486 boundAdjust = _mm256_cmp_ps(next3old1, upperBound, _CMP_GT_OS);
487 boundAdjust = _mm256_and_ps(boundAdjust, posBoundAdjust);
488 next4 = _mm256_cmp_ps(next3old1, lowerBound, _CMP_LT_OS);
489 next4 = _mm256_and_ps(next4, negBoundAdjust);
490 boundAdjust = _mm256_or_ps(next4, boundAdjust);
492 next3old1 = _mm256_add_ps(next3old1, boundAdjust);
493 _mm256_storeu_ps(outPtr, next3old1);
497 for (number = (8 > (eighthPoints * 8) ? 8 : (8 * eighthPoints)); number < num_points;
499 *outPtr = *(inPtr) - *(inPtr - 1);
501 *outPtr -= 2 * bound;
502 if (*outPtr < -bound)
503 *outPtr += 2 * bound;
508 *saveValue = inputVector[num_points - 1];
514#include <riscv_vector.h>
516static inline void volk_32f_s32f_32f_fm_detect_32f_rvv(
float* outputVector,
517 const float* inputVector,
520 unsigned int num_points)
525 *outputVector = *inputVector - *saveValue;
526 if (*outputVector > bound)
527 *outputVector -= 2 * bound;
528 if (*outputVector < -bound)
529 *outputVector += 2 * bound;
533 vfloat32m8_t v2bound = __riscv_vfmv_v_f_f32m8(bound * 2, __riscv_vsetvlmax_e32m8());
535 size_t n = num_points - 1;
536 for (
size_t vl; n > 0; n -= vl, inputVector += vl, outputVector += vl) {
537 vl = __riscv_vsetvl_e32m8(n);
538 vfloat32m8_t va = __riscv_vle32_v_f32m8(inputVector, vl);
539 vfloat32m8_t vb = __riscv_vle32_v_f32m8(inputVector - 1, vl);
540 vfloat32m8_t v = __riscv_vfsub(va, vb, vl);
541 v = __riscv_vfsub_mu(__riscv_vmfgt(v, bound, vl), v, v, v2bound, vl);
542 v = __riscv_vfadd_mu(__riscv_vmflt(v, -bound, vl), v, v, v2bound, vl);
543 __riscv_vse32(outputVector, v, vl);
546 *saveValue = inputVector[-1];