Vector Optimized Library of Kernels 3.0.0
Architecture-tuned implementations of math kernels
 
Loading...
Searching...
No Matches
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
23static 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
33static 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
42static inline void
43generate_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
56static inline void
57print_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
71static 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
79static inline void volk_32f_8u_polarbutterflypuppet_32f_generic(float* llrs,
80 const float* input,
81 unsigned char* u,
82 const int elements)
83{
84 unsigned int frame_size = maximum_frame_size(elements);
85 unsigned int frame_exp = log2_of_power_of_2(frame_size);
86
87 sanitize_bytes(u, elements);
88 clean_up_intermediate_values(llrs, u, frame_size, elements);
89 generate_error_free_input_vector(llrs + frame_exp * frame_size, u, frame_size);
90
91 unsigned int u_num = 0;
92 for (; u_num < frame_size; u_num++) {
93 volk_32f_8u_polarbutterfly_32f_generic(llrs, u, frame_exp, 0, u_num, u_num);
94 u[u_num] = llrs[u_num] > 0 ? 0 : 1;
95 }
96
97 clean_up_intermediate_values(llrs, u, frame_size, elements);
98}
99#endif /* LV_HAVE_GENERIC */
100
101#ifdef LV_HAVE_AVX
102static inline void volk_32f_8u_polarbutterflypuppet_32f_u_avx(float* llrs,
103 const float* input,
104 unsigned char* u,
105 const int elements)
106{
107 unsigned int frame_size = maximum_frame_size(elements);
108 unsigned int frame_exp = log2_of_power_of_2(frame_size);
109
110 sanitize_bytes(u, elements);
111 clean_up_intermediate_values(llrs, u, frame_size, elements);
112 generate_error_free_input_vector(llrs + frame_exp * frame_size, u, frame_size);
113
114 unsigned int u_num = 0;
115 for (; u_num < frame_size; u_num++) {
116 volk_32f_8u_polarbutterfly_32f_u_avx(llrs, u, frame_exp, 0, u_num, u_num);
117 u[u_num] = llrs[u_num] > 0 ? 0 : 1;
118 }
119
120 clean_up_intermediate_values(llrs, u, frame_size, elements);
121}
122#endif /* LV_HAVE_AVX */
123
124#ifdef LV_HAVE_AVX2
125static inline void volk_32f_8u_polarbutterflypuppet_32f_u_avx2(float* llrs,
126 const float* input,
127 unsigned char* u,
128 const int elements)
129{
130 unsigned int frame_size = maximum_frame_size(elements);
131 unsigned int frame_exp = log2_of_power_of_2(frame_size);
132
133 sanitize_bytes(u, elements);
134 clean_up_intermediate_values(llrs, u, frame_size, elements);
135 generate_error_free_input_vector(llrs + frame_exp * frame_size, u, frame_size);
136
137 unsigned int u_num = 0;
138 for (; u_num < frame_size; u_num++) {
139 volk_32f_8u_polarbutterfly_32f_u_avx2(llrs, u, frame_exp, 0, u_num, u_num);
140 u[u_num] = llrs[u_num] > 0 ? 0 : 1;
141 }
142
143 clean_up_intermediate_values(llrs, u, frame_size, elements);
144}
145#endif /* LV_HAVE_AVX2 */
146
147
148#endif /* VOLK_KERNELS_VOLK_VOLK_32F_8U_POLARBUTTERFLYPUPPET_32F_H_ */
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:102
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