GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_32f_x2_min_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_min_32f_a_H
24 #define INCLUDED_volk_32f_x2_min_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 Selects minimum value from each entry between bVector and aVector and store their results in the cVector
33  \param cVector The vector where the results will be stored
34  \param aVector The vector to be checked
35  \param bVector The vector to be checked
36  \param num_points The number of values in aVector and bVector to be checked and stored into cVector
37 */
38 static inline void volk_32f_x2_min_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_min_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  const float a = *aPtr++;
64  const float b = *bPtr++;
65  *cPtr++ = ( a < b ? a : b);
66  }
67 }
68 #endif /* LV_HAVE_SSE */
69 
70 #ifdef LV_HAVE_NEON
71 #include <arm_neon.h>
72 
73 /*!
74  \brief Selects minimum value from each entry between bVector and aVector and store their results in the cVector
75  \param cVector The vector where the results will be stored
76  \param aVector The vector to be checked
77  \param bVector The vector to be checked
78  \param num_points The number of values in aVector and bVector to be checked and stored into cVector
79 */
80 static inline void volk_32f_x2_min_32f_neon(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
81  float* cPtr = cVector;
82  const float* aPtr = aVector;
83  const float* bPtr= bVector;
84  unsigned int number = 0;
85  unsigned int quarter_points = num_points / 4;
86 
87  float32x4_t a_vec, b_vec, c_vec;
88  for(number = 0; number < quarter_points; number++){
89  a_vec = vld1q_f32(aPtr);
90  b_vec = vld1q_f32(bPtr);
91 
92  c_vec = vminq_f32(a_vec, b_vec);
93 
94  vst1q_f32(cPtr, c_vec);
95  aPtr += 4;
96  bPtr += 4;
97  cPtr += 4;
98  }
99 
100  for(number = quarter_points*4; number < num_points; number++){
101  const float a = *aPtr++;
102  const float b = *bPtr++;
103  *cPtr++ = ( a < b ? a : b);
104  }
105 }
106 #endif /* LV_HAVE_NEON */
107 
108 #ifdef LV_HAVE_GENERIC
109 /*!
110  \brief Selects minimum value from each entry between bVector and aVector and store their results in the cVector
111  \param cVector The vector where the results will be stored
112  \param aVector The vector to be checked
113  \param bVector The vector to be checked
114  \param num_points The number of values in aVector and bVector to be checked and stored into cVector
115 */
116 static inline void volk_32f_x2_min_32f_generic(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
117  float* cPtr = cVector;
118  const float* aPtr = aVector;
119  const float* bPtr= bVector;
120  unsigned int number = 0;
121 
122  for(number = 0; number < num_points; number++){
123  const float a = *aPtr++;
124  const float b = *bPtr++;
125  *cPtr++ = ( a < b ? a : b);
126  }
127 }
128 #endif /* LV_HAVE_GENERIC */
129 
130 #ifdef LV_HAVE_ORC
131 /*!
132  \brief Selects minimum value from each entry between bVector and aVector and store their results in the cVector
133  \param cVector The vector where the results will be stored
134  \param aVector The vector to be checked
135  \param bVector The vector to be checked
136  \param num_points The number of values in aVector and bVector to be checked and stored into cVector
137 */
138 extern void volk_32f_x2_min_32f_a_orc_impl(float* cVector, const float* aVector, const float* bVector, unsigned int num_points);
139 static inline void volk_32f_x2_min_32f_u_orc(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
140  volk_32f_x2_min_32f_a_orc_impl(cVector, aVector, bVector, num_points);
141 }
142 #endif /* LV_HAVE_ORC */
143 
144 
145 #endif /* INCLUDED_volk_32f_x2_min_32f_a_H */