Vector Optimized Library of Kernels  2.0
Architecture-tuned implementations of math kernels
volk_avx2_intrinsics.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2015 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 /*
24  * This file is intended to hold AVX2 intrinsics of intrinsics.
25  * They should be used in VOLK kernels to avoid copy-paste.
26  */
27 
28 #ifndef INCLUDE_VOLK_VOLK_AVX2_INTRINSICS_H_
29 #define INCLUDE_VOLK_VOLK_AVX2_INTRINSICS_H_
30 #include <immintrin.h>
32 
33 static inline __m256
35  const __m128i zeros = _mm_set1_epi8(0x00);
36  const __m128i sign_extract = _mm_set1_epi8(0x80);
37  const __m256i shuffle_mask = _mm256_setr_epi8(0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x03,
38  0xff, 0xff, 0xff, 0x04, 0xff, 0xff, 0xff, 0x05, 0xff, 0xff, 0xff, 0x06, 0xff, 0xff, 0xff, 0x07);
39  __m256i sign_bits = _mm256_setzero_si256();
40 
41  fbits = _mm_cmpgt_epi8(fbits, zeros);
42  fbits = _mm_and_si128(fbits, sign_extract);
43  sign_bits = _mm256_insertf128_si256(sign_bits,fbits,0);
44  sign_bits = _mm256_insertf128_si256(sign_bits,fbits,1);
45  sign_bits = _mm256_shuffle_epi8(sign_bits, shuffle_mask);
46 
47  return _mm256_castsi256_ps(sign_bits);
48 }
49 
50 static inline __m256
51 _mm256_polar_fsign_add_llrs_avx2(__m256 src0, __m256 src1, __m128i fbits){
52  // prepare sign mask for correct +-
53  __m256 sign_mask = _mm256_polar_sign_mask_avx2(fbits);
54 
55  __m256 llr0, llr1;
56  _mm256_polar_deinterleave(&llr0, &llr1, src0, src1);
57 
58  // calculate result
59  llr0 = _mm256_xor_ps(llr0, sign_mask);
60  __m256 dst = _mm256_add_ps(llr0, llr1);
61  return dst;
62 }
63 #endif /* INCLUDE_VOLK_VOLK_AVX2_INTRINSICS_H_ */
static __m256 _mm256_polar_sign_mask_avx2(__m128i fbits)
Definition: volk_avx2_intrinsics.h:34
static void _mm256_polar_deinterleave(__m256 *llr0, __m256 *llr1, __m256 src0, __m256 src1)
Definition: volk_avx_intrinsics.h:92
static __m256 _mm256_polar_fsign_add_llrs_avx2(__m256 src0, __m256 src1, __m128i fbits)
Definition: volk_avx2_intrinsics.h:51