GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_8i_convert_16i.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_8i_convert_16i_u_H
24 #define INCLUDED_volk_8i_convert_16i_u_H
25 
26 #include <inttypes.h>
27 #include <stdio.h>
28 
29 #ifdef LV_HAVE_SSE4_1
30 #include <smmintrin.h>
31 
32  /*!
33  \brief Converts the input 8 bit integer data into 16 bit integer data
34  \param inputVector The 8 bit input data buffer
35  \param outputVector The 16 bit output data buffer
36  \param num_points The number of data values to be converted
37  \note Input and output buffers do NOT need to be properly aligned
38  */
39 static inline void volk_8i_convert_16i_u_sse4_1(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
40  unsigned int number = 0;
41  const unsigned int sixteenthPoints = num_points / 16;
42 
43  const __m128i* inputVectorPtr = (const __m128i*)inputVector;
44  __m128i* outputVectorPtr = (__m128i*)outputVector;
45  __m128i inputVal;
46  __m128i ret;
47 
48  for(;number < sixteenthPoints; number++){
49  inputVal = _mm_loadu_si128(inputVectorPtr);
50  ret = _mm_cvtepi8_epi16(inputVal);
51  ret = _mm_slli_epi16(ret, 8); // Multiply by 256
52  _mm_storeu_si128(outputVectorPtr, ret);
53 
54  outputVectorPtr++;
55 
56  inputVal = _mm_srli_si128(inputVal, 8);
57  ret = _mm_cvtepi8_epi16(inputVal);
58  ret = _mm_slli_epi16(ret, 8); // Multiply by 256
59  _mm_storeu_si128(outputVectorPtr, ret);
60 
61  outputVectorPtr++;
62 
63  inputVectorPtr++;
64  }
65 
66  number = sixteenthPoints * 16;
67  for(; number < num_points; number++){
68  outputVector[number] = (int16_t)(inputVector[number])*256;
69  }
70 }
71 #endif /* LV_HAVE_SSE4_1 */
72 
73 #ifdef LV_HAVE_GENERIC
74  /*!
75  \brief Converts the input 8 bit integer data into 16 bit integer data
76  \param inputVector The 8 bit input data buffer
77  \param outputVector The 16 bit output data buffer
78  \param num_points The number of data values to be converted
79  \note Input and output buffers do NOT need to be properly aligned
80  */
81 static inline void volk_8i_convert_16i_generic(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
82  int16_t* outputVectorPtr = outputVector;
83  const int8_t* inputVectorPtr = inputVector;
84  unsigned int number = 0;
85 
86  for(number = 0; number < num_points; number++){
87  *outputVectorPtr++ = ((int16_t)(*inputVectorPtr++)) * 256;
88  }
89 }
90 #endif /* LV_HAVE_GENERIC */
91 
92 
93 
94 
95 #endif /* INCLUDED_VOLK_8s_CONVERT_16s_UNALIGNED8_H */
96 #ifndef INCLUDED_volk_8i_convert_16i_a_H
97 #define INCLUDED_volk_8i_convert_16i_a_H
98 
99 #include <inttypes.h>
100 #include <stdio.h>
101 
102 #ifdef LV_HAVE_SSE4_1
103 #include <smmintrin.h>
104 
105  /*!
106  \brief Converts the input 8 bit integer data into 16 bit integer data
107  \param inputVector The 8 bit input data buffer
108  \param outputVector The 16 bit output data buffer
109  \param num_points The number of data values to be converted
110  */
111 static inline void volk_8i_convert_16i_a_sse4_1(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
112  unsigned int number = 0;
113  const unsigned int sixteenthPoints = num_points / 16;
114 
115  const __m128i* inputVectorPtr = (const __m128i*)inputVector;
116  __m128i* outputVectorPtr = (__m128i*)outputVector;
117  __m128i inputVal;
118  __m128i ret;
119 
120  for(;number < sixteenthPoints; number++){
121  inputVal = _mm_load_si128(inputVectorPtr);
122  ret = _mm_cvtepi8_epi16(inputVal);
123  ret = _mm_slli_epi16(ret, 8); // Multiply by 256
124  _mm_store_si128(outputVectorPtr, ret);
125 
126  outputVectorPtr++;
127 
128  inputVal = _mm_srli_si128(inputVal, 8);
129  ret = _mm_cvtepi8_epi16(inputVal);
130  ret = _mm_slli_epi16(ret, 8); // Multiply by 256
131  _mm_store_si128(outputVectorPtr, ret);
132 
133  outputVectorPtr++;
134 
135  inputVectorPtr++;
136  }
137 
138  number = sixteenthPoints * 16;
139  for(; number < num_points; number++){
140  outputVector[number] = (int16_t)(inputVector[number])*256;
141  }
142 }
143 #endif /* LV_HAVE_SSE4_1 */
144 
145 #ifdef LV_HAVE_GENERIC
146  /*!
147  \brief Converts the input 8 bit integer data into 16 bit integer data
148  \param inputVector The 8 bit input data buffer
149  \param outputVector The 16 bit output data buffer
150  \param num_points The number of data values to be converted
151  */
152 static inline void volk_8i_convert_16i_a_generic(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
153  int16_t* outputVectorPtr = outputVector;
154  const int8_t* inputVectorPtr = inputVector;
155  unsigned int number = 0;
156 
157  for(number = 0; number < num_points; number++){
158  *outputVectorPtr++ = ((int16_t)(*inputVectorPtr++)) * 256;
159  }
160 }
161 #endif /* LV_HAVE_GENERIC */
162 
163 #ifdef LV_HAVE_NEON
164 #include <arm_neon.h>
165 
166  /*!
167  \brief Converts the input 8 bit integer data into 16 bit integer data
168  \param inputVector The 8 bit input data buffer
169  \param outputVector The 16 bit output data buffer
170  \param num_points The number of data values to be converted
171  \note Input and output buffers do NOT need to be properly aligned
172  */
173 static inline void volk_8i_convert_16i_neon(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
174  int16_t* outputVectorPtr = outputVector;
175  const int8_t* inputVectorPtr = inputVector;
176  unsigned int number;
177  const unsigned int eighth_points = num_points / 8;
178 
179  int8x8_t input_vec ;
180  int16x8_t converted_vec;
181 
182  // NEON doesn't have a concept of 8 bit registers, so we are really
183  // dealing with the low half of 16-bit registers. Since this requires
184  // a move instruction we likely do better with ASM here.
185  for(number = 0; number < eighth_points; ++number) {
186  input_vec = vld1_s8(inputVectorPtr);
187  converted_vec = vmovl_s8(input_vec);
188  //converted_vec = vmulq_s16(converted_vec, scale_factor);
189  converted_vec = vshlq_n_s16(converted_vec, 8);
190  vst1q_s16( outputVectorPtr, converted_vec);
191 
192  inputVectorPtr += 8;
193  outputVectorPtr += 8;
194  }
195 
196  for(number = eighth_points * 8; number < num_points; number++){
197  *outputVectorPtr++ = ((int16_t)(*inputVectorPtr++)) * 256;
198  }
199 }
200 #endif /* LV_HAVE_NEON */
201 
202 #ifdef LV_HAVE_ORC
203  /*!
204  \brief Converts the input 8 bit integer data into 16 bit integer data
205  \param inputVector The 8 bit input data buffer
206  \param outputVector The 16 bit output data buffer
207  \param num_points The number of data values to be converted
208  */
209 extern void volk_8i_convert_16i_a_orc_impl(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points);
210 static inline void volk_8i_convert_16i_u_orc(int16_t* outputVector, const int8_t* inputVector, unsigned int num_points){
211  volk_8i_convert_16i_a_orc_impl(outputVector, inputVector, num_points);
212 }
213 #endif /* LV_HAVE_ORC */
214 
215 
216 
217 #endif /* INCLUDED_VOLK_8s_CONVERT_16s_ALIGNED8_H */
signed short int16_t
Definition: stdint.h:76
signed char int8_t
Definition: stdint.h:75