GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_8ic_deinterleave_real_8i.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_8sc_DEINTERLEAVE_REAL_8s_ALIGNED8_H
24 #define INCLUDED_VOLK_8sc_DEINTERLEAVE_REAL_8s_ALIGNED8_H
25 
26 #include <inttypes.h>
27 #include <stdio.h>
28 
29 #ifdef LV_HAVE_SSSE3
30 #include <tmmintrin.h>
31 /*!
32  \brief Deinterleaves the complex 8 bit vector into I vector data
33  \param complexVector The complex input vector
34  \param iBuffer The I buffer output data
35  \param num_points The number of complex data values to be deinterleaved
36 */
37 static inline void volk_8ic_deinterleave_real_8i_a_ssse3(int8_t* iBuffer, const lv_8sc_t* complexVector, unsigned int num_points){
38  unsigned int number = 0;
39  const int8_t* complexVectorPtr = (int8_t*)complexVector;
40  int8_t* iBufferPtr = iBuffer;
41  __m128i moveMask1 = _mm_set_epi8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 14, 12, 10, 8, 6, 4, 2, 0);
42  __m128i moveMask2 = _mm_set_epi8(14, 12, 10, 8, 6, 4, 2, 0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80);
43  __m128i complexVal1, complexVal2, outputVal;
44 
45  unsigned int sixteenthPoints = num_points / 16;
46 
47  for(number = 0; number < sixteenthPoints; number++){
48  complexVal1 = _mm_load_si128((__m128i*)complexVectorPtr); complexVectorPtr += 16;
49  complexVal2 = _mm_load_si128((__m128i*)complexVectorPtr); complexVectorPtr += 16;
50 
51  complexVal1 = _mm_shuffle_epi8(complexVal1, moveMask1);
52  complexVal2 = _mm_shuffle_epi8(complexVal2, moveMask2);
53 
54  outputVal = _mm_or_si128(complexVal1, complexVal2);
55 
56  _mm_store_si128((__m128i*)iBufferPtr, outputVal);
57  iBufferPtr += 16;
58  }
59 
60  number = sixteenthPoints * 16;
61  for(; number < num_points; number++){
62  *iBufferPtr++ = *complexVectorPtr++;
63  complexVectorPtr++;
64  }
65 }
66 #endif /* LV_HAVE_SSSE3 */
67 
68 #ifdef LV_HAVE_AVX
69 #include <immintrin.h>
70 /*!
71  \brief Deinterleaves the complex 8 bit vector into I vector data
72  \param complexVector The complex input vector
73  \param iBuffer The I buffer output data
74  \param num_points The number of complex data values to be deinterleaved
75 */
76 
77 static inline void volk_8ic_deinterleave_real_8i_a_avx(int8_t* iBuffer, const lv_8sc_t* complexVector, unsigned int num_points){
78  unsigned int number = 0;
79  const int8_t* complexVectorPtr = (int8_t*)complexVector;
80  int8_t* iBufferPtr = iBuffer;
81  __m128i moveMaskL = _mm_set_epi8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 14, 12, 10, 8, 6, 4, 2, 0);
82  __m128i moveMaskH = _mm_set_epi8(14, 12, 10, 8, 6, 4, 2, 0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80);
83  __m256i complexVal1, complexVal2, outputVal;
84  __m128i complexVal1H, complexVal1L, complexVal2H, complexVal2L, outputVal1, outputVal2;
85 
86  unsigned int thirtysecondPoints = num_points / 32;
87 
88  for(number = 0; number < thirtysecondPoints; number++){
89 
90  complexVal1 = _mm256_load_si256((__m256i*)complexVectorPtr);
91  complexVectorPtr += 32;
92  complexVal2 = _mm256_load_si256((__m256i*)complexVectorPtr);
93  complexVectorPtr += 32;
94 
95  complexVal1H = _mm256_extractf128_si256(complexVal1, 1);
96  complexVal1L = _mm256_extractf128_si256(complexVal1, 0);
97  complexVal2H = _mm256_extractf128_si256(complexVal2, 1);
98  complexVal2L = _mm256_extractf128_si256(complexVal2, 0);
99 
100  complexVal1H = _mm_shuffle_epi8(complexVal1H, moveMaskH);
101  complexVal1L = _mm_shuffle_epi8(complexVal1L, moveMaskL);
102  outputVal1 = _mm_or_si128(complexVal1H, complexVal1L);
103 
104 
105  complexVal2H = _mm_shuffle_epi8(complexVal2H, moveMaskH);
106  complexVal2L = _mm_shuffle_epi8(complexVal2L, moveMaskL);
107  outputVal2 = _mm_or_si128(complexVal2H, complexVal2L);
108 
109  __m256i dummy = _mm256_setzero_si256();
110  outputVal = _mm256_insertf128_si256(dummy, outputVal1, 0);
111  outputVal = _mm256_insertf128_si256(outputVal, outputVal2, 1);
112 
113 
114  _mm256_store_si256((__m256i*)iBufferPtr, outputVal);
115  iBufferPtr += 32;
116  }
117 
118  number = thirtysecondPoints * 32;
119  for(; number < num_points; number++){
120  *iBufferPtr++ = *complexVectorPtr++;
121  complexVectorPtr++;
122  }
123 }
124 #endif /* LV_HAVE_AVX */
125 
126 #ifdef LV_HAVE_GENERIC
127 /*!
128  \brief Deinterleaves the complex 8 bit vector into I vector data
129  \param complexVector The complex input vector
130  \param iBuffer The I buffer output data
131  \param num_points The number of complex data values to be deinterleaved
132 */
133 static inline void volk_8ic_deinterleave_real_8i_generic(int8_t* iBuffer, const lv_8sc_t* complexVector, unsigned int num_points){
134  unsigned int number = 0;
135  const int8_t* complexVectorPtr = (int8_t*)complexVector;
136  int8_t* iBufferPtr = iBuffer;
137  for(number = 0; number < num_points; number++){
138  *iBufferPtr++ = *complexVectorPtr++;
139  complexVectorPtr++;
140  }
141 }
142 #endif /* LV_HAVE_GENERIC */
143 
144 #ifdef LV_HAVE_NEON
145 #include <arm_neon.h>
146 /*!
147  \brief Deinterleaves the complex 8 bit vector into I vector data
148  \param complexVector The complex input vector
149  \param iBuffer The I buffer output data
150  \param num_points The number of complex data values to be deinterleaved
151 */
152 static inline void volk_8ic_deinterleave_real_8i_neon(int8_t* iBuffer, const lv_8sc_t* complexVector, unsigned int num_points){
153  unsigned int number;
154  unsigned int sixteenth_points = num_points / 16;
155 
156  int8x16x2_t input_vector;
157  for(number=0; number < sixteenth_points; ++number) {
158  input_vector = vld2q_s8((int8_t*) complexVector );
159  vst1q_s8(iBuffer, input_vector.val[0]);
160  iBuffer += 16;
161  complexVector += 16;
162  }
163 
164  const int8_t* complexVectorPtr = (int8_t*)complexVector;
165  int8_t* iBufferPtr = iBuffer;
166  for(number = sixteenth_points*16; number < num_points; number++){
167  *iBufferPtr++ = *complexVectorPtr++;
168  complexVectorPtr++;
169  }
170 }
171 #endif /* LV_HAVE_NEON */
172 
173 
174 
175 #endif /* INCLUDED_VOLK_8sc_DEINTERLEAVE_REAL_8s_ALIGNED8_H */
signed char int8_t
Definition: stdint.h:75
char complex lv_8sc_t
Provide typedefs and operators for all complex types in C and C++.
Definition: volk_complex.h:52