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