-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathparse.perl
executable file
·393 lines (313 loc) · 11.7 KB
/
parse.perl
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
#!/usr/bin/perl -w
#-----------------------------------------------------------
# Description:
# ------------
# This script parses the files mentioned in the runsim script
# and creates a csv with all the relevant information of all
# the simulations
#
# Inputs:
# -------
# 1) gen_csv.pl takes the name of the USIMM runscript as the only argument
# 2) The outputs produced by the runscript should be in the output/
# directory
# 3) The output files must follow the following naming convention
# <two letter abbv of benchmark>-...-<>-<num channels>_<whatever>
# 4) Usage: > cd <usimm_dir>
# > ./gen_csv.pl -runscript <run script>
#
# Outputs:
# --------
# output/stats.csv
# Final Metric numbers are also printed on Stdout
#
# Other Notes:
# ------------
# 1) Make sure all your single thread bcmks have "$single_thread_time"
# (The times in this gen_csv.pl script represent single thread behavior
# with an FCFS scheduler, and will be the ones used for the MSC)
# 2) $mt includes the programs excluded from the fairness calculations
#-----------------------------------------------------------
use strict;
my %single_thread_time;
# Benchmark Naming convention
# $single_thread_time{<benchmark><Num Channels>}
$single_thread_time{bl1}=318150748;
$single_thread_time{bo1}=293623201;
$single_thread_time{ca1}=465074385;
$single_thread_time{fa1}=404645160;
$single_thread_time{fe1}=379065129;
$single_thread_time{fr1}=305902869;
$single_thread_time{ra1}=319983309;
$single_thread_time{st1}=320441340;
$single_thread_time{vi1}=325420205;
$single_thread_time{x21}=332000385;
$single_thread_time{c11}=372897100;
$single_thread_time{c21}=442948245;
$single_thread_time{fl1}=468052997;
$single_thread_time{sw1}=474243253;
$single_thread_time{c31}=354524613;
$single_thread_time{c41}=316208876;
$single_thread_time{c51}=265660108;
$single_thread_time{fd1}=464442704;
$single_thread_time{fp1}=251305652;
$single_thread_time{ge1}=389291761;
$single_thread_time{hm1}=296911657;
$single_thread_time{lb1}=608302501;
$single_thread_time{le1}=395169481;
$single_thread_time{li1}=611499664;
$single_thread_time{mc1}=614688361;
$single_thread_time{mu1}=628855245;
$single_thread_time{s21}=351731072;
$single_thread_time{ti1}=672025103;
$single_thread_time{bl4}=187992840;
$single_thread_time{bo4}=167672553;
$single_thread_time{ca4}=300787617;
$single_thread_time{fa4}=210337888;
$single_thread_time{fe4}=232711401;
$single_thread_time{fr4}=174316754;
$single_thread_time{ra4}=186816805;
$single_thread_time{st4}=188074168;
$single_thread_time{vi4}=192811301;
$single_thread_time{x24}=197657337;
$single_thread_time{c14}=244419708;
$single_thread_time{c24}=303069945;
$single_thread_time{fl4}=275488665;
$single_thread_time{sw4}=276348929;
$single_thread_time{c34}=218593453;
$single_thread_time{c44}=190803829;
$single_thread_time{c54}=154061128;
$single_thread_time{fd4}=267090041;
$single_thread_time{fp4}=125928705;
$single_thread_time{ge4}=225046893;
$single_thread_time{hm4}=217980413;
$single_thread_time{lb4}=319465145;
$single_thread_time{le4}=390428605;
$single_thread_time{li4}=364135428;
$single_thread_time{mc4}=383824086;
$single_thread_time{mu4}=443990865;
$single_thread_time{s24}=195015969;
$single_thread_time{ti4}=462633387;
# Multi threaded benchmarks and single programmed workloads are being excluded
# from the fairness calculations.
# Slowdown cannot be calculated for these
my %mt;
$mt{MTc} =1;
$mt{c2} =1;
$mt{MTf} =1;
#$mt{MTf4} =1;
#-----------------------------------------------------------
#Get Options
use Getopt::Long;
my ($ret, $help);
my $runscript;
$ret = Getopt::Long::GetOptions (
"runscript|runsim:s" => \$runscript,
"help|h:s" => \$help
) ;
if( !(defined $runscript)) {
print STDERR "Warning: USIMM runscript not specified. Using the default ./runsim\n";
$runscript= "runsim";
print STDERR "Usage: $0 -runscript <run script>\n\n";
}
if (defined $help) {
print STDERR "Usage: $0 -runscript <run script>\n\n";
exit;
}
#-----------------------------------------------------------
# Check if the script is being run in the correct directory
if (! -d "./output") {
die ("ERROR: ./output does not exis.. Exiting");
}
# Check if the runcript exists in the location specified by the user
if (! -e "$runscript") {
die ("ERROR: $runscript does not exis.. Exiting");
}
#-----------------------------------------------------------
# Parse the runscript to get the names of all the output files
# The runscript is assumed to be a shell script where the output
# is dumped using the ">" operatior
# All files generated by the ">" operator in the runscript will be
# assumed to be valid usimm outputs
open (RUNSIM_FH, "<$runscript") or die "Error: Can't open $runscript\n";
# This variable keeps track of the max number of programs in each workload
# This is needed to align the columns in the .csv
my $max_progs=0;
my $line;
#This variable will have all the filenames that will parsed as valid USIMM
#outputs
my @outputs;
while (<RUNSIM_FH>) {
chomp;
$line=$_;
if ($line=~/>/) {
chomp;
$line=~s/.*>\s*//;
$line=~s/.*output.*\///;
$line=~s/.*\///;
$line=~s/&//;
$line=~s/\s+.*//;
$line=~s/"//g;
@outputs[scalar @outputs] = $line;
my @benchmarks= split (/-/,$line);
my $file_len = scalar @benchmarks -1;
$max_progs= $file_len if ($max_progs < $file_len);
}
}
close RUNSIM_FH;
#-----------------------------------------------------------
my $progs=0;
my $sum_time=0;
#my @outputs = ( "c2-1", "c1-c1-1", "bl-bl-fr-fr-1", "c2-4", "st-st-st-st-1", "c1-c1-4", "fa-fa-fe-fe-1", "c1-c1-c2-c2-1", "bl-bl-fr-fr-4", "st-st-st-st-4", "c1-c1-c2-c2-4", "fa-fa-fe-fe-4", "MTc-1", "MTc-4", "fl-sw-c2-c2-1", "fl-sw-c2-c2-4", "fl-fl-sw-sw-c2-c2-fe-fe-4", "fl-fl-sw-sw-c2-c2-fe-fe-bl-bl-fr-fr-c1-c1-st-st-4" );
# This is the file where the output will be writted to in the output directory
my $out_file = "stats.csv";
print "INFO: Writing output to output/$out_file\n";
open (OUT_FH, ">output/$out_file") or die "Error: Can't open output/$out_file\n";
print OUT_FH "Workload, Sum of Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,Execution Time,,Max SlowDown, MinSlowDown, SlowDown, SlowDown, SlowDown, SlowDown, SlowDown, SlowDown, SlowDown, SlowDown, SlowDown, SlowDown, SlowDown, SlowDown, SlowDown, SlowDown, SlowDown, SlowDown...\n";
my $infile;
my %bcmk;
my %time;
my %slowdown;
my %max_slowdown;
my %min_slowdown;
my $total_execution_time=0;
my $pfp_total_execution_time=0;
my %edp;
my $total_edp=0;
my $i;
# Start reading USIMM output files
foreach $infile (@outputs) {
print "INFO: Openeing file output/$infile ";
open (IN_FH, "<output/$infile") or die "Error: Can't open output/$infile ";
#Core Num
my $n=0;
my $file_name;
$infile =~s/_.*//;
$file_name = $infile;
$file_name =~s/-(\d+).*//;
my $current_channel= $1;
my @bcmks= split ("-", $file_name);
while (<IN_FH>) {
chomp;
$line= $_;
if ($line =~/^Done: Core/) {
#time {inFile} {core}
$time{$infile}{$n} = $line;
$time{$infile}{$n} =~s/.* //;
$total_execution_time += $time{$infile}{$n};
$pfp_total_execution_time += $time{$infile}{$n} if (!exists $mt{$file_name});
$bcmk{$infile}{$n} = $bcmks[$n];
# If filename exists in the $mt hash, then it is multi-threaded and will not have a
# single threaded exec time
if (!exists $mt{$file_name}) {
my $single_thread_key= "$bcmks[$n]"."$current_channel";
if (exists $single_thread_time{$single_thread_key}) {
$slowdown{$infile}{$n} = $time{$infile}{$n}/$single_thread_time{$single_thread_key};
} else {
die "ERROR: single_thread_time{$single_thread_key} does not exist n=$n file_name=$file_name ... Exiting";
}
} else {
# SLowdown is marked negative to mark invalid
# This condition is checked each time $slowdown is used
$slowdown{$infile}{$n} = -1;
}
# Find max slowdown
if (! exists $max_slowdown{$infile}) {
if ($slowdown{$infile}{$n} > 0) {
$max_slowdown{$infile} = $slowdown{$infile}{$n};
} else {
$max_slowdown{$infile} = 0;
}
} elsif ($max_slowdown{$infile} < $slowdown{$infile}{$n} ){
$max_slowdown{$infile} = $slowdown{$infile}{$n};
}
if (! exists $min_slowdown{$infile}) {
if ($slowdown{$infile}{$n} > 0) {
$min_slowdown{$infile} = $slowdown{$infile}{$n};
} else {
$min_slowdown{$infile} = 0;
}
} elsif ($min_slowdown{$infile} > $slowdown{$infile}{$n} ){
$min_slowdown{$infile} = $slowdown{$infile}{$n};
}
$n++;
} elsif ($line =~/Energy Delay product \(EDP\) = (\S+) J.s/) {
$edp{$infile} = $1;
$total_edp += $1;
}
}
#print " - MAX SLOWDOWN: $max_slowdown{$infile} , MIN SLOWDOWN: $min_slowdown{$infile}\n";
close IN_FH;
}
my $n=0;
my $total_max_slowdown=0;
my $l_slowdown=0;
my $avg_max_slowdown;
my $workload;
my $core;
my $num_non_mt_workload=0;
$n=0;
# The completion time of MultiThreaded workloads is not considered while
# calculating the PFP metrics
foreach $workload (sort keys %slowdown) {
$n++;
my $threads= $workload;
printf "THREADS= $threads\n";
$threads=~s/-\d+$//;
if ( ! exists $mt{$threads}) {
$num_non_mt_workload++ ;
}
$total_max_slowdown+=$max_slowdown{$workload} ;
}
$avg_max_slowdown = $total_max_slowdown/$n;
my $pfp_avg_max_slowdown = $total_max_slowdown/$num_non_mt_workload;
my $pfp = $pfp_total_execution_time * $pfp_avg_max_slowdown;
#Start Generating the csv file:
foreach $workload (sort keys %time) {
$progs=0;
$sum_time=0;
print OUT_FH "$workload";
foreach $core (sort {$a<=> $b} keys %{$time{$workload}}){
$sum_time += $time{$workload}{$core};
}
print OUT_FH ",$sum_time";
foreach $core (sort {$a<=> $b} keys %{$time{$workload}}){
print OUT_FH ",$time{$workload}{$core}";
$progs++;
}
for ($i=$progs; $i<= $max_progs; $i++) {
print OUT_FH ",";
}
print OUT_FH ",$max_slowdown{$workload}";
print OUT_FH ",$min_slowdown{$workload}";
$progs=0;
foreach $core (sort {$a<=> $b} keys %{$time{$workload}}){
if ($slowdown{$workload}{$core} > 0) {
print OUT_FH ",$slowdown{$workload}{$core}";
} else {
print OUT_FH ",";
}
$progs++;
}
for ($i=$progs; $i<= $max_progs; $i++) {
print OUT_FH ",";
}
print OUT_FH "\n";
}
print OUT_FH "\n\nTotal Exection Time, $total_execution_time\n";
print OUT_FH "PFP Avg Max Slowdown, $pfp_avg_max_slowdown\n";
print OUT_FH "PFP, $pfp\n\n\n";
#Print the EDP stats into the CSV
print OUT_FH "Work Load, EDP\n";
foreach $workload (sort keys %edp) {
print OUT_FH "$workload, $edp{$workload}\n";
}
print OUT_FH "Total, $total_edp\n";
print "#----------------------------------------------\n";
print "Total_execution_time = $total_execution_time\n";
print "PFP Total_execution_time = $pfp_total_execution_time\n";
print "PFP = $pfp\n";
print "PFP Average Max Slowdown = $pfp_avg_max_slowdown\n";
print "Total EDP = $total_edp\n";
print "#----------------------------------------------\n";
close OUT_FH;