Vector Optimized Library of Kernels  2.0
Architecture-tuned implementations of math kernels
volk_32f_x2_subtract_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 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 
71 #ifndef INCLUDED_volk_32f_x2_subtract_32f_a_H
72 #define INCLUDED_volk_32f_x2_subtract_32f_a_H
73 
74 #include <inttypes.h>
75 #include <stdio.h>
76 
77 #ifdef LV_HAVE_AVX512F
78 #include <immintrin.h>
79 
80 static inline void
81 volk_32f_x2_subtract_32f_a_avx512f(float* cVector, const float* aVector,
82  const float* bVector, unsigned int num_points)
83 {
84  unsigned int number = 0;
85  const unsigned int sixteenthPoints = num_points / 16;
86 
87  float* cPtr = cVector;
88  const float* aPtr = aVector;
89  const float* bPtr = bVector;
90 
91  __m512 aVal, bVal, cVal;
92  for(;number < sixteenthPoints; number++){
93 
94  aVal = _mm512_load_ps(aPtr);
95  bVal = _mm512_load_ps(bPtr);
96 
97  cVal = _mm512_sub_ps(aVal, bVal);
98 
99  _mm512_store_ps(cPtr,cVal); // Store the results back into the C container
100 
101  aPtr += 16;
102  bPtr += 16;
103  cPtr += 16;
104  }
105 
106  number = sixteenthPoints *16;
107  for(;number < num_points; number++){
108  *cPtr++ = (*aPtr++) - (*bPtr++);
109  }
110 }
111 #endif /* LV_HAVE_AVX512F */
112 
113 #ifdef LV_HAVE_AVX
114 #include <immintrin.h>
115 
116 static inline void
117 volk_32f_x2_subtract_32f_a_avx(float* cVector, const float* aVector,
118  const float* bVector, unsigned int num_points)
119 {
120  unsigned int number = 0;
121  const unsigned int eighthPoints = num_points / 8;
122 
123  float* cPtr = cVector;
124  const float* aPtr = aVector;
125  const float* bPtr = bVector;
126 
127  __m256 aVal, bVal, cVal;
128  for(;number < eighthPoints; number++){
129 
130  aVal = _mm256_load_ps(aPtr);
131  bVal = _mm256_load_ps(bPtr);
132 
133  cVal = _mm256_sub_ps(aVal, bVal);
134 
135  _mm256_store_ps(cPtr,cVal); // Store the results back into the C container
136 
137  aPtr += 8;
138  bPtr += 8;
139  cPtr += 8;
140  }
141 
142  number = eighthPoints * 8;
143  for(;number < num_points; number++){
144  *cPtr++ = (*aPtr++) - (*bPtr++);
145  }
146 }
147 #endif /* LV_HAVE_AVX */
148 
149 #ifdef LV_HAVE_SSE
150 #include <xmmintrin.h>
151 
152 static inline void
153 volk_32f_x2_subtract_32f_a_sse(float* cVector, const float* aVector,
154  const float* bVector, unsigned int num_points)
155 {
156  unsigned int number = 0;
157  const unsigned int quarterPoints = num_points / 4;
158 
159  float* cPtr = cVector;
160  const float* aPtr = aVector;
161  const float* bPtr = bVector;
162 
163  __m128 aVal, bVal, cVal;
164  for(;number < quarterPoints; number++){
165 
166  aVal = _mm_load_ps(aPtr);
167  bVal = _mm_load_ps(bPtr);
168 
169  cVal = _mm_sub_ps(aVal, bVal);
170 
171  _mm_store_ps(cPtr,cVal); // Store the results back into the C container
172 
173  aPtr += 4;
174  bPtr += 4;
175  cPtr += 4;
176  }
177 
178  number = quarterPoints * 4;
179  for(;number < num_points; number++){
180  *cPtr++ = (*aPtr++) - (*bPtr++);
181  }
182 }
183 #endif /* LV_HAVE_SSE */
184 
185 
186 #ifdef LV_HAVE_GENERIC
187 
188 static inline void
189 volk_32f_x2_subtract_32f_generic(float* cVector, const float* aVector,
190  const float* bVector, unsigned int num_points)
191 {
192  float* cPtr = cVector;
193  const float* aPtr = aVector;
194  const float* bPtr = bVector;
195  unsigned int number = 0;
196 
197  for(number = 0; number < num_points; number++){
198  *cPtr++ = (*aPtr++) - (*bPtr++);
199  }
200 }
201 #endif /* LV_HAVE_GENERIC */
202 
203 
204 #ifdef LV_HAVE_NEON
205 #include <arm_neon.h>
206 
207 static inline void
208 volk_32f_x2_subtract_32f_neon(float* cVector, const float* aVector,
209  const float* bVector, unsigned int num_points)
210 {
211  float* cPtr = cVector;
212  const float* aPtr = aVector;
213  const float* bPtr = bVector;
214  unsigned int number = 0;
215  unsigned int quarter_points = num_points / 4;
216 
217  float32x4_t a_vec, b_vec, c_vec;
218 
219  for(number = 0; number < quarter_points; number++){
220  a_vec = vld1q_f32(aPtr);
221  b_vec = vld1q_f32(bPtr);
222  c_vec = vsubq_f32(a_vec, b_vec);
223  vst1q_f32(cPtr, c_vec);
224  aPtr += 4;
225  bPtr += 4;
226  cPtr += 4;
227  }
228 
229  for(number = quarter_points * 4; number < num_points; number++){
230  *cPtr++ = (*aPtr++) - (*bPtr++);
231  }
232 }
233 #endif /* LV_HAVE_NEON */
234 
235 
236 #ifdef LV_HAVE_ORC
237 extern void
238 volk_32f_x2_subtract_32f_a_orc_impl(float* cVector, const float* aVector,
239  const float* bVector, unsigned int num_points);
240 
241 static inline void
242 volk_32f_x2_subtract_32f_u_orc(float* cVector, const float* aVector,
243  const float* bVector, unsigned int num_points)
244 {
245  volk_32f_x2_subtract_32f_a_orc_impl(cVector, aVector, bVector, num_points);
246 }
247 #endif /* LV_HAVE_ORC */
248 
249 
250 #endif /* INCLUDED_volk_32f_x2_subtract_32f_a_H */
251 
252 
253 #ifndef INCLUDED_volk_32f_x2_subtract_32f_u_H
254 #define INCLUDED_volk_32f_x2_subtract_32f_u_H
255 
256 #include <inttypes.h>
257 #include <stdio.h>
258 
259 #ifdef LV_HAVE_AVX512F
260 #include <immintrin.h>
261 
262 static inline void
263 volk_32f_x2_subtract_32f_u_avx512f(float* cVector, const float* aVector,
264  const float* bVector, unsigned int num_points)
265 {
266  unsigned int number = 0;
267  const unsigned int sixteenthPoints = num_points / 16;
268 
269  float* cPtr = cVector;
270  const float* aPtr = aVector;
271  const float* bPtr = bVector;
272 
273  __m512 aVal, bVal, cVal;
274  for(;number < sixteenthPoints; number++){
275 
276  aVal = _mm512_loadu_ps(aPtr);
277  bVal = _mm512_loadu_ps(bPtr);
278 
279  cVal = _mm512_sub_ps(aVal, bVal);
280 
281  _mm512_storeu_ps(cPtr,cVal); // Store the results back into the C container
282 
283  aPtr += 16;
284  bPtr += 16;
285  cPtr += 16;
286  }
287 
288  number = sixteenthPoints *16;
289  for(;number < num_points; number++){
290  *cPtr++ = (*aPtr++) - (*bPtr++);
291  }
292 }
293 #endif /* LV_HAVE_AVX512F */
294 
295 
296 #ifdef LV_HAVE_AVX
297 #include <immintrin.h>
298 
299 static inline void
300 volk_32f_x2_subtract_32f_u_avx(float* cVector, const float* aVector,
301  const float* bVector, unsigned int num_points)
302 {
303  unsigned int number = 0;
304  const unsigned int eighthPoints = num_points / 8;
305 
306  float* cPtr = cVector;
307  const float* aPtr = aVector;
308  const float* bPtr = bVector;
309 
310  __m256 aVal, bVal, cVal;
311  for(;number < eighthPoints; number++){
312 
313  aVal = _mm256_loadu_ps(aPtr);
314  bVal = _mm256_loadu_ps(bPtr);
315 
316  cVal = _mm256_sub_ps(aVal, bVal);
317 
318  _mm256_storeu_ps(cPtr,cVal); // Store the results back into the C container
319 
320  aPtr += 8;
321  bPtr += 8;
322  cPtr += 8;
323  }
324 
325  number = eighthPoints * 8;
326  for(;number < num_points; number++){
327  *cPtr++ = (*aPtr++) - (*bPtr++);
328  }
329 }
330 #endif /* LV_HAVE_AVX */
331 
332 #endif /* INCLUDED_volk_32f_x2_subtract_32f_u_H */
static void volk_32f_x2_subtract_32f_a_avx(float *cVector, const float *aVector, const float *bVector, unsigned int num_points)
Definition: volk_32f_x2_subtract_32f.h:117
static void volk_32f_x2_subtract_32f_neon(float *cVector, const float *aVector, const float *bVector, unsigned int num_points)
Definition: volk_32f_x2_subtract_32f.h:208
static void volk_32f_x2_subtract_32f_generic(float *cVector, const float *aVector, const float *bVector, unsigned int num_points)
Definition: volk_32f_x2_subtract_32f.h:189
static void volk_32f_x2_subtract_32f_a_sse(float *cVector, const float *aVector, const float *bVector, unsigned int num_points)
Definition: volk_32f_x2_subtract_32f.h:153
static void volk_32f_x2_subtract_32f_u_avx(float *cVector, const float *aVector, const float *bVector, unsigned int num_points)
Definition: volk_32f_x2_subtract_32f.h:300