GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_64f_x2_max_64f.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_64f_x2_max_64f_a_H
24 #define INCLUDED_volk_64f_x2_max_64f_a_H
25 
26 #include <inttypes.h>
27 #include <stdio.h>
28 
29 #ifdef LV_HAVE_SSE2
30 #include <emmintrin.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_64f_x2_max_64f_a_sse2(double* cVector, const double* aVector, const double* bVector, unsigned int num_points){
39  unsigned int number = 0;
40  const unsigned int halfPoints = num_points / 2;
41 
42  double* cPtr = cVector;
43  const double* aPtr = aVector;
44  const double* bPtr= bVector;
45 
46  __m128d aVal, bVal, cVal;
47  for(;number < halfPoints; number++){
48 
49  aVal = _mm_load_pd(aPtr);
50  bVal = _mm_load_pd(bPtr);
51 
52  cVal = _mm_max_pd(aVal, bVal);
53 
54  _mm_store_pd(cPtr,cVal); // Store the results back into the C container
55 
56  aPtr += 2;
57  bPtr += 2;
58  cPtr += 2;
59  }
60 
61  number = halfPoints * 2;
62  for(;number < num_points; number++){
63  const double a = *aPtr++;
64  const double b = *bPtr++;
65  *cPtr++ = ( a > b ? a : b);
66  }
67 }
68 #endif /* LV_HAVE_SSE2 */
69 
70 #ifdef LV_HAVE_GENERIC
71 /*!
72  \brief Selects maximum value from each entry between bVector and aVector and store their results in the cVector
73  \param cVector The vector where the results will be stored
74  \param aVector The vector to be checked
75  \param bVector The vector to be checked
76  \param num_points The number of values in aVector and bVector to be checked and stored into cVector
77 */
78 static inline void volk_64f_x2_max_64f_generic(double* cVector, const double* aVector, const double* bVector, unsigned int num_points){
79  double* cPtr = cVector;
80  const double* aPtr = aVector;
81  const double* bPtr= bVector;
82  unsigned int number = 0;
83 
84  for(number = 0; number < num_points; number++){
85  const double a = *aPtr++;
86  const double b = *bPtr++;
87  *cPtr++ = ( a > b ? a : b);
88  }
89 }
90 #endif /* LV_HAVE_GENERIC */
91 
92 
93 #endif /* INCLUDED_volk_64f_x2_max_64f_a_H */