-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathoptions.cpp
More file actions
162 lines (157 loc) · 5.69 KB
/
options.cpp
File metadata and controls
162 lines (157 loc) · 5.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "../include/ze_peak.h"
static const char *usage_str =
"\n ze_peak [OPTIONS]"
"\n"
"\n OPTIONS:"
"\n -r, --driver num choose driver (num starts with 0)"
"\n -d, --device num choose device (num starts with 0)"
"\n -e time using ze events instead of std "
"chrono timer"
"\n hide driver latencies [default: No]"
"\n -t, string selectively run a particular test"
"\n global_bw selectively run global bandwidth test"
"\n hp_compute selectively run half precision compute "
"test"
"\n sp_compute selectively run single precision compute "
"test"
"\n dp_compute selectively run double precision compute "
"test"
"\n int_compute selectively run integer compute test"
"\n transfer_bw selectively run transfer bandwidth test"
"\n kernel_lat selectively run kernel latency test"
"\n -a run all above tests [default]"
"\n -v enable verbose prints"
"\n -i set number of iterations to run[default: "
"50]"
"\n -w set number of warmup iterations to "
"run[default: 10]"
"\n -x enable explicit scaling [default: "
"Disabled]"
"\n -q query for number of engines available"
"\n -g, group select engine group (default: 0)"
"\n -n, number select engine index (default: 0)"
"\n -h, --help display help message"
"\n";
static uint32_t sanitize_ulong(char *in) {
unsigned long temp = strtoul(in, NULL, 0);
if (ERANGE == errno) {
fprintf(stderr, "%s out of range of type ulong\n", in);
} else if (temp > UINT32_MAX) {
fprintf(stderr, "%ld greater than UINT32_MAX\n", temp);
} else {
return static_cast<uint32_t>(temp);
}
return 0;
}
//---------------------------------------------------------------------
// Utility function which parses the arguments to ze_peak and
// sets the test parameters accordingly for main to execute the tests
// with the correct environment.
//---------------------------------------------------------------------
int ZePeak::parse_arguments(int argc, char **argv) {
bool __run_global_bw = false;
bool __run_hp_compute = false;
bool __run_sp_compute = false;
bool __run_dp_compute = false;
bool __run_int_compute = false;
bool __run_transfer_bw = false;
bool __run_kernel_lat = false;
for (int i = 1; i < argc; i++) {
if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) {
std::cout << usage_str;
exit(0);
} else if ((strcmp(argv[i], "-r") == 0) ||
(strcmp(argv[i], "--driver") == 0)) {
if ((i + 1) < argc) {
specified_driver = sanitize_ulong(argv[i + 1]);
i++;
}
} else if ((strcmp(argv[i], "-d") == 0) ||
(strcmp(argv[i], "--device") == 0)) {
if ((i + 1) < argc) {
specified_device = sanitize_ulong(argv[i + 1]);
i++;
}
} else if (strcmp(argv[i], "-e") == 0) {
use_event_timer = true;
} else if (strcmp(argv[i], "-v") == 0) {
verbose = true;
} else if (strcmp(argv[i], "-i") == 0) {
if ((i + 1) < argc) {
iters = sanitize_ulong(argv[i + 1]);
i++;
}
} else if (strcmp(argv[i], "-w") == 0) {
if ((i + 1) < argc) {
warmup_iterations = sanitize_ulong(argv[i + 1]);
i++;
}
} else if ((strcmp(argv[i], "-t") == 0)) {
if ((i + 1) >= argc) {
std::cout << usage_str;
exit(-1);
}
if (strcmp(argv[i + 1], "global_bw") == 0) {
__run_global_bw = true;
i++;
} else if (strcmp(argv[i + 1], "hp_compute") == 0) {
__run_hp_compute = true;
i++;
} else if (strcmp(argv[i + 1], "sp_compute") == 0) {
__run_sp_compute = true;
i++;
} else if (strcmp(argv[i + 1], "dp_compute") == 0) {
__run_dp_compute = true;
i++;
} else if (strcmp(argv[i + 1], "int_compute") == 0) {
__run_int_compute = true;
i++;
} else if (strcmp(argv[i + 1], "transfer_bw") == 0) {
__run_transfer_bw = true;
i++;
} else if (strcmp(argv[i + 1], "kernel_lat") == 0) {
__run_kernel_lat = true;
i++;
} else {
std::cout << usage_str;
exit(-1);
}
} else if (strcmp(argv[i], "-a") == 0) {
__run_global_bw = __run_hp_compute = __run_sp_compute = __run_dp_compute =
__run_int_compute = __run_transfer_bw = __run_kernel_lat = true;
} else if (strcmp(argv[i], "-x") == 0) {
enable_explicit_scaling = true;
} else if ((strcmp(argv[i], "-q") == 0)) {
query_engines = true;
} else if ((strcmp(argv[i], "-g") == 0)) {
enable_fixed_ordinal_index = true;
if (((i + 1) < argc) && isdigit(argv[i + 1][0])) {
command_queue_group_ordinal = atoi(argv[i + 1]);
}
i++;
} else if ((strcmp(argv[i], "-n") == 0)) {
if (((i + 1) < argc) && isdigit(argv[i + 1][0])) {
command_queue_index = atoi(argv[i + 1]);
}
i++;
} else {
std::cout << usage_str;
exit(-1);
}
}
run_global_bw = __run_global_bw;
run_hp_compute = __run_hp_compute;
run_sp_compute = __run_sp_compute;
run_dp_compute = __run_dp_compute;
run_int_compute = __run_int_compute;
run_transfer_bw = __run_transfer_bw;
run_kernel_lat = __run_kernel_lat;
return 0;
}