10
10
11
11
# @test_to_run_list stores only the test(s) that will be run
12
12
# For example, for "tc -t llvm_test_suite_sycl/aot_cpu,aot_gpu" it will store 2 tests - aot_cpu and aot_gpu
13
- my @test_to_run_list = ();
13
+ my @test_to_run_list = get_tests_to_run ();
14
14
# @suite_test_list stores all the tests in the whole suite(without splitting) or sub-suite(with splitting)
15
15
# For example, for "tc -t llvm_test_suite_sycl~4-1/aot_cpu,aot_gpu" it will store all the tests in sub-suite 4-1
16
- my @suite_test_list = ( );
16
+ my @suite_test_list = get_test_list( $current_optset );
17
17
my $short_test_name ;
18
18
my $test_info ;
19
- my $config_folder = " " ;
19
+ my $config_folder = ' config_sycl ' ;
20
20
my $subdir = " SYCL" ;
21
21
my $insert_command = " " ;
22
- my $is_suite = 0;
23
22
24
23
my $sycl_backend = " " ;
25
24
my $device = " " ;
@@ -52,13 +51,27 @@ sub lscl {
52
51
return $output ;
53
52
}
54
53
54
+ sub is_zperf_run {
55
+ if ((defined $opt_perf && $opt_perf ) ||
56
+ (defined $opt_perf_run && $opt_perf_run )) {
57
+ return 1;
58
+ }
59
+ return 0;
60
+ }
61
+
62
+ sub is_suite {
63
+ my @whole_suite_test = sort (@suite_test_list );
64
+ my @current_test_list = sort (@test_to_run_list );
65
+
66
+ return is_same(\@current_test_list , \@whole_suite_test );
67
+ }
68
+
55
69
sub init_test
56
70
{
57
71
my $suite_feature = $current_suite ;
58
72
$suite_feature =~ s / ^llvm_test_suite_// ;
59
73
# Remove suffix of suite names if it has
60
74
$suite_feature =~ s / ~.*$// ;
61
- $config_folder = ' config_sycl' ;
62
75
if ($suite_feature !~ / ^sycl/ )
63
76
{
64
77
$config_folder = $config_folder . ' _' . $suite_feature ;
@@ -93,7 +106,7 @@ sub init_test
93
106
}
94
107
95
108
# Remove untested source files from $subdir if it run with several subsuites
96
- if ($ is_suite ) {
109
+ if (is_suite() ) {
97
110
my $info_dir = " $optset_work_dir /$config_folder " ;
98
111
my @info_files = glob (" $info_dir /*.info" );
99
112
@@ -124,21 +137,69 @@ sub init_test
124
137
return PASS;
125
138
}
126
139
140
+ sub extract_perf_results
141
+ {
142
+ my $timer = Timer-> new($current_test , $current_suite , $current_optset );
143
+ $timer -> set(" host" , &alloy_utils::get_hostname());
144
+ my $output_file = join ($slash , $optset_work_dir , " $current_test .output" );
145
+ open (LOG, " +>" , $output_file ) or die " open $output_file fail" ;
146
+ print LOG $execution_output ;
147
+ seek (LOG, 0, 0);
148
+ my $perf_matched = 0;
149
+ while (<LOG>) {
150
+ my $pattern = " .*OverallTime(.*):(\\ d+.?\\ d*[Ee]?[+-]?\\ d+).*" ;
151
+ if ($_ =~ qr /$pattern / ) {
152
+ my $primary = $1 ;
153
+ my $result = $2 ;
154
+ my $metric = " time" ;
155
+ my $better = " lt" ;
156
+ $timer -> set($metric , $result );
157
+ $timer -> set(" BETTER_$metric " , $better );
158
+ if ($primary =~ m / Primary/ ) {
159
+ $timer -> set(" primary_metric" , $metric );
160
+ $perf_matched = 1;
161
+ }
162
+ }
163
+ $pattern = " .*KernelThroughput(.*):(\\ d+.?\\ d*[Ee]?[+-]?\\ d+).*" ;
164
+ if ($_ =~ qr /$pattern / ) {
165
+ my $primary = $1 ;
166
+ my $result = $2 ;
167
+ my $metric = " throughput" ;
168
+ my $better = " gt" ;
169
+ $timer -> set($metric , $result );
170
+ $timer -> set(" BETTER_$metric " , $better );
171
+ if ($primary =~ m / Primary/ ) {
172
+ $timer -> set(" primary_metric" , $metric );
173
+ $perf_matched = 1;
174
+ }
175
+ }
176
+ $pattern = " .*KernelTime(.*):(\\ d+.?\\ d*[Ee]?[+-]?\\ d+).*" ;
177
+ if ($_ =~ qr /$pattern / ) {
178
+ my $primary = $1 ;
179
+ my $result = $2 ;
180
+ my $metric = " kerneltime" ;
181
+ my $better = " lt" ;
182
+ $timer -> set($metric , $result );
183
+ $timer -> set(" BETTER_$metric " , $better );
184
+ if ($primary =~ m / Primary/ ) {
185
+ $timer -> set(" primary_metric" , $metric );
186
+ $perf_matched = 1;
187
+ }
188
+ }
189
+ }
190
+ close (LOG);
191
+ if (! $perf_matched ) {
192
+ print " Warning: Primary metric is not specified!!!\n " ;
193
+ }
194
+ }
195
+
127
196
sub BuildTest
128
197
{
129
198
$build_dir = $cwd . " /build" ;
130
199
safe_Mkdir($build_dir );
131
200
132
- # CMPLRTST-14094: API get_test_list() requires optset name as an argument
133
- @suite_test_list = get_test_list($current_optset );
134
-
135
- @test_to_run_list = get_tests_to_run();
136
201
if ($current_test eq $test_to_run_list [0])
137
202
{
138
- my @whole_suite_test = sort (@suite_test_list );
139
- my @current_test_list = sort (@test_to_run_list );
140
- $is_suite = is_same(\@current_test_list , \@whole_suite_test );
141
-
142
203
init_test();
143
204
chdir_log($build_dir );
144
205
@@ -168,6 +229,9 @@ sub BuildTest
168
229
169
230
sub RunTest
170
231
{
232
+ $build_dir = $cwd . " /build" ;
233
+ chdir_log($build_dir );
234
+
171
235
$test_info = get_info();
172
236
my ( $status , $output ) = do_run($test_info );
173
237
my $res = " " ;
@@ -180,6 +244,9 @@ sub RunTest
180
244
} else {
181
245
$res = generate_run_result($output );
182
246
}
247
+ if ($res eq $PASS && is_zperf_run()) {
248
+ extract_perf_results();
249
+ }
183
250
return $res ;
184
251
}
185
252
@@ -215,7 +282,7 @@ sub do_run
215
282
$timeset = " --timeout 0" ;
216
283
}
217
284
218
- if ($ is_suite ) {
285
+ if (is_suite() ) {
219
286
set_tool_path();
220
287
execute(" $python $lit -a $matrix $jobset . $timeset > $run_all_lf 2>&1" );
221
288
} else {
0 commit comments