GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_32f_x2_max_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_max_32f_a_H
24 #define INCLUDED_volk_32f_x2_max_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 maximum 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_max_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_max_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  \brief Selects maximum value from each entry between bVector and aVector and store their results in the cVector
74  \param cVector The vector where the results will be stored
75  \param aVector The vector to be checked
76  \param bVector The vector to be checked
77  \param num_points The number of values in aVector and bVector to be checked and stored into cVector
78 */
79 static inline void volk_32f_x2_max_32f_neon(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
80  unsigned int quarter_points = num_points / 4;
81  float* cPtr = cVector;
82  const float* aPtr = aVector;
83  const float* bPtr= bVector;
84  unsigned int number = 0;
85 
86  float32x4_t a_vec, b_vec, c_vec;
87  for(number = 0; number < quarter_points; number++){
88  a_vec = vld1q_f32(aPtr);
89  b_vec = vld1q_f32(bPtr);
90  c_vec = vmaxq_f32(a_vec, b_vec);
91  vst1q_f32(cPtr, c_vec);
92  aPtr += 4;
93  bPtr += 4;
94  cPtr += 4;
95  }
96 
97  for(number = quarter_points*4; number < num_points; number++){
98  const float a = *aPtr++;
99  const float b = *bPtr++;
100  *cPtr++ = ( a > b ? a : b);
101  }
102 
103 }
104 #endif /* LV_HAVE_NEON */
105 
106 #ifdef LV_HAVE_GENERIC
107 /*!
108  \brief Selects maximum value from each entry between bVector and aVector and store their results in the cVector
109  \param cVector The vector where the results will be stored
110  \param aVector The vector to be checked
111  \param bVector The vector to be checked
112  \param num_points The number of values in aVector and bVector to be checked and stored into cVector
113 */
114 static inline void volk_32f_x2_max_32f_generic(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
115  float* cPtr = cVector;
116  const float* aPtr = aVector;
117  const float* bPtr= bVector;
118  unsigned int number = 0;
119 
120  for(number = 0; number < num_points; number++){
121  const float a = *aPtr++;
122  const float b = *bPtr++;
123  *cPtr++ = ( a > b ? a : b);
124  }
125 }
126 #endif /* LV_HAVE_GENERIC */
127 
128 #ifdef LV_HAVE_ORC
129 /*!
130  \brief Selects maximum value from each entry between bVector and aVector and store their results in the cVector
131  \param cVector The vector where the results will be stored
132  \param aVector The vector to be checked
133  \param bVector The vector to be checked
134  \param num_points The number of values in aVector and bVector to be checked and stored into cVector
135 */
136 extern void volk_32f_x2_max_32f_a_orc_impl(float* cVector, const float* aVector, const float* bVector, unsigned int num_points);
137 static inline void volk_32f_x2_max_32f_u_orc(float* cVector, const float* aVector, const float* bVector, unsigned int num_points){
138  volk_32f_x2_max_32f_a_orc_impl(cVector, aVector, bVector, num_points);
139 }
140 #endif /* LV_HAVE_ORC */
141 
142 
143 #endif /* INCLUDED_volk_32f_x2_max_32f_a_H */