Vector Optimized Library of Kernels  2.0
Architecture-tuned implementations of math kernels
volk_8u_x3_encodepolarpuppet_8u.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 /* For documentation see 'kernels/volk/volk_8u_x3_encodepolar_8u_x2.h'
24  * This file exists for test purposes only. Should not be used directly.
25  */
26 
27 #ifndef VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_H_
28 #define VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_H_
29 #include <volk/volk.h>
31 
32 static inline unsigned int
33 next_lower_power_of_two(const unsigned int val)
34 {
35  // algorithm found and adopted from: http://acius2.blogspot.de/2007/11/calculating-next-power-of-2.html
36  unsigned int res = val;
37  res = (res >> 1) | res;
38  res = (res >> 2) | res;
39  res = (res >> 4) | res;
40  res = (res >> 8) | res;
41  res = (res >> 16) | res;
42  res += 1;
43  return res >> 1;
44 }
45 
46 static inline void
47 adjust_frozen_mask(unsigned char* mask, const unsigned int frame_size)
48 {
49  // just like the rest of the puppet this function exists for test purposes only.
50  unsigned int i;
51  for(i = 0; i < frame_size; ++i){
52  *mask = (*mask & 0x80) ? 0xFF : 0x00;
53  mask++;
54  }
55 }
56 
57 #ifdef LV_HAVE_GENERIC
58 static inline void
59 volk_8u_x3_encodepolarpuppet_8u_generic(unsigned char* frame, unsigned char* frozen_bit_mask,
60  const unsigned char* frozen_bits, const unsigned char* info_bits,
61  unsigned int frame_size)
62 {
63  frame_size = next_lower_power_of_two(frame_size);
64  unsigned char* temp = (unsigned char*) volk_malloc(sizeof(unsigned char) * frame_size, volk_get_alignment());
65  adjust_frozen_mask(frozen_bit_mask, frame_size);
66  volk_8u_x3_encodepolar_8u_x2_generic(frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
67  volk_free(temp);
68 }
69 #endif /* LV_HAVE_GENERIC */
70 
71 
72 #ifdef LV_HAVE_SSSE3
73 static inline void
74 volk_8u_x3_encodepolarpuppet_8u_u_ssse3(unsigned char* frame, unsigned char* frozen_bit_mask,
75  const unsigned char* frozen_bits, const unsigned char* info_bits,
76  unsigned int frame_size)
77 {
78  frame_size = next_lower_power_of_two(frame_size);
79  unsigned char* temp = (unsigned char*) volk_malloc(sizeof(unsigned char) * frame_size, volk_get_alignment());
80  adjust_frozen_mask(frozen_bit_mask, frame_size);
81  volk_8u_x3_encodepolar_8u_x2_u_ssse3(frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
82  volk_free(temp);
83 }
84 #endif /* LV_HAVE_SSSE3 */
85 
86 #ifdef LV_HAVE_AVX2
87 static inline void
88 volk_8u_x3_encodepolarpuppet_8u_u_avx2(unsigned char* frame, unsigned char* frozen_bit_mask,
89  const unsigned char* frozen_bits, const unsigned char* info_bits,
90  unsigned int frame_size)
91 {
92  frame_size = next_lower_power_of_two(frame_size);
93  unsigned char* temp = (unsigned char*) volk_malloc(sizeof(unsigned char) * frame_size, volk_get_alignment());
94  adjust_frozen_mask(frozen_bit_mask, frame_size);
95  volk_8u_x3_encodepolar_8u_x2_u_avx2(frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
96  volk_free(temp);
97 }
98 #endif /* LV_HAVE_AVX2 */
99 
100 #endif /* VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_H_ */
101 
102 #ifndef VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_A_H_
103 #define VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_A_H_
104 
105 #ifdef LV_HAVE_SSSE3
106 static inline void
107 volk_8u_x3_encodepolarpuppet_8u_a_ssse3(unsigned char* frame, unsigned char* frozen_bit_mask,
108  const unsigned char* frozen_bits, const unsigned char* info_bits,
109  unsigned int frame_size)
110 {
111  frame_size = next_lower_power_of_two(frame_size);
112  unsigned char* temp = (unsigned char*) volk_malloc(sizeof(unsigned char) * frame_size, volk_get_alignment());
113  adjust_frozen_mask(frozen_bit_mask, frame_size);
114  volk_8u_x3_encodepolar_8u_x2_a_ssse3(frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
115  volk_free(temp);
116 }
117 #endif /* LV_HAVE_SSSE3 */
118 
119 #ifdef LV_HAVE_AVX2
120 static inline void
121 volk_8u_x3_encodepolarpuppet_8u_a_avx2(unsigned char* frame, unsigned char* frozen_bit_mask,
122  const unsigned char* frozen_bits, const unsigned char* info_bits,
123  unsigned int frame_size)
124 {
125  frame_size = next_lower_power_of_two(frame_size);
126  unsigned char* temp = (unsigned char*) volk_malloc(sizeof(unsigned char) * frame_size, volk_get_alignment());
127  adjust_frozen_mask(frozen_bit_mask, frame_size);
128  volk_8u_x3_encodepolar_8u_x2_a_avx2(frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
129  volk_free(temp);
130 }
131 #endif /* LV_HAVE_AVX2 */
132 
133 
134 #endif /* VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_A_H_ */
val
Definition: volk_arch_defs.py:69
static void volk_8u_x3_encodepolarpuppet_8u_generic(unsigned char *frame, unsigned char *frozen_bit_mask, const unsigned char *frozen_bits, const unsigned char *info_bits, unsigned int frame_size)
Definition: volk_8u_x3_encodepolarpuppet_8u.h:59
size_t volk_get_alignment(void)
Get the machine alignment in bytes.
Definition: volk.tmpl.c:102
static void volk_8u_x3_encodepolar_8u_x2_a_ssse3(unsigned char *frame, unsigned char *temp, const unsigned char *frozen_bit_mask, const unsigned char *frozen_bits, const unsigned char *info_bits, unsigned int frame_size)
Definition: volk_8u_x3_encodepolar_8u_x2.h:142
static void volk_8u_x3_encodepolar_8u_x2_generic(unsigned char *frame, unsigned char *temp, const unsigned char *frozen_bit_mask, const unsigned char *frozen_bits, const unsigned char *info_bits, unsigned int frame_size)
Definition: volk_8u_x3_encodepolar_8u_x2.h:94
static void volk_8u_x3_encodepolarpuppet_8u_a_ssse3(unsigned char *frame, unsigned char *frozen_bit_mask, const unsigned char *frozen_bits, const unsigned char *info_bits, unsigned int frame_size)
Definition: volk_8u_x3_encodepolarpuppet_8u.h:107
static void volk_8u_x3_encodepolar_8u_x2_u_ssse3(unsigned char *frame, unsigned char *temp, const unsigned char *frozen_bit_mask, const unsigned char *frozen_bits, const unsigned char *info_bits, unsigned int frame_size)
Definition: volk_8u_x3_encodepolar_8u_x2.h:109
for i
Definition: volk_config_fixed.tmpl.h:25
__VOLK_DECL_BEGIN VOLK_API void * volk_malloc(size_t size, size_t alignment)
Allocate size bytes of data aligned to alignment.
Definition: volk_malloc.c:93
static void volk_8u_x3_encodepolarpuppet_8u_u_ssse3(unsigned char *frame, unsigned char *frozen_bit_mask, const unsigned char *frozen_bits, const unsigned char *info_bits, unsigned int frame_size)
Definition: volk_8u_x3_encodepolarpuppet_8u.h:74
VOLK_API void volk_free(void *aptr)
Free&#39;s memory allocated by volk_malloc.
Definition: volk_malloc.c:117
static void adjust_frozen_mask(unsigned char *mask, const unsigned int frame_size)
Definition: volk_8u_x3_encodepolarpuppet_8u.h:47
static unsigned int next_lower_power_of_two(const unsigned int val)
Definition: volk_8u_x3_encodepolarpuppet_8u.h:33