GNU Radio Manual and C++ API Reference  3.7.5.1
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
volk_32f_x2_subtract_32f.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_32f_x2_subtract_32f_a_H
2 #define INCLUDED_volk_32f_x2_subtract_32f_a_H
3 
4 #include <inttypes.h>
5 #include <stdio.h>
6 
7 #ifdef LV_HAVE_SSE
8 #include <xmmintrin.h>
9 /*!
10  \brief Subtracts bVector form aVector and store their results in the cVector
11  \param cVector The vector where the results will be stored
12  \param aVector The initial vector
13  \param bVector The vector to be subtracted
14  \param num_points The number of values in aVector and bVector to be subtracted together and stored into cVector
15 */
16 static inline void volk_32f_x2_subtract_32f_a_sse(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
17  unsigned int number = 0;
18  const unsigned int quarterPoints = num_points / 4;
19 
20  float* cPtr = cVector;
21  const float* aPtr = aVector;
22  const float* bPtr= bVector;
23 
24  __m128 aVal, bVal, cVal;
25  for(;number < quarterPoints; number++){
26 
27  aVal = _mm_load_ps(aPtr);
28  bVal = _mm_load_ps(bPtr);
29 
30  cVal = _mm_sub_ps(aVal, bVal);
31 
32  _mm_store_ps(cPtr,cVal); // Store the results back into the C container
33 
34  aPtr += 4;
35  bPtr += 4;
36  cPtr += 4;
37  }
38 
39  number = quarterPoints * 4;
40  for(;number < num_points; number++){
41  *cPtr++ = (*aPtr++) - (*bPtr++);
42  }
43 }
44 #endif /* LV_HAVE_SSE */
45 
46 #ifdef LV_HAVE_GENERIC
47 /*!
48  \brief Subtracts bVector form aVector and store their results in the cVector
49  \param cVector The vector where the results will be stored
50  \param aVector The initial vector
51  \param bVector The vector to be subtracted
52  \param num_points The number of values in aVector and bVector to be subtracted together and stored into cVector
53 */
54 static inline void volk_32f_x2_subtract_32f_generic(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
55  float* cPtr = cVector;
56  const float* aPtr = aVector;
57  const float* bPtr= bVector;
58  unsigned int number = 0;
59 
60  for(number = 0; number < num_points; number++){
61  *cPtr++ = (*aPtr++) - (*bPtr++);
62  }
63 }
64 #endif /* LV_HAVE_GENERIC */
65 
66 #ifdef LV_HAVE_NEON
67 #include <arm_neon.h>
68 
69 /*!
70  \brief Subtracts bVector form aVector and store their results in the cVector
71  \param cVector The vector where the results will be stored
72  \param aVector The initial vector
73  \param bVector The vector to be subtracted
74  \param num_points The number of values in aVector and bVector to be subtracted together and stored into cVector
75 */
76 static inline void volk_32f_x2_subtract_32f_neon(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
77  float* cPtr = cVector;
78  const float* aPtr = aVector;
79  const float* bPtr= bVector;
80  unsigned int number = 0;
81  unsigned int quarter_points = num_points / 4;
82 
83  float32x4_t a_vec, b_vec, c_vec;
84 
85  for(number = 0; number < quarter_points; number++){
86  a_vec = vld1q_f32(aPtr);
87  b_vec = vld1q_f32(bPtr);
88  c_vec = vsubq_f32(a_vec, b_vec);
89  vst1q_f32(cPtr, c_vec);
90  aPtr += 4;
91  bPtr += 4;
92  cPtr += 4;
93  }
94 
95  for(number = quarter_points * 4; number < num_points; number++){
96  *cPtr++ = (*aPtr++) - (*bPtr++);
97  }
98 }
99 #endif /* LV_HAVE_NEON */
100 
101 
102 #ifdef LV_HAVE_ORC
103 /*!
104  \brief Subtracts bVector form aVector and store their results in the cVector
105  \param cVector The vector where the results will be stored
106  \param aVector The initial vector
107  \param bVector The vector to be subtracted
108  \param num_points The number of values in aVector and bVector to be subtracted together and stored into cVector
109 */
110 extern void volk_32f_x2_subtract_32f_a_orc_impl(float* cVector, const float* aVector, const float* bVector, unsigned int num_points);
111 static inline void volk_32f_x2_subtract_32f_u_orc(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
112  volk_32f_x2_subtract_32f_a_orc_impl(cVector, aVector, bVector, num_points);
113 }
114 #endif /* LV_HAVE_ORC */
115 
116 
117 #endif /* INCLUDED_volk_32f_x2_subtract_32f_a_H */