Vector Optimized Library of Kernels 3.1.0
Architecture-tuned implementations of math kernels
kernel_tests.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2014 - 2021 Free Software Foundation, Inc.
4 * Copyright 2023 Magnus Lundmark <magnuslundmark@gmail.com>
5 *
6 * This file is part of VOLK
7 *
8 * SPDX-License-Identifier: LGPL-3.0-or-later
9 */
10
11#include "qa_utils.h"
12
13#include <volk/volk.h>
14#include <vector>
15
16// macros for initializing volk_test_case_t. Maccros are needed to generate
17// function names of the pattern kernel_name_*
18
19// for puppets we need to get all the func_variants for the puppet and just
20// keep track of the actual function name to write to results
21#define VOLK_INIT_PUPP(func, puppet_master_func, test_params) \
22 volk_test_case_t(func##_get_func_desc(), \
23 (void (*)())func##_manual, \
24 std::string(#func), \
25 std::string(#puppet_master_func), \
26 test_params)
27
28#define VOLK_INIT_TEST(func, test_params) \
29 volk_test_case_t(func##_get_func_desc(), \
30 (void (*)())func##_manual, \
31 std::string(#func), \
32 test_params)
33
34#define QA(test) test_cases.push_back(test);
35std::vector<volk_test_case_t> init_test_list(volk_test_params_t test_params)
36{
37
38 // Some kernels need a lower tolerance
39 volk_test_params_t test_params_inacc = test_params.make_tol(1e-2);
40 volk_test_params_t test_params_inacc_tenth = test_params.make_tol(1e-1);
41
42 volk_test_params_t test_params_power(test_params);
43 test_params_power.set_scalar(2.5);
44
45 volk_test_params_t test_params_clamp(test_params);
46 test_params_clamp.set_scalar(-.5f);
47
48 volk_test_params_t test_params_rotator(test_params);
49 test_params_rotator.set_scalar(std::polar(1.0f, 0.1f));
50 test_params_rotator.set_tol(1e-3);
51
52 volk_test_params_t test_params_snf(test_params);
53 test_params_snf.set_scalar(0.5);
54 test_params_snf.set_tol(1e-4);
55
56 std::vector<volk_test_case_t> test_cases;
57 QA(VOLK_INIT_PUPP(volk_64u_popcntpuppet_64u, volk_64u_popcnt, test_params))
58 QA(VOLK_INIT_PUPP(volk_16u_byteswappuppet_16u, volk_16u_byteswap, test_params))
59 QA(VOLK_INIT_PUPP(volk_32u_byteswappuppet_32u, volk_32u_byteswap, test_params))
60 QA(VOLK_INIT_PUPP(volk_32u_popcntpuppet_32u, volk_32u_popcnt, test_params))
61 QA(VOLK_INIT_PUPP(volk_64u_byteswappuppet_64u, volk_64u_byteswap, test_params))
62 QA(VOLK_INIT_PUPP(volk_32fc_s32fc_rotator2puppet_32fc,
63 volk_32fc_s32fc_x2_rotator2_32fc,
64 test_params_rotator))
66 volk_8u_conv_k7_r2puppet_8u, volk_8u_x4_conv_k7_r2_8u, test_params.make_tol(0)))
67 QA(VOLK_INIT_PUPP(volk_32f_x2_fm_detectpuppet_32f,
68 volk_32f_s32f_32f_fm_detect_32f,
69 test_params.make_absolute(1e-6)))
70 QA(VOLK_INIT_TEST(volk_16ic_s32f_deinterleave_real_32f, test_params))
71 QA(VOLK_INIT_TEST(volk_16ic_deinterleave_real_8i, test_params))
72 QA(VOLK_INIT_TEST(volk_16ic_deinterleave_16i_x2, test_params))
73 QA(VOLK_INIT_TEST(volk_16ic_s32f_deinterleave_32f_x2, test_params))
74 QA(VOLK_INIT_TEST(volk_16ic_deinterleave_real_16i, test_params))
75 QA(VOLK_INIT_TEST(volk_16ic_magnitude_16i, test_params))
76 QA(VOLK_INIT_TEST(volk_16ic_s32f_magnitude_32f, test_params))
77 QA(VOLK_INIT_TEST(volk_16ic_convert_32fc, test_params))
78 QA(VOLK_INIT_TEST(volk_16ic_x2_multiply_16ic, test_params))
79 QA(VOLK_INIT_TEST(volk_16ic_x2_dot_prod_16ic, test_params))
80 QA(VOLK_INIT_TEST(volk_16i_s32f_convert_32f, test_params))
81 QA(VOLK_INIT_TEST(volk_16i_convert_8i, test_params))
82 QA(VOLK_INIT_TEST(volk_16i_32fc_dot_prod_32fc, test_params.make_absolute(1e-1)))
83 QA(VOLK_INIT_TEST(volk_32f_accumulator_s32f, test_params.make_absolute(2e-2)))
84 QA(VOLK_INIT_TEST(volk_32f_x2_add_32f, test_params))
85 QA(VOLK_INIT_TEST(volk_32f_index_max_16u, test_params))
86 QA(VOLK_INIT_TEST(volk_32f_index_max_32u, test_params))
87 QA(VOLK_INIT_TEST(volk_32f_index_min_16u, test_params))
88 QA(VOLK_INIT_TEST(volk_32f_index_min_32u, test_params))
89 QA(VOLK_INIT_TEST(volk_32fc_32f_multiply_32fc, test_params))
90 QA(VOLK_INIT_TEST(volk_32fc_32f_add_32fc, test_params))
91 QA(VOLK_INIT_TEST(volk_32f_log2_32f, test_params.make_absolute(1.5e-5)))
92 QA(VOLK_INIT_TEST(volk_32f_expfast_32f, test_params_inacc_tenth))
93 QA(VOLK_INIT_TEST(volk_32f_sin_32f, test_params_inacc))
94 QA(VOLK_INIT_TEST(volk_32f_cos_32f, test_params_inacc))
95 QA(VOLK_INIT_TEST(volk_32f_tan_32f, test_params_inacc))
96 QA(VOLK_INIT_TEST(volk_32f_atan_32f, test_params))
97 QA(VOLK_INIT_TEST(volk_32f_asin_32f, test_params_inacc))
98 QA(VOLK_INIT_TEST(volk_32f_acos_32f, test_params_inacc))
99 QA(VOLK_INIT_TEST(volk_32fc_s32f_power_32fc, test_params_power))
100 QA(VOLK_INIT_TEST(volk_32f_s32f_calc_spectral_noise_floor_32f, test_params_snf))
101 QA(VOLK_INIT_TEST(volk_32fc_s32f_atan2_32f, test_params))
102 QA(VOLK_INIT_TEST(volk_32fc_x2_conjugate_dot_prod_32fc,
103 test_params.make_absolute(2e-2)))
104 QA(VOLK_INIT_TEST(volk_32fc_deinterleave_32f_x2, test_params))
105 QA(VOLK_INIT_TEST(volk_32fc_accumulator_s32fc, test_params.make_absolute(3e-2)))
106 QA(VOLK_INIT_TEST(volk_32fc_deinterleave_64f_x2, test_params))
107 QA(VOLK_INIT_TEST(volk_32fc_s32f_deinterleave_real_16i, test_params.make_tol(1)))
108 QA(VOLK_INIT_TEST(volk_32fc_deinterleave_imag_32f, test_params))
109 QA(VOLK_INIT_TEST(volk_32fc_deinterleave_real_32f, test_params))
110 QA(VOLK_INIT_TEST(volk_32fc_deinterleave_real_64f, test_params))
111 QA(VOLK_INIT_TEST(volk_32fc_x2_dot_prod_32fc, test_params.make_absolute(2e-2)))
112 QA(VOLK_INIT_TEST(volk_32fc_32f_dot_prod_32fc, test_params.make_absolute(1e-2)))
113 QA(VOLK_INIT_TEST(volk_32fc_index_max_16u, test_params))
114 QA(VOLK_INIT_TEST(volk_32fc_index_max_32u, test_params))
115 QA(VOLK_INIT_TEST(volk_32fc_index_min_16u, test_params))
116 QA(VOLK_INIT_TEST(volk_32fc_index_min_32u, test_params))
117 QA(VOLK_INIT_TEST(volk_32fc_s32f_magnitude_16i, test_params.make_tol(1)))
118 QA(VOLK_INIT_TEST(volk_32fc_magnitude_32f, test_params_inacc_tenth))
119 QA(VOLK_INIT_TEST(volk_32fc_magnitude_squared_32f, test_params))
120 QA(VOLK_INIT_TEST(volk_32fc_x2_add_32fc, test_params))
121 QA(VOLK_INIT_TEST(volk_32fc_x2_multiply_32fc, test_params))
122 QA(VOLK_INIT_TEST(volk_32fc_x2_multiply_conjugate_32fc, test_params))
123 QA(VOLK_INIT_TEST(volk_32fc_x2_divide_32fc, test_params))
124 QA(VOLK_INIT_TEST(volk_32fc_conjugate_32fc, test_params))
125 QA(VOLK_INIT_TEST(volk_32f_s32f_convert_16i, test_params.make_tol(1)))
126 QA(VOLK_INIT_TEST(volk_32f_s32f_convert_32i, test_params.make_tol(1)))
127 QA(VOLK_INIT_TEST(volk_32f_convert_64f, test_params))
128 QA(VOLK_INIT_TEST(volk_32f_s32f_convert_8i, test_params.make_tol(1)))
129 QA(VOLK_INIT_TEST(volk_32fc_convert_16ic, test_params))
130 QA(VOLK_INIT_TEST(volk_32fc_s32f_power_spectrum_32f, test_params.make_tol(2e-6)))
131 QA(VOLK_INIT_TEST(volk_32fc_x2_square_dist_32f, test_params))
132 QA(VOLK_INIT_TEST(volk_32fc_x2_s32f_square_dist_scalar_mult_32f, test_params))
133 QA(VOLK_INIT_TEST(volk_32f_x2_divide_32f, test_params))
134 QA(VOLK_INIT_TEST(volk_32f_x2_dot_prod_32f, test_params.make_absolute(1.5e-2)))
135 QA(VOLK_INIT_TEST(volk_32f_x2_s32f_interleave_16ic, test_params.make_tol(1)))
136 QA(VOLK_INIT_TEST(volk_32f_x2_interleave_32fc, test_params))
137 QA(VOLK_INIT_TEST(volk_32f_x2_max_32f, test_params))
138 QA(VOLK_INIT_TEST(volk_32f_x2_min_32f, test_params))
139 QA(VOLK_INIT_TEST(volk_32f_x2_multiply_32f, test_params))
140 QA(VOLK_INIT_TEST(volk_32f_64f_multiply_64f, test_params))
141 QA(VOLK_INIT_TEST(volk_32f_64f_add_64f, test_params))
142 QA(VOLK_INIT_TEST(volk_32f_s32f_normalize, test_params))
143 QA(VOLK_INIT_TEST(volk_32f_s32f_power_32f, test_params))
144 QA(VOLK_INIT_TEST(volk_32f_sqrt_32f, test_params_inacc))
145 QA(VOLK_INIT_TEST(volk_32f_s32f_stddev_32f, test_params_inacc))
146 QA(VOLK_INIT_TEST(volk_32f_stddev_and_mean_32f_x2, test_params.make_absolute(1e-5)))
147 QA(VOLK_INIT_TEST(volk_32f_x2_subtract_32f, test_params))
148 QA(VOLK_INIT_TEST(volk_32f_x3_sum_of_poly_32f, test_params.make_absolute(1e+3)))
149 QA(VOLK_INIT_TEST(volk_32i_x2_and_32i, test_params))
150 QA(VOLK_INIT_TEST(volk_32i_s32f_convert_32f, test_params))
151 QA(VOLK_INIT_TEST(volk_32i_x2_or_32i, test_params))
152 QA(VOLK_INIT_TEST(volk_32f_x2_dot_prod_16i, test_params.make_tol(1)))
153 QA(VOLK_INIT_TEST(volk_64f_convert_32f, test_params))
154 QA(VOLK_INIT_TEST(volk_64f_x2_max_64f, test_params))
155 QA(VOLK_INIT_TEST(volk_64f_x2_min_64f, test_params))
156 QA(VOLK_INIT_TEST(volk_64f_x2_multiply_64f, test_params))
157 QA(VOLK_INIT_TEST(volk_64f_x2_add_64f, test_params))
158 QA(VOLK_INIT_TEST(volk_8ic_deinterleave_16i_x2, test_params))
159 QA(VOLK_INIT_TEST(volk_8ic_s32f_deinterleave_32f_x2, test_params))
160 QA(VOLK_INIT_TEST(volk_8ic_deinterleave_real_16i, test_params))
161 QA(VOLK_INIT_TEST(volk_8ic_s32f_deinterleave_real_32f, test_params))
162 QA(VOLK_INIT_TEST(volk_8ic_deinterleave_real_8i, test_params))
163 QA(VOLK_INIT_TEST(volk_8ic_x2_multiply_conjugate_16ic, test_params))
164 QA(VOLK_INIT_TEST(volk_8ic_x2_s32f_multiply_conjugate_32fc, test_params))
165 QA(VOLK_INIT_TEST(volk_8i_convert_16i, test_params))
166 QA(VOLK_INIT_TEST(volk_8i_s32f_convert_32f, test_params))
167 QA(VOLK_INIT_TEST(volk_32fc_s32fc_multiply2_32fc, test_params))
168 QA(VOLK_INIT_TEST(volk_32f_s32f_multiply_32f, test_params))
169 QA(VOLK_INIT_TEST(volk_32f_s32f_add_32f, test_params))
170 QA(VOLK_INIT_TEST(volk_32f_binary_slicer_32i, test_params))
171 QA(VOLK_INIT_TEST(volk_32f_binary_slicer_8i, test_params))
172 QA(VOLK_INIT_TEST(volk_32u_reverse_32u, test_params))
173 QA(VOLK_INIT_TEST(volk_32f_tanh_32f, test_params_inacc))
174 QA(VOLK_INIT_TEST(volk_32fc_x2_s32fc_multiply_conjugate_add2_32fc, test_params))
175 QA(VOLK_INIT_TEST(volk_32f_exp_32f, test_params))
176 QA(VOLK_INIT_PUPP(volk_32f_x2_powpuppet_32f, volk_32f_x2_pow_32f, test_params_inacc))
178 volk_32f_s32f_mod_rangepuppet_32f, volk_32f_s32f_s32f_mod_range_32f, test_params))
180 volk_8u_x3_encodepolarpuppet_8u, volk_8u_x3_encodepolar_8u_x2, test_params))
181 QA(VOLK_INIT_PUPP(volk_32f_8u_polarbutterflypuppet_32f,
182 volk_32f_8u_polarbutterfly_32f,
183 test_params))
184 QA(VOLK_INIT_PUPP(volk_32fc_s32f_power_spectral_densitypuppet_32f,
185 volk_32fc_s32f_x2_power_spectral_density_32f,
186 test_params))
188 volk_32f_s32f_clamppuppet_32f, volk_32f_s32f_x2_clamp_32f, test_params_clamp))
189 QA(VOLK_INIT_PUPP(volk_32f_s32f_convertpuppet_8u,
190 volk_32f_s32f_x2_convert_8u,
191 test_params.make_tol(1)))
192 // no one uses these, so don't test them
193 // VOLK_PROFILE(volk_16i_x5_add_quad_16i_x4, 1e-4, 2046, 10000, &results,
194 // benchmark_mode, kernel_regex); VOLK_PROFILE(volk_16i_branch_4_state_8, 1e-4, 2046,
195 // 10000, &results, benchmark_mode, kernel_regex); VOLK_PROFILE(volk_16i_max_star_16i,
196 // 0, 0, 204602, 10000, &results, benchmark_mode, kernel_regex);
197 // VOLK_PROFILE(volk_16i_max_star_horizontal_16i, 0, 0, 204602, 10000, &results,
198 // benchmark_mode, kernel_regex); VOLK_PROFILE(volk_16i_permute_and_scalar_add, 1e-4,
199 // 0, 2046, 10000, &results, benchmark_mode, kernel_regex);
200 // VOLK_PROFILE(volk_16i_x4_quad_max_star_16i, 1e-4, 0, 2046, 10000, &results,
201 // benchmark_mode, kernel_regex);
202
203 return test_cases;
204}