Vector Optimized Library of Kernels  2.0
Architecture-tuned implementations of math kernels
kernel_tests.h
Go to the documentation of this file.
1 #include "qa_utils.h"
2 
3 #include <volk/volk.h>
4 #include <vector>
5 
6 // macros for initializing volk_test_case_t. Maccros are needed to generate
7 // function names of the pattern kernel_name_*
8 
9 // for puppets we need to get all the func_variants for the puppet and just
10 // keep track of the actual function name to write to results
11 #define VOLK_INIT_PUPP(func, puppet_master_func, test_params)\
12  volk_test_case_t(func##_get_func_desc(), (void(*)())func##_manual, std::string(#func),\
13  std::string(#puppet_master_func), test_params)
14 
15 #define VOLK_INIT_TEST(func, test_params)\
16  volk_test_case_t(func##_get_func_desc(), (void(*)())func##_manual, std::string(#func),\
17  test_params)
18 
19 #define QA(test) test_cases.push_back(test);
20 std::vector<volk_test_case_t> init_test_list(volk_test_params_t test_params)
21 {
22 
23  // Some kernels need a lower tolerance
24  volk_test_params_t test_params_inacc = test_params.make_tol(1e-2);
25  volk_test_params_t test_params_inacc_tenth = test_params.make_tol(1e-1);
26 
27  volk_test_params_t test_params_power(test_params);
28  test_params_power.set_scalar(2.5);
29 
30  volk_test_params_t test_params_rotator(test_params);
31  test_params_rotator.set_scalar(std::polar(1.0f, 0.1f));
32  test_params_rotator.set_tol(1e-3);
33 
34  std::vector<volk_test_case_t> test_cases;
35  QA(VOLK_INIT_PUPP(volk_64u_popcntpuppet_64u, volk_64u_popcnt, test_params))
36  QA(VOLK_INIT_PUPP(volk_64u_popcntpuppet_64u, volk_64u_popcnt, test_params))
37  QA(VOLK_INIT_PUPP(volk_64u_popcntpuppet_64u, volk_64u_popcnt, test_params))
38  QA(VOLK_INIT_PUPP(volk_16u_byteswappuppet_16u, volk_16u_byteswap, test_params))
39  QA(VOLK_INIT_PUPP(volk_32u_byteswappuppet_32u, volk_32u_byteswap, test_params))
40  QA(VOLK_INIT_PUPP(volk_32u_popcntpuppet_32u, volk_32u_popcnt_32u, test_params))
41  QA(VOLK_INIT_PUPP(volk_64u_byteswappuppet_64u, volk_64u_byteswap, test_params))
42  QA(VOLK_INIT_PUPP(volk_32fc_s32fc_rotatorpuppet_32fc, volk_32fc_s32fc_x2_rotator_32fc, test_params_rotator))
43  QA(VOLK_INIT_PUPP(volk_8u_conv_k7_r2puppet_8u, volk_8u_x4_conv_k7_r2_8u, test_params.make_tol(0)))
44  QA(VOLK_INIT_PUPP(volk_32f_x2_fm_detectpuppet_32f, volk_32f_s32f_32f_fm_detect_32f, test_params))
45  QA(VOLK_INIT_TEST(volk_16ic_s32f_deinterleave_real_32f, test_params))
46  QA(VOLK_INIT_TEST(volk_16ic_deinterleave_real_8i, test_params))
47  QA(VOLK_INIT_TEST(volk_16ic_deinterleave_16i_x2, test_params))
48  QA(VOLK_INIT_TEST(volk_16ic_s32f_deinterleave_32f_x2, test_params))
49  QA(VOLK_INIT_TEST(volk_16ic_deinterleave_real_16i, test_params))
50  QA(VOLK_INIT_TEST(volk_16ic_magnitude_16i, test_params))
51  QA(VOLK_INIT_TEST(volk_16ic_s32f_magnitude_32f, test_params))
52  QA(VOLK_INIT_TEST(volk_16ic_convert_32fc, test_params))
53  QA(VOLK_INIT_TEST(volk_16ic_x2_multiply_16ic, test_params))
54  QA(VOLK_INIT_TEST(volk_16ic_x2_dot_prod_16ic, test_params))
55  QA(VOLK_INIT_TEST(volk_16i_s32f_convert_32f, test_params))
56  QA(VOLK_INIT_TEST(volk_16i_convert_8i, test_params))
57  QA(VOLK_INIT_TEST(volk_16i_32fc_dot_prod_32fc, test_params_inacc))
58  QA(VOLK_INIT_TEST(volk_32f_accumulator_s32f, test_params_inacc))
59  QA(VOLK_INIT_TEST(volk_32f_x2_add_32f, test_params))
60  QA(VOLK_INIT_TEST(volk_32f_index_max_16u, test_params))
61  QA(VOLK_INIT_TEST(volk_32f_index_max_32u, test_params))
62  QA(VOLK_INIT_TEST(volk_32fc_32f_multiply_32fc, test_params))
63  QA(VOLK_INIT_TEST(volk_32fc_32f_add_32fc, test_params))
64  QA(VOLK_INIT_TEST(volk_32f_log2_32f, test_params.make_absolute(1e-5)))
65  QA(VOLK_INIT_TEST(volk_32f_expfast_32f, test_params_inacc_tenth))
66  QA(VOLK_INIT_TEST(volk_32f_x2_pow_32f, test_params_inacc))
67  QA(VOLK_INIT_TEST(volk_32f_sin_32f, test_params_inacc))
68  QA(VOLK_INIT_TEST(volk_32f_cos_32f, test_params_inacc))
69  QA(VOLK_INIT_TEST(volk_32f_tan_32f, test_params_inacc))
70  QA(VOLK_INIT_TEST(volk_32f_atan_32f, test_params_inacc))
71  QA(VOLK_INIT_TEST(volk_32f_asin_32f, test_params_inacc))
72  QA(VOLK_INIT_TEST(volk_32f_acos_32f, test_params_inacc))
73  QA(VOLK_INIT_TEST(volk_32fc_s32f_power_32fc, test_params_power))
74  QA(VOLK_INIT_TEST(volk_32f_s32f_calc_spectral_noise_floor_32f, test_params_inacc))
75  QA(VOLK_INIT_TEST(volk_32fc_s32f_atan2_32f, test_params))
76  QA(VOLK_INIT_TEST(volk_32fc_x2_conjugate_dot_prod_32fc, test_params_inacc_tenth))
77  QA(VOLK_INIT_TEST(volk_32fc_deinterleave_32f_x2, test_params))
78  QA(VOLK_INIT_TEST(volk_32fc_deinterleave_64f_x2, test_params))
79  QA(VOLK_INIT_TEST(volk_32fc_s32f_deinterleave_real_16i, test_params))
80  QA(VOLK_INIT_TEST(volk_32fc_deinterleave_imag_32f, test_params))
81  QA(VOLK_INIT_TEST(volk_32fc_deinterleave_real_32f, test_params))
82  QA(VOLK_INIT_TEST(volk_32fc_deinterleave_real_64f, test_params))
83  QA(VOLK_INIT_TEST(volk_32fc_x2_dot_prod_32fc, test_params_inacc))
84  QA(VOLK_INIT_TEST(volk_32fc_32f_dot_prod_32fc, test_params_inacc))
85  QA(VOLK_INIT_TEST(volk_32fc_index_max_16u, test_params))
86  QA(VOLK_INIT_TEST(volk_32fc_index_max_32u, test_params))
87  QA(VOLK_INIT_TEST(volk_32fc_s32f_magnitude_16i, test_params))
88  QA(VOLK_INIT_TEST(volk_32fc_magnitude_32f, test_params_inacc_tenth))
89  QA(VOLK_INIT_TEST(volk_32fc_magnitude_squared_32f, test_params))
90  QA(VOLK_INIT_TEST(volk_32fc_x2_add_32fc, test_params))
91  QA(VOLK_INIT_TEST(volk_32fc_x2_multiply_32fc, test_params))
92  QA(VOLK_INIT_TEST(volk_32fc_x2_multiply_conjugate_32fc, test_params))
93  QA(VOLK_INIT_TEST(volk_32fc_x2_divide_32fc, test_params))
94  QA(VOLK_INIT_TEST(volk_32fc_conjugate_32fc, test_params))
95  QA(VOLK_INIT_TEST(volk_32f_s32f_convert_16i, test_params))
96  QA(VOLK_INIT_TEST(volk_32f_s32f_convert_32i, test_params))
97  QA(VOLK_INIT_TEST(volk_32f_convert_64f, test_params))
98  QA(VOLK_INIT_TEST(volk_32f_s32f_convert_8i, test_params))
99  QA(VOLK_INIT_TEST(volk_32fc_convert_16ic, test_params))
100  QA(VOLK_INIT_TEST(volk_32fc_s32f_power_spectrum_32f, test_params))
101  QA(VOLK_INIT_TEST(volk_32fc_x2_square_dist_32f, test_params))
102  QA(VOLK_INIT_TEST(volk_32fc_x2_s32f_square_dist_scalar_mult_32f, test_params))
103  QA(VOLK_INIT_TEST(volk_32f_x2_divide_32f, test_params))
104  QA(VOLK_INIT_TEST(volk_32f_x2_dot_prod_32f, test_params_inacc))
105  QA(VOLK_INIT_TEST(volk_32f_x2_s32f_interleave_16ic, test_params))
106  QA(VOLK_INIT_TEST(volk_32f_x2_interleave_32fc, test_params))
107  QA(VOLK_INIT_TEST(volk_32f_x2_max_32f, test_params))
108  QA(VOLK_INIT_TEST(volk_32f_x2_min_32f, test_params))
109  QA(VOLK_INIT_TEST(volk_32f_x2_multiply_32f, test_params))
110  QA(VOLK_INIT_TEST(volk_32f_64f_multiply_64f, test_params))
111  QA(VOLK_INIT_TEST(volk_32f_64f_add_64f, test_params))
112  QA(VOLK_INIT_TEST(volk_32f_s32f_normalize, test_params))
113  QA(VOLK_INIT_TEST(volk_32f_s32f_power_32f, test_params))
114  QA(VOLK_INIT_TEST(volk_32f_sqrt_32f, test_params_inacc))
115  QA(VOLK_INIT_TEST(volk_32f_s32f_stddev_32f, test_params_inacc))
116  QA(VOLK_INIT_TEST(volk_32f_stddev_and_mean_32f_x2, test_params_inacc))
117  QA(VOLK_INIT_TEST(volk_32f_x2_subtract_32f, test_params))
118  QA(VOLK_INIT_TEST(volk_32f_x3_sum_of_poly_32f, test_params_inacc))
119  QA(VOLK_INIT_TEST(volk_32i_x2_and_32i, test_params))
120  QA(VOLK_INIT_TEST(volk_32i_s32f_convert_32f, test_params))
121  QA(VOLK_INIT_TEST(volk_32i_x2_or_32i, test_params))
122  QA(VOLK_INIT_TEST(volk_32f_x2_dot_prod_16i, test_params))
123  QA(VOLK_INIT_TEST(volk_64f_convert_32f, test_params))
124  QA(VOLK_INIT_TEST(volk_64f_x2_max_64f, test_params))
125  QA(VOLK_INIT_TEST(volk_64f_x2_min_64f, test_params))
126  QA(VOLK_INIT_TEST(volk_64f_x2_multiply_64f, test_params))
127  QA(VOLK_INIT_TEST(volk_64f_x2_add_64f, test_params))
128  QA(VOLK_INIT_TEST(volk_8ic_deinterleave_16i_x2, test_params))
129  QA(VOLK_INIT_TEST(volk_8ic_s32f_deinterleave_32f_x2, test_params))
130  QA(VOLK_INIT_TEST(volk_8ic_deinterleave_real_16i, test_params))
131  QA(VOLK_INIT_TEST(volk_8ic_s32f_deinterleave_real_32f, test_params))
132  QA(VOLK_INIT_TEST(volk_8ic_deinterleave_real_8i, test_params))
133  QA(VOLK_INIT_TEST(volk_8ic_x2_multiply_conjugate_16ic, test_params))
134  QA(VOLK_INIT_TEST(volk_8ic_x2_s32f_multiply_conjugate_32fc, test_params))
135  QA(VOLK_INIT_TEST(volk_8i_convert_16i, test_params))
136  QA(VOLK_INIT_TEST(volk_8i_s32f_convert_32f, test_params))
137  QA(VOLK_INIT_TEST(volk_32fc_s32fc_multiply_32fc, test_params))
138  QA(VOLK_INIT_TEST(volk_32f_s32f_multiply_32f, test_params))
139  QA(VOLK_INIT_TEST(volk_32f_binary_slicer_32i, test_params))
140  QA(VOLK_INIT_TEST(volk_32f_binary_slicer_8i, test_params))
141  QA(VOLK_INIT_TEST(volk_32u_reverse_32u, test_params))
142  QA(VOLK_INIT_TEST(volk_32f_tanh_32f, test_params_inacc))
143  QA(VOLK_INIT_TEST(volk_32f_s32f_mod_rangepuppet_32f, test_params))
144  QA(VOLK_INIT_PUPP(volk_8u_x3_encodepolarpuppet_8u, volk_8u_x3_encodepolar_8u_x2, test_params))
145  QA(VOLK_INIT_PUPP(volk_32f_8u_polarbutterflypuppet_32f, volk_32f_8u_polarbutterfly_32f, test_params))
146  // no one uses these, so don't test them
147  //VOLK_PROFILE(volk_16i_x5_add_quad_16i_x4, 1e-4, 2046, 10000, &results, benchmark_mode, kernel_regex);
148  //VOLK_PROFILE(volk_16i_branch_4_state_8, 1e-4, 2046, 10000, &results, benchmark_mode, kernel_regex);
149  //VOLK_PROFILE(volk_16i_max_star_16i, 0, 0, 204602, 10000, &results, benchmark_mode, kernel_regex);
150  //VOLK_PROFILE(volk_16i_max_star_horizontal_16i, 0, 0, 204602, 10000, &results, benchmark_mode, kernel_regex);
151  //VOLK_PROFILE(volk_16i_permute_and_scalar_add, 1e-4, 0, 2046, 10000, &results, benchmark_mode, kernel_regex);
152  //VOLK_PROFILE(volk_16i_x4_quad_max_star_16i, 1e-4, 0, 2046, 10000, &results, benchmark_mode, kernel_regex);
153  // we need a puppet for this one
154  //(VOLK_INIT_TEST(volk_32fc_s32f_x2_power_spectral_density_32f, test_params))
155 
156 
157  return test_cases;
158 }
volk_test_params_t test_params(1e-6f, 327.f, 131071, 1987, false, "")
void set_tol(float tol)
Definition: qa_utils.h:60
#define VOLK_INIT_PUPP(func, puppet_master_func, test_params)
Definition: kernel_tests.h:11
volk_test_params_t make_absolute(float tol)
Definition: qa_utils.h:74
std::vector< volk_test_case_t > init_test_list(volk_test_params_t test_params)
Definition: kernel_tests.h:20
volk_test_params_t make_tol(float tol)
Definition: qa_utils.h:80
void set_scalar(lv_32fc_t scalar)
Definition: qa_utils.h:61
#define VOLK_INIT_TEST(func, test_params)
Definition: kernel_tests.h:15
#define QA(test)
Definition: kernel_tests.h:19
Definition: qa_utils.h:44