Vector Optimized Library of Kernels
3.2.0
Architecture-tuned implementations of math kernels
Loading...
Searching...
No Matches
qa_utils.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2011 - 2020, 2022 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
#ifndef VOLK_QA_UTILS_H
11
#define VOLK_QA_UTILS_H
12
13
#include <stdbool.h>
// for bool, false
14
#include <volk/volk.h>
// for volk_func_desc_t
15
#include <cstdlib>
// for NULL
16
#include <map>
// for map
17
#include <string>
// for string, basic_string
18
#include <vector>
// for vector
19
20
#include "
volk/volk_complex.h
"
// for lv_32fc_t
21
22
/************************************************
23
* VOLK QA type definitions *
24
************************************************/
25
struct
volk_type_t
{
26
bool
is_float
;
27
bool
is_scalar
;
28
bool
is_signed
;
29
bool
is_complex
;
30
int
size
;
31
std::string
str
;
32
};
33
34
class
volk_test_time_t
35
{
36
public
:
37
std::string
name
;
38
double
time
;
39
std::string
units
;
40
bool
pass
;
41
};
42
43
class
volk_test_results_t
44
{
45
public
:
46
std::string
name
;
47
std::string
config_name
;
48
unsigned
int
vlen
;
49
unsigned
int
iter
;
50
std::map<std::string, volk_test_time_t>
results
;
51
std::string
best_arch_a
;
52
std::string
best_arch_u
;
53
};
54
55
class
volk_test_params_t
56
{
57
private
:
58
float
_tol;
59
lv_32fc_t
_scalar;
60
unsigned
int
_vlen;
61
unsigned
int
_iter;
62
bool
_benchmark_mode;
63
bool
_absolute_mode;
64
std::string _kernel_regex;
65
66
public
:
67
// ctor
68
volk_test_params_t
(
float
tol
,
69
lv_32fc_t
scalar
,
70
unsigned
int
vlen
,
71
unsigned
int
iter
,
72
bool
benchmark_mode
,
73
std::string
kernel_regex
)
74
: _tol(
tol
),
75
_scalar(
scalar
),
76
_vlen(
vlen
),
77
_iter(
iter
),
78
_benchmark_mode(
benchmark_mode
),
79
_absolute_mode(false),
80
_kernel_regex(
kernel_regex
){};
81
// setters
82
void
set_tol
(
float
tol
) { _tol =
tol
; };
83
void
set_scalar
(
lv_32fc_t
scalar
) { _scalar =
scalar
; };
84
void
set_vlen
(
unsigned
int
vlen
) { _vlen =
vlen
; };
85
void
set_iter
(
unsigned
int
iter
) { _iter =
iter
; };
86
void
set_benchmark
(
bool
benchmark) { _benchmark_mode = benchmark; };
87
void
set_regex
(std::string regex) { _kernel_regex = regex; };
88
// getters
89
float
tol
() {
return
_tol; };
90
lv_32fc_t
scalar
() {
return
_scalar; };
91
unsigned
int
vlen
() {
return
_vlen; };
92
unsigned
int
iter
() {
return
_iter; };
93
bool
benchmark_mode
() {
return
_benchmark_mode; };
94
bool
absolute_mode
() {
return
_absolute_mode; };
95
std::string
kernel_regex
() {
return
_kernel_regex; };
96
volk_test_params_t
make_absolute
(
float
tol
)
97
{
98
volk_test_params_t
t(*
this
);
99
t._tol =
tol
;
100
t._absolute_mode =
true
;
101
return
t;
102
}
103
volk_test_params_t
make_tol
(
float
tol
)
104
{
105
volk_test_params_t
t(*
this
);
106
t._tol =
tol
;
107
return
t;
108
}
109
};
110
111
class
volk_test_case_t
112
{
113
private
:
114
volk_func_desc_t _desc;
115
void (*_kernel_ptr)();
116
std::string _name;
117
volk_test_params_t
_test_parameters;
118
std::string _puppet_master_name;
119
120
public
:
121
volk_func_desc_t
desc
() {
return
_desc; };
122
void (*
kernel_ptr
())() {
return
_kernel_ptr; };
123
std::string
name
() {
return
_name; };
124
std::string
puppet_master_name
() {
return
_puppet_master_name; };
125
volk_test_params_t
test_parameters
() {
return
_test_parameters; };
126
// normal ctor
127
volk_test_case_t
(volk_func_desc_t
desc
,
128
void
(*t_kernel_ptr)(),
129
std::string
name
,
130
volk_test_params_t
test_parameters
)
131
: _desc(
desc
),
132
_kernel_ptr(t_kernel_ptr),
133
_name(
name
),
134
_test_parameters(
test_parameters
),
135
_puppet_master_name(
"NULL"
){};
136
// ctor for puppets
137
volk_test_case_t
(volk_func_desc_t
desc
,
138
void
(*t_kernel_ptr)(),
139
std::string
name
,
140
std::string
puppet_master_name
,
141
volk_test_params_t
test_parameters
)
142
: _desc(
desc
),
143
_kernel_ptr(t_kernel_ptr),
144
_name(
name
),
145
_test_parameters(
test_parameters
),
146
_puppet_master_name(
puppet_master_name
){};
147
};
148
149
/************************************************
150
* VOLK QA functions *
151
************************************************/
152
volk_type_t
volk_type_from_string
(std::string);
153
154
float
uniform
(
void
);
155
void
random_floats
(
float
* buf,
unsigned
n);
156
157
bool
run_volk_tests
(volk_func_desc_t,
158
void
(*)(),
159
std::string,
160
volk_test_params_t
,
161
std::vector<volk_test_results_t>* results = NULL,
162
std::string puppet_master_name =
"NULL"
);
163
164
bool
run_volk_tests
(volk_func_desc_t,
165
void
(*)(),
166
std::string,
167
float
,
168
lv_32fc_t
,
169
unsigned
int
,
170
unsigned
int
,
171
std::vector<volk_test_results_t>* results = NULL,
172
std::string puppet_master_name =
"NULL"
,
173
bool
absolute_mode =
false
,
174
bool
benchmark_mode =
false
);
175
176
#define VOLK_PROFILE(func, test_params, results) \
177
run_volk_tests(func##_get_func_desc(), \
178
(void (*)())func##_manual, \
179
std::string(#func), \
180
test_params, \
181
results, \
182
"NULL")
183
#define VOLK_PUPPET_PROFILE(func, puppet_master_func, test_params, results) \
184
run_volk_tests(func##_get_func_desc(), \
185
(void (*)())func##_manual, \
186
std::string(#func), \
187
test_params, \
188
results, \
189
std::string(#puppet_master_func))
190
typedef
void (*
volk_fn_1arg
)(
void
*,
191
unsigned
int,
192
const
char
*);
// one input, operate in place
193
typedef
void (*
volk_fn_2arg
)(
void
*,
void
*,
unsigned
int,
const
char
*);
194
typedef
void (*
volk_fn_3arg
)(
void
*,
void
*,
void
*,
unsigned
int,
const
char
*);
195
typedef
void (*
volk_fn_4arg
)(
void
*,
void
*,
void
*,
void
*,
unsigned
int,
const
char
*);
196
typedef
void (*
volk_fn_1arg_s32f
)(
197
void
*, float,
unsigned
int,
const
char
*);
// one input vector, one scalar float input
198
typedef
void (*
volk_fn_2arg_s32f
)(
void
*,
void
*, float,
unsigned
int,
const
char
*);
199
typedef
void (*
volk_fn_3arg_s32f
)(
void
*,
void
*,
void
*, float,
unsigned
int,
const
char
*);
200
typedef
void (*
volk_fn_1arg_s32fc
)(
201
void
*,
202
lv_32fc_t
*,
203
unsigned
int,
204
const
char
*);
// one input vector, one scalar float input
205
typedef
void (*
volk_fn_2arg_s32fc
)(
void
*,
void
*,
lv_32fc_t
*,
unsigned
int,
const
char
*);
206
typedef
void (*
volk_fn_3arg_s32fc
)(
207
void
*,
void
*,
void
*,
lv_32fc_t
*,
unsigned
int,
const
char
*);
208
209
#endif
// VOLK_QA_UTILS_H
lib
qa_utils.h
Generated by
1.9.8