Vector Optimized Library of Kernels  3.2.0
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 VOLK
6  *
7  * SPDX-License-Identifier: LGPL-3.0-or-later
8  */
9 
10 /*
11  * This puppet is for VOLK tests only.
12  * For documentation see 'kernels/volk/volk_32f_8u_polarbutterfly_32f.h'
13  */
14 
15 #ifndef VOLK_KERNELS_VOLK_VOLK_32F_8U_POLARBUTTERFLYPUPPET_32F_H_
16 #define VOLK_KERNELS_VOLK_VOLK_32F_8U_POLARBUTTERFLYPUPPET_32F_H_
17 
21 
22 
23 static inline void sanitize_bytes(unsigned char* u, const int elements)
24 {
25  int i;
26  unsigned char* u_ptr = u;
27  for (i = 0; i < elements; i++) {
28  *u_ptr = (*u_ptr & 0x01);
29  u_ptr++;
30  }
31 }
32 
33 static inline void clean_up_intermediate_values(float* llrs,
34  unsigned char* u,
35  const int frame_size,
36  const int elements)
37 {
38  memset(u + frame_size, 0, sizeof(unsigned char) * (elements - frame_size));
39  memset(llrs + frame_size, 0, sizeof(float) * (elements - frame_size));
40 }
41 
42 static inline void
43 generate_error_free_input_vector(float* llrs, unsigned char* u, const int frame_size)
44 {
45  memset(u, 0, frame_size);
46  unsigned char* target = u + frame_size;
47  volk_8u_x2_encodeframepolar_8u_generic(target, u + 2 * frame_size, frame_size);
48  float* ft = llrs;
49  int i;
50  for (i = 0; i < frame_size; i++) {
51  *ft = (-2 * ((float)*target++)) + 1.0f;
52  ft++;
53  }
54 }
55 
56 static inline void
57 print_llr_tree(const float* llrs, const int frame_size, const int frame_exp)
58 {
59  int s, e;
60  for (s = 0; s < frame_size; s++) {
61  for (e = 0; e < frame_exp + 1; e++) {
62  printf("%+4.2f ", llrs[e * frame_size + s]);
63  }
64  printf("\n");
65  if ((s + 1) % 8 == 0) {
66  printf("\n");
67  }
68  }
69 }
70 
71 static inline int maximum_frame_size(const int elements)
72 {
73  unsigned int frame_size = next_lower_power_of_two(elements);
74  unsigned int frame_exp = log2_of_power_of_2(frame_size);
75  return next_lower_power_of_two(frame_size / frame_exp);
76 }
77 
78 #ifdef LV_HAVE_GENERIC
79 static inline void volk_32f_8u_polarbutterflypuppet_32f_generic(float* llrs,
80  const float* input,
81  unsigned char* u,
82  const int elements)
83 {
84  (void)input; // suppress unused parameter warning
85 
86  if (elements < 2) {
87  return;
88  }
89 
90  unsigned int frame_size = maximum_frame_size(elements);
91  unsigned int frame_exp = log2_of_power_of_2(frame_size);
92 
93  sanitize_bytes(u, elements);
94  clean_up_intermediate_values(llrs, u, frame_size, elements);
95  generate_error_free_input_vector(llrs + frame_exp * frame_size, u, frame_size);
96 
97  unsigned int u_num = 0;
98  for (; u_num < frame_size; u_num++) {
99  volk_32f_8u_polarbutterfly_32f_generic(llrs, u, frame_exp, 0, u_num, u_num);
100  u[u_num] = llrs[u_num] > 0 ? 0 : 1;
101  }
102 
103  clean_up_intermediate_values(llrs, u, frame_size, elements);
104 }
105 #endif /* LV_HAVE_GENERIC */
106 
107 #ifdef LV_HAVE_AVX
108 static inline void volk_32f_8u_polarbutterflypuppet_32f_u_avx(float* llrs,
109  const float* input,
110  unsigned char* u,
111  const int elements)
112 {
113  (void)input; // suppress unused parameter warning
114 
115  if (elements < 2) {
116  return;
117  }
118 
119  unsigned int frame_size = maximum_frame_size(elements);
120  unsigned int frame_exp = log2_of_power_of_2(frame_size);
121 
122  sanitize_bytes(u, elements);
123  clean_up_intermediate_values(llrs, u, frame_size, elements);
124  generate_error_free_input_vector(llrs + frame_exp * frame_size, u, frame_size);
125 
126  unsigned int u_num = 0;
127  for (; u_num < frame_size; u_num++) {
128  volk_32f_8u_polarbutterfly_32f_u_avx(llrs, u, frame_exp, 0, u_num, u_num);
129  u[u_num] = llrs[u_num] > 0 ? 0 : 1;
130  }
131 
132  clean_up_intermediate_values(llrs, u, frame_size, elements);
133 }
134 #endif /* LV_HAVE_AVX */
135 
136 #ifdef LV_HAVE_AVX2
137 static inline void volk_32f_8u_polarbutterflypuppet_32f_u_avx2(float* llrs,
138  const float* input,
139  unsigned char* u,
140  const int elements)
141 {
142  (void)input; // suppress unused parameter warning
143 
144  if (elements < 2) {
145  return;
146  }
147 
148  unsigned int frame_size = maximum_frame_size(elements);
149  unsigned int frame_exp = log2_of_power_of_2(frame_size);
150 
151  sanitize_bytes(u, elements);
152  clean_up_intermediate_values(llrs, u, frame_size, elements);
153  generate_error_free_input_vector(llrs + frame_exp * frame_size, u, frame_size);
154 
155  unsigned int u_num = 0;
156  for (; u_num < frame_size; u_num++) {
157  volk_32f_8u_polarbutterfly_32f_u_avx2(llrs, u, frame_exp, 0, u_num, u_num);
158  u[u_num] = llrs[u_num] > 0 ? 0 : 1;
159  }
160 
161  clean_up_intermediate_values(llrs, u, frame_size, elements);
162 }
163 #endif /* LV_HAVE_AVX2 */
164 
165 #ifdef LV_HAVE_RVV
166 static inline void volk_32f_8u_polarbutterflypuppet_32f_rvv(float* llrs,
167  const float* input,
168  unsigned char* u,
169  const int elements)
170 {
171  (void)input; // suppress unused parameter warning
172 
173  if (elements < 2) {
174  return;
175  }
176 
177  unsigned int frame_size = maximum_frame_size(elements);
178  unsigned int frame_exp = log2_of_power_of_2(frame_size);
179 
180  sanitize_bytes(u, elements);
181  clean_up_intermediate_values(llrs, u, frame_size, elements);
182  generate_error_free_input_vector(llrs + frame_exp * frame_size, u, frame_size);
183 
184  unsigned int u_num = 0;
185  for (; u_num < frame_size; u_num++) {
186  volk_32f_8u_polarbutterfly_32f_rvv(llrs, u, frame_exp, 0, u_num, u_num);
187  u[u_num] = llrs[u_num] > 0 ? 0 : 1;
188  }
189 
190  clean_up_intermediate_values(llrs, u, frame_size, elements);
191 }
192 #endif /* LV_HAVE_RVV */
193 
194 #ifdef LV_HAVE_RVVSEG
195 static inline void volk_32f_8u_polarbutterflypuppet_32f_rvvseg(float* llrs,
196  const float* input,
197  unsigned char* u,
198  const int elements)
199 {
200  (void)input; // suppress unused parameter warning
201 
202  if (elements < 2) {
203  return;
204  }
205 
206  unsigned int frame_size = maximum_frame_size(elements);
207  unsigned int frame_exp = log2_of_power_of_2(frame_size);
208 
209  sanitize_bytes(u, elements);
210  clean_up_intermediate_values(llrs, u, frame_size, elements);
211  generate_error_free_input_vector(llrs + frame_exp * frame_size, u, frame_size);
212 
213  unsigned int u_num = 0;
214  for (; u_num < frame_size; u_num++) {
215  volk_32f_8u_polarbutterfly_32f_rvvseg(llrs, u, frame_exp, 0, u_num, u_num);
216  u[u_num] = llrs[u_num] > 0 ? 0 : 1;
217  }
218 
219  clean_up_intermediate_values(llrs, u, frame_size, elements);
220 }
221 #endif /* LV_HAVE_RVVSEG */
222 
223 #endif /* VOLK_KERNELS_VOLK_VOLK_32F_8U_POLARBUTTERFLYPUPPET_32F_H_ */
VOLK_API void
Call into a specific implementation given by name.
Definition: volk.tmpl.h:103
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:144
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:200
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:33
static void print_llr_tree(const float *llrs, const int frame_size, const int frame_exp)
Definition: volk_32f_8u_polarbutterflypuppet_32f.h:57
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:79
static int maximum_frame_size(const int elements)
Definition: volk_32f_8u_polarbutterflypuppet_32f.h:71
static void generate_error_free_input_vector(float *llrs, unsigned char *u, const int frame_size)
Definition: volk_32f_8u_polarbutterflypuppet_32f.h:43
static void sanitize_bytes(unsigned char *u, const int elements)
Definition: volk_32f_8u_polarbutterflypuppet_32f.h:23
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:108
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:52
static unsigned int log2_of_power_of_2(unsigned int val)
Definition: volk_8u_x2_encodeframepolar_8u.h:18
static unsigned int next_lower_power_of_two(const unsigned int val)
Definition: volk_8u_x3_encodepolarpuppet_8u.h:19
for i
Definition: volk_config_fixed.tmpl.h:13