GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_32f_x2_subtract_32f.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2014 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_volk_32f_x2_subtract_32f_a_H
24 #define INCLUDED_volk_32f_x2_subtract_32f_a_H
25 
26 #include <inttypes.h>
27 #include <stdio.h>
28 
29 #ifdef LV_HAVE_SSE
30 #include <xmmintrin.h>
31 /*!
32  \brief Subtracts bVector form aVector and store their results in the cVector
33  \param cVector The vector where the results will be stored
34  \param aVector The initial vector
35  \param bVector The vector to be subtracted
36  \param num_points The number of values in aVector and bVector to be subtracted together and stored into cVector
37 */
38 static inline void volk_32f_x2_subtract_32f_a_sse(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
39  unsigned int number = 0;
40  const unsigned int quarterPoints = num_points / 4;
41 
42  float* cPtr = cVector;
43  const float* aPtr = aVector;
44  const float* bPtr= bVector;
45 
46  __m128 aVal, bVal, cVal;
47  for(;number < quarterPoints; number++){
48 
49  aVal = _mm_load_ps(aPtr);
50  bVal = _mm_load_ps(bPtr);
51 
52  cVal = _mm_sub_ps(aVal, bVal);
53 
54  _mm_store_ps(cPtr,cVal); // Store the results back into the C container
55 
56  aPtr += 4;
57  bPtr += 4;
58  cPtr += 4;
59  }
60 
61  number = quarterPoints * 4;
62  for(;number < num_points; number++){
63  *cPtr++ = (*aPtr++) - (*bPtr++);
64  }
65 }
66 #endif /* LV_HAVE_SSE */
67 
68 #ifdef LV_HAVE_GENERIC
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_generic(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 
82  for(number = 0; number < num_points; number++){
83  *cPtr++ = (*aPtr++) - (*bPtr++);
84  }
85 }
86 #endif /* LV_HAVE_GENERIC */
87 
88 #ifdef LV_HAVE_NEON
89 #include <arm_neon.h>
90 
91 /*!
92  \brief Subtracts bVector form aVector and store their results in the cVector
93  \param cVector The vector where the results will be stored
94  \param aVector The initial vector
95  \param bVector The vector to be subtracted
96  \param num_points The number of values in aVector and bVector to be subtracted together and stored into cVector
97 */
98 static inline void volk_32f_x2_subtract_32f_neon(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
99  float* cPtr = cVector;
100  const float* aPtr = aVector;
101  const float* bPtr= bVector;
102  unsigned int number = 0;
103  unsigned int quarter_points = num_points / 4;
104 
105  float32x4_t a_vec, b_vec, c_vec;
106 
107  for(number = 0; number < quarter_points; number++){
108  a_vec = vld1q_f32(aPtr);
109  b_vec = vld1q_f32(bPtr);
110  c_vec = vsubq_f32(a_vec, b_vec);
111  vst1q_f32(cPtr, c_vec);
112  aPtr += 4;
113  bPtr += 4;
114  cPtr += 4;
115  }
116 
117  for(number = quarter_points * 4; number < num_points; number++){
118  *cPtr++ = (*aPtr++) - (*bPtr++);
119  }
120 }
121 #endif /* LV_HAVE_NEON */
122 
123 
124 #ifdef LV_HAVE_ORC
125 /*!
126  \brief Subtracts bVector form aVector and store their results in the cVector
127  \param cVector The vector where the results will be stored
128  \param aVector The initial vector
129  \param bVector The vector to be subtracted
130  \param num_points The number of values in aVector and bVector to be subtracted together and stored into cVector
131 */
132 extern void volk_32f_x2_subtract_32f_a_orc_impl(float* cVector, const float* aVector, const float* bVector, unsigned int num_points);
133 static inline void volk_32f_x2_subtract_32f_u_orc(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
134  volk_32f_x2_subtract_32f_a_orc_impl(cVector, aVector, bVector, num_points);
135 }
136 #endif /* LV_HAVE_ORC */
137 
138 
139 #endif /* INCLUDED_volk_32f_x2_subtract_32f_a_H */