40 #ifndef INCLUDED_volk_16u_byteswap_u_H
41 #define INCLUDED_volk_16u_byteswap_u_H
46 #ifdef LV_HAVE_GENERIC
49 unsigned int num_points)
51 uint16_t* inputPtr = intsToSwap;
52 for (
unsigned int point = 0; point < num_points; point++) {
53 uint16_t output = *inputPtr;
54 output = (((output >> 8) & 0xff) | ((output << 8) & 0xff00));
63 #include <immintrin.h>
64 static inline void volk_16u_byteswap_a_avx2(uint16_t* intsToSwap,
unsigned int num_points)
68 const unsigned int nPerSet = 16;
69 const uint64_t nSets = num_points / nPerSet;
71 uint16_t* inputPtr = (uint16_t*)intsToSwap;
73 const uint8_t shuffleVector[32] = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11,
74 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20,
75 23, 22, 25, 24, 27, 26, 29, 28, 31, 30 };
77 const __m256i myShuffle = _mm256_loadu_si256((__m256i*)&shuffleVector[0]);
79 for (number = 0; number < nSets; number++) {
81 const __m256i input = _mm256_load_si256((__m256i*)inputPtr);
82 const __m256i output = _mm256_shuffle_epi8(input, myShuffle);
85 _mm256_store_si256((__m256i*)inputPtr, output);
90 for (number = nPerSet * nSets; number < num_points; number++) {
91 uint16_t outputVal = *inputPtr;
92 outputVal = (((outputVal >> 8) & 0xff) | ((outputVal << 8) & 0xff00));
93 *inputPtr = outputVal;
101 #include <immintrin.h>
102 static inline void volk_16u_byteswap_u_avx2(uint16_t* intsToSwap,
unsigned int num_points)
106 const unsigned int nPerSet = 16;
107 const uint64_t nSets = num_points / nPerSet;
109 uint16_t* inputPtr = (uint16_t*)intsToSwap;
111 const uint8_t shuffleVector[32] = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11,
112 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20,
113 23, 22, 25, 24, 27, 26, 29, 28, 31, 30 };
115 const __m256i myShuffle = _mm256_loadu_si256((__m256i*)&shuffleVector[0]);
117 for (number = 0; number < nSets; number++) {
119 const __m256i input = _mm256_loadu_si256((__m256i*)inputPtr);
120 const __m256i output = _mm256_shuffle_epi8(input, myShuffle);
123 _mm256_storeu_si256((__m256i*)inputPtr, output);
128 for (number = nPerSet * nSets; number < num_points; number++) {
129 uint16_t outputVal = *inputPtr;
130 outputVal = (((outputVal >> 8) & 0xff) | ((outputVal << 8) & 0xff00));
131 *inputPtr = outputVal;
139 #include <emmintrin.h>
143 unsigned int number = 0;
144 uint16_t* inputPtr = intsToSwap;
145 __m128i input, left, right, output;
147 const unsigned int eighthPoints = num_points / 8;
148 for (; number < eighthPoints; number++) {
162 number = eighthPoints * 8;
163 for (; number < num_points; number++) {
164 uint16_t outputVal = *inputPtr;
165 outputVal = (((outputVal >> 8) & 0xff) | ((outputVal << 8) & 0xff00));
166 *inputPtr = outputVal;
174 #ifndef INCLUDED_volk_16u_byteswap_a_H
175 #define INCLUDED_volk_16u_byteswap_a_H
177 #include <inttypes.h>
181 #include <emmintrin.h>
185 uint16_t* inputPtr = intsToSwap;
186 __m128i input, left, right, output;
188 const unsigned int eighthPoints = num_points / 8;
189 for (
unsigned int number = 0; number < eighthPoints; number++) {
208 #include <arm_neon.h>
213 unsigned int eighth_points = num_points / 8;
214 uint16x8_t input, output;
215 uint16_t* inputPtr = intsToSwap;
217 for (number = 0; number < eighth_points; number++) {
218 input = vld1q_u16(inputPtr);
219 output = vsriq_n_u16(output, input, 8);
220 output = vsliq_n_u16(output, input, 8);
221 vst1q_u16(inputPtr, output);
230 #include <arm_neon.h>
233 unsigned int num_points)
235 uint16_t* inputPtr = intsToSwap;
236 unsigned int number = 0;
237 unsigned int n16points = num_points / 16;
239 uint8x8x4_t input_table;
240 uint8x8_t int_lookup01, int_lookup23, int_lookup45, int_lookup67;
241 uint8x8_t swapped_int01, swapped_int23, swapped_int45, swapped_int67;
251 int_lookup01 = vcreate_u8(1232017111498883080);
252 int_lookup23 = vcreate_u8(1376697457175036426);
253 int_lookup45 = vcreate_u8(1521377802851189772);
254 int_lookup67 = vcreate_u8(1666058148527343118);
256 for (number = 0; number < n16points; ++number) {
257 input_table = vld4_u8((uint8_t*)inputPtr);
258 swapped_int01 = vtbl4_u8(input_table, int_lookup01);
259 swapped_int23 = vtbl4_u8(input_table, int_lookup23);
260 swapped_int45 = vtbl4_u8(input_table, int_lookup45);
261 swapped_int67 = vtbl4_u8(input_table, int_lookup67);
262 vst1_u8((uint8_t*)inputPtr, swapped_int01);
263 vst1_u8((uint8_t*)(inputPtr + 4), swapped_int23);
264 vst1_u8((uint8_t*)(inputPtr + 8), swapped_int45);
265 vst1_u8((uint8_t*)(inputPtr + 12), swapped_int67);
274 #ifdef LV_HAVE_GENERIC
277 unsigned int num_points)
279 uint16_t* inputPtr = intsToSwap;
280 for (
unsigned int point = 0; point < num_points; point++) {
281 uint16_t output = *inputPtr;
282 output = (((output >> 8) & 0xff) | ((output << 8) & 0xff00));
291 extern void volk_16u_byteswap_a_orc_impl(uint16_t* intsToSwap,
unsigned int num_points);
292 static inline void volk_16u_byteswap_u_orc(uint16_t* intsToSwap,
unsigned int num_points)
294 volk_16u_byteswap_a_orc_impl(intsToSwap, num_points);
FORCE_INLINE void _mm_store_si128(__m128i *p, __m128i a)
Definition: sse2neon.h:5937
FORCE_INLINE __m128i _mm_loadu_si128(const __m128i *p)
Definition: sse2neon.h:4570
FORCE_INLINE __m128i _mm_load_si128(const __m128i *p)
Definition: sse2neon.h:4471
FORCE_INLINE void _mm_storeu_si128(__m128i *p, __m128i a)
Definition: sse2neon.h:6010
FORCE_INLINE __m128i _mm_slli_epi16(__m128i a, int imm)
Definition: sse2neon.h:5544
#define _mm_srli_epi16(a, imm)
Definition: sse2neon.h:5812
FORCE_INLINE __m128i _mm_or_si128(__m128i, __m128i)
Definition: sse2neon.h:5021
int64x2_t __m128i
Definition: sse2neon.h:244
static void volk_16u_byteswap_u_sse2(uint16_t *intsToSwap, unsigned int num_points)
Definition: volk_16u_byteswap.h:141
static void volk_16u_byteswap_a_generic(uint16_t *intsToSwap, unsigned int num_points)
Definition: volk_16u_byteswap.h:276
static void volk_16u_byteswap_neon(uint16_t *intsToSwap, unsigned int num_points)
Definition: volk_16u_byteswap.h:210
static void volk_16u_byteswap_a_sse2(uint16_t *intsToSwap, unsigned int num_points)
Definition: volk_16u_byteswap.h:183
static void volk_16u_byteswap_generic(uint16_t *intsToSwap, unsigned int num_points)
Definition: volk_16u_byteswap.h:48
static void volk_16u_byteswap_neon_table(uint16_t *intsToSwap, unsigned int num_points)
Definition: volk_16u_byteswap.h:232