Vector Optimized Library of Kernels  3.3.0
Architecture-tuned implementations of math kernels
volk_32f_s32f_calc_spectral_noise_floor_32f.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012, 2014 Free Software Foundation, Inc.
4  *
5  * This file is part of VOLK
6  *
7  * SPDX-License-Identifier: LGPL-3.0-or-later
8  */
9 
48 #ifndef INCLUDED_volk_32f_s32f_calc_spectral_noise_floor_32f_a_H
49 #define INCLUDED_volk_32f_s32f_calc_spectral_noise_floor_32f_a_H
50 
51 #include <inttypes.h>
52 #include <stdio.h>
53 #include <volk/volk_common.h>
54 
56 
57 #ifdef LV_HAVE_AVX
58 #include <immintrin.h>
59 
60 static inline void
62  const float* realDataPoints,
63  const float spectralExclusionValue,
64  const unsigned int num_points)
65 {
66  unsigned int number = 0;
67  const unsigned int eighthPoints = num_points / 8;
68 
69  const float* dataPointsPtr = realDataPoints;
70  __VOLK_ATTR_ALIGNED(32) float avgPointsVector[8];
71 
72  __m256 dataPointsVal;
73  __m256 avgPointsVal = _mm256_setzero_ps();
74  // Calculate the sum (for mean) for all points
75  for (; number < eighthPoints; number++) {
76 
77  dataPointsVal = _mm256_load_ps(dataPointsPtr);
78 
79  dataPointsPtr += 8;
80 
81  avgPointsVal = _mm256_add_ps(avgPointsVal, dataPointsVal);
82  }
83 
84  _mm256_store_ps(avgPointsVector, avgPointsVal);
85 
86  float sumMean = 0.0;
87  sumMean += avgPointsVector[0];
88  sumMean += avgPointsVector[1];
89  sumMean += avgPointsVector[2];
90  sumMean += avgPointsVector[3];
91  sumMean += avgPointsVector[4];
92  sumMean += avgPointsVector[5];
93  sumMean += avgPointsVector[6];
94  sumMean += avgPointsVector[7];
95 
96  number = eighthPoints * 8;
97  for (; number < num_points; number++) {
98  sumMean += realDataPoints[number];
99  }
100 
101  // calculate the spectral mean
102  // +20 because for the comparison below we only want to throw out bins
103  // that are significantly higher (and would, thus, affect the mean more
104  const float meanAmplitude = (sumMean / ((float)num_points)) + spectralExclusionValue;
105 
106  dataPointsPtr = realDataPoints; // Reset the dataPointsPtr
107  __m256 vMeanAmplitudeVector = _mm256_set1_ps(meanAmplitude);
108  __m256 vOnesVector = _mm256_set1_ps(1.0);
109  __m256 vValidBinCount = _mm256_setzero_ps();
110  avgPointsVal = _mm256_setzero_ps();
111  __m256 compareMask;
112  number = 0;
113  // Calculate the sum (for mean) for any points which do NOT exceed the mean amplitude
114  for (; number < eighthPoints; number++) {
115 
116  dataPointsVal = _mm256_load_ps(dataPointsPtr);
117 
118  dataPointsPtr += 8;
119 
120  // Identify which items do not exceed the mean amplitude
121  compareMask = _mm256_cmp_ps(dataPointsVal, vMeanAmplitudeVector, _CMP_LE_OQ);
122 
123  // Mask off the items that exceed the mean amplitude and add the avg Points that
124  // do not exceed the mean amplitude
125  avgPointsVal =
126  _mm256_add_ps(avgPointsVal, _mm256_and_ps(compareMask, dataPointsVal));
127 
128  // Count the number of bins which do not exceed the mean amplitude
129  vValidBinCount =
130  _mm256_add_ps(vValidBinCount, _mm256_and_ps(compareMask, vOnesVector));
131  }
132 
133  // Calculate the mean from the remaining data points
134  _mm256_store_ps(avgPointsVector, avgPointsVal);
135 
136  sumMean = 0.0;
137  sumMean += avgPointsVector[0];
138  sumMean += avgPointsVector[1];
139  sumMean += avgPointsVector[2];
140  sumMean += avgPointsVector[3];
141  sumMean += avgPointsVector[4];
142  sumMean += avgPointsVector[5];
143  sumMean += avgPointsVector[6];
144  sumMean += avgPointsVector[7];
145 
146  // Calculate the number of valid bins from the remaining count
147  __VOLK_ATTR_ALIGNED(32) float validBinCountVector[8];
148  _mm256_store_ps(validBinCountVector, vValidBinCount);
149 
150  float validBinCount = 0;
151  validBinCount += validBinCountVector[0];
152  validBinCount += validBinCountVector[1];
153  validBinCount += validBinCountVector[2];
154  validBinCount += validBinCountVector[3];
155  validBinCount += validBinCountVector[4];
156  validBinCount += validBinCountVector[5];
157  validBinCount += validBinCountVector[6];
158  validBinCount += validBinCountVector[7];
159 
160  number = eighthPoints * 8;
161  for (; number < num_points; number++) {
162  if (realDataPoints[number] <= meanAmplitude) {
163  sumMean += realDataPoints[number];
164  validBinCount += 1.0;
165  }
166  }
167 
168  float localNoiseFloorAmplitude = 0;
169  if (validBinCount > 0.0) {
170  localNoiseFloorAmplitude = sumMean / validBinCount;
171  } else {
172  localNoiseFloorAmplitude =
173  meanAmplitude; // For the odd case that all the amplitudes are equal...
174  }
175 
176  *noiseFloorAmplitude = localNoiseFloorAmplitude;
177 }
178 #endif /* LV_HAVE_AVX */
179 
180 #ifdef LV_HAVE_SSE
181 #include <xmmintrin.h>
182 
183 static inline void
185  const float* realDataPoints,
186  const float spectralExclusionValue,
187  const unsigned int num_points)
188 {
189  unsigned int number = 0;
190  const unsigned int quarterPoints = num_points / 4;
191 
192  const float* dataPointsPtr = realDataPoints;
193  __VOLK_ATTR_ALIGNED(16) float avgPointsVector[4];
194 
195  __m128 dataPointsVal;
196  __m128 avgPointsVal = _mm_setzero_ps();
197  // Calculate the sum (for mean) for all points
198  for (; number < quarterPoints; number++) {
199 
200  dataPointsVal = _mm_load_ps(dataPointsPtr);
201 
202  dataPointsPtr += 4;
203 
204  avgPointsVal = _mm_add_ps(avgPointsVal, dataPointsVal);
205  }
206 
207  _mm_store_ps(avgPointsVector, avgPointsVal);
208 
209  float sumMean = 0.0;
210  sumMean += avgPointsVector[0];
211  sumMean += avgPointsVector[1];
212  sumMean += avgPointsVector[2];
213  sumMean += avgPointsVector[3];
214 
215  number = quarterPoints * 4;
216  for (; number < num_points; number++) {
217  sumMean += realDataPoints[number];
218  }
219 
220  // calculate the spectral mean
221  // +20 because for the comparison below we only want to throw out bins
222  // that are significantly higher (and would, thus, affect the mean more
223  const float meanAmplitude = (sumMean / ((float)num_points)) + spectralExclusionValue;
224 
225  dataPointsPtr = realDataPoints; // Reset the dataPointsPtr
226  __m128 vMeanAmplitudeVector = _mm_set_ps1(meanAmplitude);
227  __m128 vOnesVector = _mm_set_ps1(1.0);
228  __m128 vValidBinCount = _mm_setzero_ps();
229  avgPointsVal = _mm_setzero_ps();
230  __m128 compareMask;
231  number = 0;
232  // Calculate the sum (for mean) for any points which do NOT exceed the mean amplitude
233  for (; number < quarterPoints; number++) {
234 
235  dataPointsVal = _mm_load_ps(dataPointsPtr);
236 
237  dataPointsPtr += 4;
238 
239  // Identify which items do not exceed the mean amplitude
240  compareMask = _mm_cmple_ps(dataPointsVal, vMeanAmplitudeVector);
241 
242  // Mask off the items that exceed the mean amplitude and add the avg Points that
243  // do not exceed the mean amplitude
244  avgPointsVal = _mm_add_ps(avgPointsVal, _mm_and_ps(compareMask, dataPointsVal));
245 
246  // Count the number of bins which do not exceed the mean amplitude
247  vValidBinCount = _mm_add_ps(vValidBinCount, _mm_and_ps(compareMask, vOnesVector));
248  }
249 
250  // Calculate the mean from the remaining data points
251  _mm_store_ps(avgPointsVector, avgPointsVal);
252 
253  sumMean = 0.0;
254  sumMean += avgPointsVector[0];
255  sumMean += avgPointsVector[1];
256  sumMean += avgPointsVector[2];
257  sumMean += avgPointsVector[3];
258 
259  // Calculate the number of valid bins from the remaining count
260  __VOLK_ATTR_ALIGNED(16) float validBinCountVector[4];
261  _mm_store_ps(validBinCountVector, vValidBinCount);
262 
263  float validBinCount = 0;
264  validBinCount += validBinCountVector[0];
265  validBinCount += validBinCountVector[1];
266  validBinCount += validBinCountVector[2];
267  validBinCount += validBinCountVector[3];
268 
269  number = quarterPoints * 4;
270  for (; number < num_points; number++) {
271  if (realDataPoints[number] <= meanAmplitude) {
272  sumMean += realDataPoints[number];
273  validBinCount += 1.0;
274  }
275  }
276 
277  float localNoiseFloorAmplitude = 0;
278  if (validBinCount > 0.0) {
279  localNoiseFloorAmplitude = sumMean / validBinCount;
280  } else {
281  localNoiseFloorAmplitude =
282  meanAmplitude; // For the odd case that all the amplitudes are equal...
283  }
284 
285  *noiseFloorAmplitude = localNoiseFloorAmplitude;
286 }
287 #endif /* LV_HAVE_SSE */
288 
289 
290 #ifdef LV_HAVE_GENERIC
291 
292 static inline void
294  const float* realDataPoints,
295  const float spectralExclusionValue,
296  const unsigned int num_points)
297 {
298  float sumMean = 0.0;
299  unsigned int number;
300  // find the sum (for mean), etc
301  for (number = 0; number < num_points; number++) {
302  // sum (for mean)
303  sumMean += realDataPoints[number];
304  }
305 
306  // calculate the spectral mean
307  // +20 because for the comparison below we only want to throw out bins
308  // that are significantly higher (and would, thus, affect the mean more)
309  const float meanAmplitude = (sumMean / num_points) + spectralExclusionValue;
310 
311  // now throw out any bins higher than the mean
312  sumMean = 0.0;
313  unsigned int newNumDataPoints = num_points;
314  for (number = 0; number < num_points; number++) {
315  if (realDataPoints[number] <= meanAmplitude)
316  sumMean += realDataPoints[number];
317  else
318  newNumDataPoints--;
319  }
320 
321  float localNoiseFloorAmplitude = 0.0;
322  if (newNumDataPoints == 0) // in the odd case that all
323  localNoiseFloorAmplitude = meanAmplitude; // amplitudes are equal!
324  else
325  localNoiseFloorAmplitude = sumMean / ((float)newNumDataPoints);
326 
327  *noiseFloorAmplitude = localNoiseFloorAmplitude;
328 }
329 #endif /* LV_HAVE_GENERIC */
330 
331 #ifdef LV_HAVE_NEON
332 #include <arm_neon.h>
333 
334 static inline void
336  const float* realDataPoints,
337  const float spectralExclusionValue,
338  const unsigned int num_points)
339 {
340  unsigned int number = 0;
341  const unsigned int quarterPoints = num_points / 4;
342 
343  const float* dataPointsPtr = realDataPoints;
344  float32x4_t avgPointsVal = vdupq_n_f32(0.0f);
345 
346  // Calculate the sum (for mean) for all points
347  for (; number < quarterPoints; number++) {
348  float32x4_t dataPointsVal = vld1q_f32(dataPointsPtr);
349  dataPointsPtr += 4;
350  avgPointsVal = vaddq_f32(avgPointsVal, dataPointsVal);
351  }
352 
353  // Horizontal sum
354  float32x2_t sum2 = vadd_f32(vget_low_f32(avgPointsVal), vget_high_f32(avgPointsVal));
355  float sumMean = vget_lane_f32(vpadd_f32(sum2, sum2), 0);
356 
357  number = quarterPoints * 4;
358  for (; number < num_points; number++) {
359  sumMean += realDataPoints[number];
360  }
361 
362  // calculate the spectral mean
363  const float meanAmplitude = (sumMean / ((float)num_points)) + spectralExclusionValue;
364 
365  dataPointsPtr = realDataPoints;
366  float32x4_t vMeanAmplitudeVector = vdupq_n_f32(meanAmplitude);
367  float32x4_t vOnesVector = vdupq_n_f32(1.0f);
368  float32x4_t vValidBinCount = vdupq_n_f32(0.0f);
369  avgPointsVal = vdupq_n_f32(0.0f);
370  number = 0;
371 
372  // Calculate the sum (for mean) for any points which do NOT exceed the mean amplitude
373  for (; number < quarterPoints; number++) {
374  float32x4_t dataPointsVal = vld1q_f32(dataPointsPtr);
375  dataPointsPtr += 4;
376 
377  // Identify which items do not exceed the mean amplitude
378  uint32x4_t compareMask = vcleq_f32(dataPointsVal, vMeanAmplitudeVector);
379 
380  // Mask off the items that exceed the mean amplitude
381  float32x4_t maskedData = vbslq_f32(compareMask, dataPointsVal, vdupq_n_f32(0.0f));
382  avgPointsVal = vaddq_f32(avgPointsVal, maskedData);
383 
384  // Count the number of bins which do not exceed the mean amplitude
385  float32x4_t maskedOnes = vbslq_f32(compareMask, vOnesVector, vdupq_n_f32(0.0f));
386  vValidBinCount = vaddq_f32(vValidBinCount, maskedOnes);
387  }
388 
389  // Horizontal sums
390  sum2 = vadd_f32(vget_low_f32(avgPointsVal), vget_high_f32(avgPointsVal));
391  sumMean = vget_lane_f32(vpadd_f32(sum2, sum2), 0);
392 
393  float32x2_t cnt2 =
394  vadd_f32(vget_low_f32(vValidBinCount), vget_high_f32(vValidBinCount));
395  float validBinCount = vget_lane_f32(vpadd_f32(cnt2, cnt2), 0);
396 
397  number = quarterPoints * 4;
398  for (; number < num_points; number++) {
399  if (realDataPoints[number] <= meanAmplitude) {
400  sumMean += realDataPoints[number];
401  validBinCount += 1.0f;
402  }
403  }
404 
405  float localNoiseFloorAmplitude = 0;
406  if (validBinCount > 0.0f) {
407  localNoiseFloorAmplitude = sumMean / validBinCount;
408  } else {
409  localNoiseFloorAmplitude = meanAmplitude;
410  }
411 
412  *noiseFloorAmplitude = localNoiseFloorAmplitude;
413 }
414 #endif /* LV_HAVE_NEON */
415 
416 #ifdef LV_HAVE_NEONV8
417 #include <arm_neon.h>
418 
419 static inline void
420 volk_32f_s32f_calc_spectral_noise_floor_32f_neonv8(float* noiseFloorAmplitude,
421  const float* realDataPoints,
422  const float spectralExclusionValue,
423  const unsigned int num_points)
424 {
425  unsigned int number = 0;
426  const unsigned int eighthPoints = num_points / 8;
427 
428  const float* dataPointsPtr = realDataPoints;
429  float32x4_t avgPointsVal0 = vdupq_n_f32(0.0f);
430  float32x4_t avgPointsVal1 = vdupq_n_f32(0.0f);
431 
432  // Calculate the sum (for mean) for all points
433  for (; number < eighthPoints; number++) {
434  __VOLK_PREFETCH(dataPointsPtr + 16);
435  float32x4_t dataPointsVal0 = vld1q_f32(dataPointsPtr);
436  float32x4_t dataPointsVal1 = vld1q_f32(dataPointsPtr + 4);
437  dataPointsPtr += 8;
438  avgPointsVal0 = vaddq_f32(avgPointsVal0, dataPointsVal0);
439  avgPointsVal1 = vaddq_f32(avgPointsVal1, dataPointsVal1);
440  }
441 
442  // Combine and horizontal sum using vaddvq_f32
443  float32x4_t avgPointsVal = vaddq_f32(avgPointsVal0, avgPointsVal1);
444  float sumMean = vaddvq_f32(avgPointsVal);
445 
446  number = eighthPoints * 8;
447  for (; number < num_points; number++) {
448  sumMean += realDataPoints[number];
449  }
450 
451  // calculate the spectral mean
452  const float meanAmplitude = (sumMean / ((float)num_points)) + spectralExclusionValue;
453 
454  dataPointsPtr = realDataPoints;
455  float32x4_t vMeanAmplitudeVector = vdupq_n_f32(meanAmplitude);
456  float32x4_t vOnesVector = vdupq_n_f32(1.0f);
457  float32x4_t vValidBinCount0 = vdupq_n_f32(0.0f);
458  float32x4_t vValidBinCount1 = vdupq_n_f32(0.0f);
459  avgPointsVal0 = vdupq_n_f32(0.0f);
460  avgPointsVal1 = vdupq_n_f32(0.0f);
461  number = 0;
462 
463  // Calculate the sum (for mean) for any points which do NOT exceed the mean amplitude
464  for (; number < eighthPoints; number++) {
465  __VOLK_PREFETCH(dataPointsPtr + 16);
466  float32x4_t dataPointsVal0 = vld1q_f32(dataPointsPtr);
467  float32x4_t dataPointsVal1 = vld1q_f32(dataPointsPtr + 4);
468  dataPointsPtr += 8;
469 
470  // Identify which items do not exceed the mean amplitude
471  uint32x4_t compareMask0 = vcleq_f32(dataPointsVal0, vMeanAmplitudeVector);
472  uint32x4_t compareMask1 = vcleq_f32(dataPointsVal1, vMeanAmplitudeVector);
473 
474  // Mask off the items that exceed the mean amplitude
475  float32x4_t maskedData0 =
476  vbslq_f32(compareMask0, dataPointsVal0, vdupq_n_f32(0.0f));
477  float32x4_t maskedData1 =
478  vbslq_f32(compareMask1, dataPointsVal1, vdupq_n_f32(0.0f));
479  avgPointsVal0 = vaddq_f32(avgPointsVal0, maskedData0);
480  avgPointsVal1 = vaddq_f32(avgPointsVal1, maskedData1);
481 
482  // Count the number of bins which do not exceed the mean amplitude
483  float32x4_t maskedOnes0 = vbslq_f32(compareMask0, vOnesVector, vdupq_n_f32(0.0f));
484  float32x4_t maskedOnes1 = vbslq_f32(compareMask1, vOnesVector, vdupq_n_f32(0.0f));
485  vValidBinCount0 = vaddq_f32(vValidBinCount0, maskedOnes0);
486  vValidBinCount1 = vaddq_f32(vValidBinCount1, maskedOnes1);
487  }
488 
489  // Combine and horizontal sums
490  avgPointsVal = vaddq_f32(avgPointsVal0, avgPointsVal1);
491  sumMean = vaddvq_f32(avgPointsVal);
492 
493  float32x4_t vValidBinCount = vaddq_f32(vValidBinCount0, vValidBinCount1);
494  float validBinCount = vaddvq_f32(vValidBinCount);
495 
496  number = eighthPoints * 8;
497  for (; number < num_points; number++) {
498  if (realDataPoints[number] <= meanAmplitude) {
499  sumMean += realDataPoints[number];
500  validBinCount += 1.0f;
501  }
502  }
503 
504  float localNoiseFloorAmplitude = 0;
505  if (validBinCount > 0.0f) {
506  localNoiseFloorAmplitude = sumMean / validBinCount;
507  } else {
508  localNoiseFloorAmplitude = meanAmplitude;
509  }
510 
511  *noiseFloorAmplitude = localNoiseFloorAmplitude;
512 }
513 #endif /* LV_HAVE_NEONV8 */
514 
515 #endif /* INCLUDED_volk_32f_s32f_calc_spectral_noise_floor_32f_a_H */
516 
517 #ifndef INCLUDED_volk_32f_s32f_calc_spectral_noise_floor_32f_u_H
518 #define INCLUDED_volk_32f_s32f_calc_spectral_noise_floor_32f_u_H
519 
520 #include <inttypes.h>
521 #include <stdio.h>
522 #include <volk/volk_common.h>
523 
524 #ifdef LV_HAVE_AVX
525 #include <immintrin.h>
526 
527 static inline void
529  const float* realDataPoints,
530  const float spectralExclusionValue,
531  const unsigned int num_points)
532 {
533  unsigned int number = 0;
534  const unsigned int eighthPoints = num_points / 8;
535 
536  const float* dataPointsPtr = realDataPoints;
537  __VOLK_ATTR_ALIGNED(16) float avgPointsVector[8];
538 
539  __m256 dataPointsVal;
540  __m256 avgPointsVal = _mm256_setzero_ps();
541  // Calculate the sum (for mean) for all points
542  for (; number < eighthPoints; number++) {
543 
544  dataPointsVal = _mm256_loadu_ps(dataPointsPtr);
545 
546  dataPointsPtr += 8;
547 
548  avgPointsVal = _mm256_add_ps(avgPointsVal, dataPointsVal);
549  }
550 
551  _mm256_storeu_ps(avgPointsVector, avgPointsVal);
552 
553  float sumMean = 0.0;
554  sumMean += avgPointsVector[0];
555  sumMean += avgPointsVector[1];
556  sumMean += avgPointsVector[2];
557  sumMean += avgPointsVector[3];
558  sumMean += avgPointsVector[4];
559  sumMean += avgPointsVector[5];
560  sumMean += avgPointsVector[6];
561  sumMean += avgPointsVector[7];
562 
563  number = eighthPoints * 8;
564  for (; number < num_points; number++) {
565  sumMean += realDataPoints[number];
566  }
567 
568  // calculate the spectral mean
569  // +20 because for the comparison below we only want to throw out bins
570  // that are significantly higher (and would, thus, affect the mean more
571  const float meanAmplitude = (sumMean / ((float)num_points)) + spectralExclusionValue;
572 
573  dataPointsPtr = realDataPoints; // Reset the dataPointsPtr
574  __m256 vMeanAmplitudeVector = _mm256_set1_ps(meanAmplitude);
575  __m256 vOnesVector = _mm256_set1_ps(1.0);
576  __m256 vValidBinCount = _mm256_setzero_ps();
577  avgPointsVal = _mm256_setzero_ps();
578  __m256 compareMask;
579  number = 0;
580  // Calculate the sum (for mean) for any points which do NOT exceed the mean amplitude
581  for (; number < eighthPoints; number++) {
582 
583  dataPointsVal = _mm256_loadu_ps(dataPointsPtr);
584 
585  dataPointsPtr += 8;
586 
587  // Identify which items do not exceed the mean amplitude
588  compareMask = _mm256_cmp_ps(dataPointsVal, vMeanAmplitudeVector, _CMP_LE_OQ);
589 
590  // Mask off the items that exceed the mean amplitude and add the avg Points that
591  // do not exceed the mean amplitude
592  avgPointsVal =
593  _mm256_add_ps(avgPointsVal, _mm256_and_ps(compareMask, dataPointsVal));
594 
595  // Count the number of bins which do not exceed the mean amplitude
596  vValidBinCount =
597  _mm256_add_ps(vValidBinCount, _mm256_and_ps(compareMask, vOnesVector));
598  }
599 
600  // Calculate the mean from the remaining data points
601  _mm256_storeu_ps(avgPointsVector, avgPointsVal);
602 
603  sumMean = 0.0;
604  sumMean += avgPointsVector[0];
605  sumMean += avgPointsVector[1];
606  sumMean += avgPointsVector[2];
607  sumMean += avgPointsVector[3];
608  sumMean += avgPointsVector[4];
609  sumMean += avgPointsVector[5];
610  sumMean += avgPointsVector[6];
611  sumMean += avgPointsVector[7];
612 
613  // Calculate the number of valid bins from the remaining count
614  __VOLK_ATTR_ALIGNED(16) float validBinCountVector[8];
615  _mm256_storeu_ps(validBinCountVector, vValidBinCount);
616 
617  float validBinCount = 0;
618  validBinCount += validBinCountVector[0];
619  validBinCount += validBinCountVector[1];
620  validBinCount += validBinCountVector[2];
621  validBinCount += validBinCountVector[3];
622  validBinCount += validBinCountVector[4];
623  validBinCount += validBinCountVector[5];
624  validBinCount += validBinCountVector[6];
625  validBinCount += validBinCountVector[7];
626 
627  number = eighthPoints * 8;
628  for (; number < num_points; number++) {
629  if (realDataPoints[number] <= meanAmplitude) {
630  sumMean += realDataPoints[number];
631  validBinCount += 1.0;
632  }
633  }
634 
635  float localNoiseFloorAmplitude = 0;
636  if (validBinCount > 0.0) {
637  localNoiseFloorAmplitude = sumMean / validBinCount;
638  } else {
639  localNoiseFloorAmplitude =
640  meanAmplitude; // For the odd case that all the amplitudes are equal...
641  }
642 
643  *noiseFloorAmplitude = localNoiseFloorAmplitude;
644 }
645 #endif /* LV_HAVE_AVX */
646 
647 #ifdef LV_HAVE_RVV
648 #include <riscv_vector.h>
649 
650 static inline void
651 volk_32f_s32f_calc_spectral_noise_floor_32f_rvv(float* noiseFloorAmplitude,
652  const float* realDataPoints,
653  const float spectralExclusionValue,
654  const unsigned int num_points)
655 {
656  float sum;
657  volk_32f_accumulator_s32f_rvv(&sum, realDataPoints, num_points);
658  float meanAmplitude = sum / num_points + spectralExclusionValue;
659 
660  vfloat32m8_t vbin = __riscv_vfmv_v_f_f32m8(meanAmplitude, __riscv_vsetvlmax_e32m8());
661  vfloat32m8_t vsum = __riscv_vfmv_v_f_f32m8(0, __riscv_vsetvlmax_e32m8());
662  size_t n = num_points, binCount = 0;
663  for (size_t vl; n > 0; n -= vl, realDataPoints += vl) {
664  vl = __riscv_vsetvl_e32m8(n);
665  vfloat32m8_t v = __riscv_vle32_v_f32m8(realDataPoints, vl);
666  vbool4_t m = __riscv_vmfle(v, vbin, vl);
667  binCount += __riscv_vcpop(m, vl);
668  vsum = __riscv_vfadd_tumu(m, vsum, vsum, v, vl);
669  }
670  size_t vl = __riscv_vsetvlmax_e32m1();
671  vfloat32m1_t v = RISCV_SHRINK8(vfadd, f, 32, vsum);
672  vfloat32m1_t z = __riscv_vfmv_s_f_f32m1(0, vl);
673  sum = __riscv_vfmv_f(__riscv_vfredusum(v, z, vl));
674 
675  *noiseFloorAmplitude = binCount == 0 ? meanAmplitude : sum / binCount;
676 }
677 #endif /*LV_HAVE_RVV*/
678 
679 #endif /* INCLUDED_volk_32f_s32f_calc_spectral_noise_floor_32f_u_H */
volk_32f_s32f_calc_spectral_noise_floor_32f_a_sse
static void volk_32f_s32f_calc_spectral_noise_floor_32f_a_sse(float *noiseFloorAmplitude, const float *realDataPoints, const float spectralExclusionValue, const unsigned int num_points)
Definition: volk_32f_s32f_calc_spectral_noise_floor_32f.h:184
__VOLK_ATTR_ALIGNED
#define __VOLK_ATTR_ALIGNED(x)
Definition: volk_common.h:62
volk_32f_s32f_calc_spectral_noise_floor_32f_neon
static void volk_32f_s32f_calc_spectral_noise_floor_32f_neon(float *noiseFloorAmplitude, const float *realDataPoints, const float spectralExclusionValue, const unsigned int num_points)
Definition: volk_32f_s32f_calc_spectral_noise_floor_32f.h:335
volk_32f_s32f_calc_spectral_noise_floor_32f_generic
static void volk_32f_s32f_calc_spectral_noise_floor_32f_generic(float *noiseFloorAmplitude, const float *realDataPoints, const float spectralExclusionValue, const unsigned int num_points)
Definition: volk_32f_s32f_calc_spectral_noise_floor_32f.h:293
__VOLK_PREFETCH
#define __VOLK_PREFETCH(addr)
Definition: volk_common.h:68
volk_32f_s32f_calc_spectral_noise_floor_32f_a_avx
static void volk_32f_s32f_calc_spectral_noise_floor_32f_a_avx(float *noiseFloorAmplitude, const float *realDataPoints, const float spectralExclusionValue, const unsigned int num_points)
Definition: volk_32f_s32f_calc_spectral_noise_floor_32f.h:61
volk_common.h
volk_32f_s32f_calc_spectral_noise_floor_32f_u_avx
static void volk_32f_s32f_calc_spectral_noise_floor_32f_u_avx(float *noiseFloorAmplitude, const float *realDataPoints, const float spectralExclusionValue, const unsigned int num_points)
Definition: volk_32f_s32f_calc_spectral_noise_floor_32f.h:528
RISCV_SHRINK8
#define RISCV_SHRINK8(op, T, S, v)
Definition: volk_rvv_intrinsics.h:33
volk_32f_accumulator_s32f.h