Vector Optimized Library of Kernels  2.2
Architecture-tuned implementations of math kernels
volk_32f_8u_polarbutterflypuppet_32f.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 puppet is for VOLK tests only.
25  * For documentation see 'kernels/volk/volk_32f_8u_polarbutterfly_32f.h'
26  */
27 
28 #ifndef VOLK_KERNELS_VOLK_VOLK_32F_8U_POLARBUTTERFLYPUPPET_32F_H_
29 #define VOLK_KERNELS_VOLK_VOLK_32F_8U_POLARBUTTERFLYPUPPET_32F_H_
30 
35 
36 
37 static inline void
38 sanitize_bytes(unsigned char* u, const int elements)
39 {
40  int i;
41  unsigned char* u_ptr = u;
42  for(i = 0; i < elements; i++){
43  *u_ptr = (*u_ptr & 0x01);
44  u_ptr++;
45  }
46 }
47 
48 static inline void
49 clean_up_intermediate_values(float* llrs, unsigned char* u, const int frame_size, const int elements)
50 {
51  memset(u + frame_size, 0, sizeof(unsigned char) * (elements - frame_size));
52  memset(llrs + frame_size, 0, sizeof(float) * (elements - frame_size));
53 }
54 
55 static inline void
56 generate_error_free_input_vector(float* llrs, unsigned char* u, const int frame_size)
57 {
58  memset(u, 0, frame_size);
59  unsigned char* target = u + frame_size;
60  volk_8u_x2_encodeframepolar_8u_generic(target, u + 2 * frame_size, frame_size);
61  float* ft = llrs;
62  int i;
63  for(i = 0; i < frame_size; i++){
64  *ft = (-2 * ((float) *target++)) + 1.0f;
65  ft++;
66  }
67 }
68 
69 static inline void
70 print_llr_tree(const float* llrs, const int frame_size, const int frame_exp)
71 {
72  int s, e;
73  for(s = 0; s < frame_size; s++){
74  for(e = 0; e < frame_exp + 1; e++){
75  printf("%+4.2f ", llrs[e * frame_size + s]);
76  }
77  printf("\n");
78  if((s + 1) % 8 == 0){
79  printf("\n");
80  }
81  }
82 }
83 
84 static inline int
85 maximum_frame_size(const int elements)
86 {
87  unsigned int frame_size = next_lower_power_of_two(elements);
88  unsigned int frame_exp = log2_of_power_of_2(frame_size);
89  return next_lower_power_of_two(frame_size / frame_exp);
90 }
91 
92 #ifdef LV_HAVE_GENERIC
93 static inline void
94 volk_32f_8u_polarbutterflypuppet_32f_generic(float* llrs, const float* input, unsigned char* u, const int elements)
95 {
96  unsigned int frame_size = maximum_frame_size(elements);
97  unsigned int frame_exp = log2_of_power_of_2(frame_size);
98 
99  sanitize_bytes(u, elements);
100  clean_up_intermediate_values(llrs, u, frame_size, elements);
101  generate_error_free_input_vector(llrs + frame_exp * frame_size, u, frame_size);
102 
103  unsigned int u_num = 0;
104  for(; u_num < frame_size; u_num++){
105  volk_32f_8u_polarbutterfly_32f_generic(llrs, u, frame_exp, 0, u_num, u_num);
106  u[u_num] = llrs[u_num] > 0 ? 0 : 1;
107  }
108 
109  clean_up_intermediate_values(llrs, u, frame_size, elements);
110 }
111 #endif /* LV_HAVE_GENERIC */
112 
113 #ifdef LV_HAVE_AVX
114 static inline void
115 volk_32f_8u_polarbutterflypuppet_32f_u_avx(float* llrs, const float* input, unsigned char* u, const int elements)
116 {
117  unsigned int frame_size = maximum_frame_size(elements);
118  unsigned int frame_exp = log2_of_power_of_2(frame_size);
119 
120  sanitize_bytes(u, elements);
121  clean_up_intermediate_values(llrs, u, frame_size, elements);
122  generate_error_free_input_vector(llrs + frame_exp * frame_size, u, frame_size);
123 
124  unsigned int u_num = 0;
125  for(; u_num < frame_size; u_num++){
126  volk_32f_8u_polarbutterfly_32f_u_avx(llrs, u, frame_exp, 0, u_num, u_num);
127  u[u_num] = llrs[u_num] > 0 ? 0 : 1;
128  }
129 
130  clean_up_intermediate_values(llrs, u, frame_size, elements);
131 }
132 #endif /* LV_HAVE_AVX */
133 
134 #ifdef LV_HAVE_AVX2
135 static inline void
136 volk_32f_8u_polarbutterflypuppet_32f_u_avx2(float* llrs, const float* input, unsigned char* u, const int elements)
137 {
138  unsigned int frame_size = maximum_frame_size(elements);
139  unsigned int frame_exp = log2_of_power_of_2(frame_size);
140 
141  sanitize_bytes(u, elements);
142  clean_up_intermediate_values(llrs, u, frame_size, elements);
143  generate_error_free_input_vector(llrs + frame_exp * frame_size, u, frame_size);
144 
145  unsigned int u_num = 0;
146  for(; u_num < frame_size; u_num++){
147  volk_32f_8u_polarbutterfly_32f_u_avx2(llrs, u, frame_exp, 0, u_num, u_num);
148  u[u_num] = llrs[u_num] > 0 ? 0 : 1;
149  }
150 
151  clean_up_intermediate_values(llrs, u, frame_size, elements);
152 }
153 #endif /* LV_HAVE_AVX2 */
154 
155 
156 
157 #endif /* VOLK_KERNELS_VOLK_VOLK_32F_8U_POLARBUTTERFLYPUPPET_32F_H_ */
volk_8u_x3_encodepolar_8u_x2.h
maximum_frame_size
static int maximum_frame_size(const int elements)
Definition: volk_32f_8u_polarbutterflypuppet_32f.h:85
print_llr_tree
static void print_llr_tree(const float *llrs, const int frame_size, const int frame_exp)
Definition: volk_32f_8u_polarbutterflypuppet_32f.h:70
volk_8u_x3_encodepolarpuppet_8u.h
volk_8u_x2_encodeframepolar_8u.h
next_lower_power_of_two
static unsigned int next_lower_power_of_two(const unsigned int val)
Definition: volk_8u_x3_encodepolarpuppet_8u.h:33
i
for i
Definition: volk_config_fixed.tmpl.h:25
volk_32f_8u_polarbutterflypuppet_32f_u_avx
static void volk_32f_8u_polarbutterflypuppet_32f_u_avx(float *llrs, const float *input, unsigned char *u, const int elements)
Definition: volk_32f_8u_polarbutterflypuppet_32f.h:115
volk_32f_8u_polarbutterfly_32f_u_avx
static void volk_32f_8u_polarbutterfly_32f_u_avx(float *llrs, unsigned char *u, const int frame_exp, const int stage, const int u_num, const int row)
Definition: volk_32f_8u_polarbutterfly_32f.h:210
volk_32f_8u_polarbutterflypuppet_32f_generic
static void volk_32f_8u_polarbutterflypuppet_32f_generic(float *llrs, const float *input, unsigned char *u, const int elements)
Definition: volk_32f_8u_polarbutterflypuppet_32f.h:94
volk_8u_x2_encodeframepolar_8u_generic
static void volk_8u_x2_encodeframepolar_8u_generic(unsigned char *frame, unsigned char *temp, unsigned int frame_size)
Definition: volk_8u_x2_encodeframepolar_8u.h:62
volk_32f_8u_polarbutterfly_32f_generic
static void volk_32f_8u_polarbutterfly_32f_generic(float *llrs, unsigned char *u, const int frame_exp, const int stage, const int u_num, const int row)
Definition: volk_32f_8u_polarbutterfly_32f.h:158
volk_32f_8u_polarbutterfly_32f.h
clean_up_intermediate_values
static void clean_up_intermediate_values(float *llrs, unsigned char *u, const int frame_size, const int elements)
Definition: volk_32f_8u_polarbutterflypuppet_32f.h:49
generate_error_free_input_vector
static void generate_error_free_input_vector(float *llrs, unsigned char *u, const int frame_size)
Definition: volk_32f_8u_polarbutterflypuppet_32f.h:56
sanitize_bytes
static void sanitize_bytes(unsigned char *u, const int elements)
Definition: volk_32f_8u_polarbutterflypuppet_32f.h:38
log2_of_power_of_2
static unsigned int log2_of_power_of_2(unsigned int val)
Definition: volk_8u_x2_encodeframepolar_8u.h:32