GNU Radio 3.7.3 C++ API
volk_32f_accumulator_s32f.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_32f_accumulator_s32f_a_H
2 #define INCLUDED_volk_32f_accumulator_s32f_a_H
3 
4 #include <volk/volk_common.h>
5 #include <inttypes.h>
6 #include <stdio.h>
7 
8 #ifdef LV_HAVE_SSE
9 #include <xmmintrin.h>
10 /*!
11  \brief Accumulates the values in the input buffer
12  \param result The accumulated result
13  \param inputBuffer The buffer of data to be accumulated
14  \param num_points The number of values in inputBuffer to be accumulated
15 */
16 static inline void volk_32f_accumulator_s32f_a_sse(float* result, const float* inputBuffer, unsigned int num_points){
17  float returnValue = 0;
18  unsigned int number = 0;
19  const unsigned int quarterPoints = num_points / 4;
20 
21  const float* aPtr = inputBuffer;
22  __VOLK_ATTR_ALIGNED(16) float tempBuffer[4];
23 
24  __m128 accumulator = _mm_setzero_ps();
25  __m128 aVal = _mm_setzero_ps();
26 
27  for(;number < quarterPoints; number++){
28  aVal = _mm_load_ps(aPtr);
29  accumulator = _mm_add_ps(accumulator, aVal);
30  aPtr += 4;
31  }
32  _mm_store_ps(tempBuffer,accumulator); // Store the results back into the C container
33  returnValue = tempBuffer[0];
34  returnValue += tempBuffer[1];
35  returnValue += tempBuffer[2];
36  returnValue += tempBuffer[3];
37 
38  number = quarterPoints * 4;
39  for(;number < num_points; number++){
40  returnValue += (*aPtr++);
41  }
42  *result = returnValue;
43 }
44 #endif /* LV_HAVE_SSE */
45 
46 #ifdef LV_HAVE_GENERIC
47 /*!
48  \brief Accumulates the values in the input buffer
49  \param result The accumulated result
50  \param inputBuffer The buffer of data to be accumulated
51  \param num_points The number of values in inputBuffer to be accumulated
52 */
53 static inline void volk_32f_accumulator_s32f_generic(float* result, const float* inputBuffer, unsigned int num_points){
54  const float* aPtr = inputBuffer;
55  unsigned int number = 0;
56  float returnValue = 0;
57 
58  for(;number < num_points; number++){
59  returnValue += (*aPtr++);
60  }
61  *result = returnValue;
62 }
63 #endif /* LV_HAVE_GENERIC */
64 
65 
66 
67 
68 #endif /* INCLUDED_volk_32f_accumulator_s32f_a_H */
#define __VOLK_ATTR_ALIGNED(x)
Definition: volk_common.h:27