GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_32i_x2_and_32i.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_32i_x2_and_32i_a_H
24 #define INCLUDED_volk_32i_x2_and_32i_a_H
25 
26 #include <inttypes.h>
27 #include <stdio.h>
28 
29 #ifdef LV_HAVE_SSE
30 #include <xmmintrin.h>
31 /*!
32  \brief Ands the two input vectors and store their results in the third vector
33  \param cVector The vector where the results will be stored
34  \param aVector One of the vectors
35  \param bVector One of the vectors
36  \param num_points The number of values in aVector and bVector to be anded together and stored into cVector
37 */
38 static inline void volk_32i_x2_and_32i_a_sse(int32_t* cVector, const int32_t* aVector, const int32_t* bVector, unsigned int num_points){
39  unsigned int number = 0;
40  const unsigned int quarterPoints = num_points / 4;
41 
42  float* cPtr = (float*)cVector;
43  const float* aPtr = (float*)aVector;
44  const float* bPtr = (float*)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_and_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  cVector[number] = aVector[number] & bVector[number];
64  }
65 }
66 #endif /* LV_HAVE_SSE */
67 
68 #ifdef LV_HAVE_NEON
69 #include <arm_neon.h>
70 /*!
71  \brief Ands the two input vectors and store their results in the third vector
72  \param cVector The vector where the results will be stored
73  \param aVector One of the vectors
74  \param bVector One of the vectors
75  \param num_points The number of values in aVector and bVector to be anded together and stored into cVector
76 */
77 static inline void volk_32i_x2_and_32i_neon(int32_t* cVector, const int32_t* aVector, const int32_t* bVector, unsigned int num_points){
78  int32_t* cPtr = cVector;
79  const int32_t* aPtr = aVector;
80  const int32_t* bPtr= bVector;
81  unsigned int number = 0;
82  unsigned int quarter_points = num_points / 4;
83 
84  int32x4_t a_val, b_val, c_val;
85 
86  for(number = 0; number < quarter_points; number++){
87  a_val = vld1q_s32(aPtr);
88  b_val = vld1q_s32(bPtr);
89  c_val = vandq_s32(a_val, b_val);
90  vst1q_s32(cPtr, c_val);
91  aPtr += 4;
92  bPtr += 4;
93  cPtr += 4;
94  }
95 
96  for(number = quarter_points * 4; number < num_points; number++){
97  *cPtr++ = (*aPtr++) & (*bPtr++);
98  }
99 }
100 #endif /* LV_HAVE_NEON */
101 
102 #ifdef LV_HAVE_GENERIC
103 /*!
104  \brief Ands the two input vectors and store their results in the third vector
105  \param cVector The vector where the results will be stored
106  \param aVector One of the vectors
107  \param bVector One of the vectors
108  \param num_points The number of values in aVector and bVector to be anded together and stored into cVector
109 */
110 static inline void volk_32i_x2_and_32i_generic(int32_t* cVector, const int32_t* aVector, const int32_t* bVector, unsigned int num_points){
111  int32_t* cPtr = cVector;
112  const int32_t* aPtr = aVector;
113  const int32_t* bPtr= bVector;
114  unsigned int number = 0;
115 
116  for(number = 0; number < num_points; number++){
117  *cPtr++ = (*aPtr++) & (*bPtr++);
118  }
119 }
120 #endif /* LV_HAVE_GENERIC */
121 
122 #ifdef LV_HAVE_ORC
123 /*!
124  \brief Ands the two input vectors and store their results in the third vector
125  \param cVector The vector where the results will be stored
126  \param aVector One of the vectors
127  \param bVector One of the vectors
128  \param num_points The number of values in aVector and bVector to be anded together and stored into cVector
129 */
130 extern void volk_32i_x2_and_32i_a_orc_impl(int32_t* cVector, const int32_t* aVector, const int32_t* bVector, unsigned int num_points);
131 static inline void volk_32i_x2_and_32i_u_orc(int32_t* cVector, const int32_t* aVector, const int32_t* bVector, unsigned int num_points){
132  volk_32i_x2_and_32i_a_orc_impl(cVector, aVector, bVector, num_points);
133 }
134 #endif /* LV_HAVE_ORC */
135 
136 
137 #endif /* INCLUDED_volk_32i_x2_and_32i_a_H */
signed int int32_t
Definition: stdint.h:77