emSum.prl
10.4 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
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
#!/usr/local/bin/perl5
#
# Copyright (C) 1996-1998 by the Board of Trustees
# of Leland Stanford Junior University.
#
# This file is part of the SimOS distribution.
# See LICENSE file for terms of the license.
#
unshift(@INC, "/morse/m4/witchel/bin/");
unshift(@INC, "/morse/m4/witchel/bin/Stats");
unshift(@INC, "/morse/m4/witchel/bin/Stats/Basic.pm");
require "Basic.pm";
#use Stats::Basic;
@Modes = ('K', 'U', 'I', 'S', 'T');
require "getopts.pl";
&Getopts('cl');
# -c for consistency output check
# -l for long output (stat breakdown)
$inputFile = shift;
if( !defined $inputFile ) {
$inputFile = "cpu.log";
}
$mipsInfo = Stats::Basic->new;
$transInfo = Stats::Basic->new;
$clkInfo = Stats::Basic->new;
# Page Mode
$mmuMissInfo = Stats::Basic->new;
open(LOG, $inputFile) || die "Failed to open $inputFile $.\n";
while(<LOG>){
if(/^CONFIG EmPCSample\s+(\d+)/) {
$pcSampleRate = $1;
}
if(/^CONFIG EmStatInterval\s+(\d+)/) {
$emStatInterval = $1;
}
if(/^CONFIG NumCPUs\s+(\d+)/) {
$numCPUs = $1;
}
if(/^CONFIG CpuClock\s+(\d+)/) {
$cpuClock = $1;
}
if(/^CONFIG MemCycleTime\s+(\d+)/) {
if( !defined $cpuClock ) {
die "Need CpuClock before MemCycleTime\n";
}
$memCycleTime = $1 * $cpuClock / 1000;
}
if(/^CONFIG SCacheLineSize\s+(\d+)/) {
$sCacheLineSize = $1;
}
if(/Usec (\d+)/) {
if( !defined $startUsec ) { $startUsec = $1; }
$cur{'usec'} = $1;
}
# Get a notion of simulated time
if(/^EM_CPU 0 Cycle (\d+)/) {
$cur{'cycleCount'} = $1 * $numCPUs;
}
# This occurs in cache mode not page mode
if(/^EM_CS_(\w)/) {
($label, $pcSamples{$1}, $dStall{$1}, $iStall{$1}, $iCount{$1},
$iMiss{$1}, $dRefs{$1}, $dMiss{$1}, $upgrades{$1} ) = split;
$cur{'pcSamples'} += $pcSamples{$1};
}
if(/^EM_PCTC/){
$cur{'pctcLine'} = $_;
}
# This occurs in page mode, not cache mode
if(/^EM_MMU/){
$pageMode = 1;
split;
$cur{'mmuSMissCount'} = $_[3];
$cur{'mmuXMissCount'} = $_[4];
}
if(/^EM_QC/){
$cur{'emqcLine'} = $_;
}
if(/^EM_C0/){
split;
$cur{'clkCount'} = $_[4];
$cur{'exc_int'} = $_[6];
$cur{'exc_mod'} = $_[8];
($ker, $user) = split(/\//, $_[10]);
$cur{'exc_rmiss'} = $ker + $user;
($ker, $user) = split(/\//, $_[12]);
$cur{'exc_wmiss'} = $ker + $user;
$cur{'exc_syscall'} = $_[14];
}
if(/^EM_T Tran ([0-9\.]+)s/) {
$cur{'transTime'} = $1;
}
if(/^EM_B.*Bdr ([0-9\.]+)r/) {
$bdAccesses = $1;
}
if(/^EmbraRunTime\s*([0-9\.]+) sec/) {
$realSec = $1;
$realMin = $1/60;
}
# End Frame
if(/^EM_X/) {
$mmuMissInfo->AddData(
100*(($cur{'mmuSMissCount'} + $cur{'mmuXMissCount'}) -
($prev{'mmuSMissCount'} + $prev{'mmuXMissCount'}))/
($cur{'cycleCount'} - $prev{'cycleCount'} ));
$prev{'mmuSMissCount'} = $cur{'mmuSMissCount'};
$prev{'mmuXMissCount'} = $cur{'mmuXMissCount'};
if( $pageMode ) {
$mipsInfo->AddData( ($cur{'cycleCount'} - $prev{'cycleCount'})/
( $cur{'usec'} - $prev{'usec'} ) );
$prev{'cycleCount'} = $cur{'cycleCount'};
} else {
$mipsInfo->AddData( $pcSampleRate *
($cur{'pcSamples'} - $prev{'pcSamples'}) /
( $cur{'usec'} - $prev{'usec'} ) );
$prev{'pcSamples'} = $cur{'pcSamples'};
$cur{'pcSamples'} = 0;
}
$transInfo->AddData( $cur{'transTime'} - $prev{'transTime'} );
$prev{'transTime'} = $cur{'transTime'};
$clkInfo->AddData( $cur{'clkCount'} - $prev{'clkCount'} );
$prev{'clkCount'} = $cur{'clkCount'};
$prev{'usec'} = $cur{'usec'};
}
}
if( !$realMin ) {
$realMin = ($cur{'usec'} - $startUsec)/(1000*1000*60);
}
$simSec = $cur{'cycleCount'}/($numCPUs * $cpuClock * 1000 * 1000);
if( $simSec ) {
printf("Real %d sec %.2f min\nSim %.2f sec\nSlowdown %.2fx %.2fx/proc\n",
$realSec, $realMin, $simSec, ($realMin * 60)/$simSec,
($realMin*60)/($simSec*$numCPUs) );
} else {
print "Real $realSec sec $realMin min\n";
}
@mipsStats = ("Min", "Max", "Median", "Mean", "SD", "Coeff");
if( $opt_l ) {
print join("\t", @mipsStats), "\n";
}
printf "MIPS AVG %.2f\n",
$cur{'cycleCount'}/($cur{'usec'} - $startUsec);
if( $opt_l ) {
printf("%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.3f\n",
$mipsInfo->Min,
$mipsInfo->Max,
$mipsInfo->Median,
$mipsInfo->Mean,
$mipsInfo->StandardDeviation,
$mipsInfo->CoefficientOfVariance );
}
printf "TRANSLATION TIME (s) %d sec %.2f%% of total time\n",
$cur{'transTime'},
100*1000*1000*$cur{'transTime'}/($cur{'usec'} - $startUsec);
if( $opt_l ) {
printf("%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.3f\n",
$transInfo->Min,
$transInfo->Max,
$transInfo->Median,
$transInfo->Mean,
$transInfo->StandardDeviation,
$transInfo->CoefficientOfVariance );
}
# Time divided by simulated time
printf "CLK RATE (count) AVG slowdown %.2f\n",
$numCPUs * ($cur{'usec'} - $startUsec)/($cur{'clkCount'} * 10 * 1000);
if( $opt_l ) {
printf("%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.3f\n",
$clkInfo->Min,
$clkInfo->Max,
$clkInfo->Median,
$clkInfo->Mean,
$clkInfo->StandardDeviation,
$clkInfo->CoefficientOfVariance );
}
# Time divided by simulated time
if( $pageMode ) {
printf "MMU Misses (rate) AVG %.2f%% SHARED %.2f%% EXCL %.2f%%\n",
100*($cur{'mmuSMissCount'} + $cur{'mmuXMissCount'})/$cur{'cycleCount'},
100*$cur{'mmuSMissCount'}/($cur{'mmuSMissCount'} + $cur{'mmuXMissCount'}),
100*$cur{'mmuXMissCount'}/($cur{'mmuSMissCount'} + $cur{'mmuXMissCount'});
if( $opt_l ) {
printf("%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.3f\n",
$mmuMissInfo->Min,
$mmuMissInfo->Max,
$mmuMissInfo->Median,
$mmuMissInfo->Mean,
$mmuMissInfo->StandardDeviation,
$mmuMissInfo->CoefficientOfVariance );
}
} else {
split(/[ \n\t]+/, $cur{'emqcLine'});
$totdRefs = 0;
$totiCount = 0;
foreach $mode (@Modes) {
$totdRefs += $dRefs{$mode};
$totiCount += $iCount{$mode};
}
#100*($_[2] + $_[3] + $_[4])/$cur{'cycleCount'},
# printf("VQC Miss %.2f-%.2f%%I %.2f%%D %.2f%%B INSTR %.2f%% SHARED %.2f%% EXCL %.2f%%\n",
# 100*$_[2]/$totiCount, 100*$_[2]/($totiCount/($sCacheLineSize/4)),
# 100*($_[3] + $_[4])/$totdRefs,
# 100*$bdAccesses/($_[2] + $_[3] + $_[4]),
# 100*$_[2]/($_[2] + $_[3] + $_[4]),
# 100*$_[3]/($_[2] + $_[3] + $_[4]),
# 100*$_[4]/($_[2] + $_[3] + $_[4]) );
# printf("PQC Miss %.2f%% INSTR %.2f%% SHARED %.2f%% EXCL %.2f%%\n",
# 100*($_[5] + $_[6] + $_[7])/($_[2] + $_[3] + $_[4]),
# 100*$_[5]/$_[2],
# 100*$_[6]/$_[3],
# 100*$_[7]/$_[4] );
if( $opt_c ) {
print("Cache Sanity:\n");
} else {
print("Cache Stats:\n");
}
foreach $mode (@Modes) {
print "Mode $mode\n";
if( $mode ne 'T' ) {
$dStall{'T'} += $dStall{$mode};
$iStall{'T'} += $iStall{$mode};
$dMiss{'T'} += $dMiss{$mode};
$iMiss{'T'} += $iMiss{$mode};
$iCount{'T'} += $iCount{$mode};
$pcSamples{'T'} += $pcSamples{$mode};
$upgrades{'T'} += $upgrades{$mode};
}
$countCycles = $iCount{$mode} + $iStall{$mode} + $dStall{$mode};
$sampCycles = $pcSamples{$mode} * $pcSampleRate;
if( $opt_c ) {
printf("dStall %10d dMiss * memCycleTime %10d Diff %.2f%%\n",
$dStall{$mode},
$dMiss{$mode} * $memCycleTime,
$dStall{$mode} ?
100*($dStall{$mode} -
($dMiss{$mode}*$memCycleTime))/$dStall{$mode} :
0 );
printf("iStall %10d iMiss * memCycleTime %10d Diff %.2f%%\n",
$iStall{$mode},
$iMiss{$mode} * $memCycleTime,
$iStall{$mode} ?
100*($iStall{$mode} -
($iMiss{$mode} * $memCycleTime))/$iStall{$mode} :
0 );
print "Cycles: ",
$countCycles,
" measured ",
$sampCycles;
printf(" sampled Diff %.2f%%\n",
$countCycles ?
100*( $countCycles - $sampCycles )/$countCycles :
0 );
} else {
print (($pcSamples{$mode} * $pcSampleRate) /
($cpuClock * 1000 * 1000 ));
print " sec (sim) $iCount{$mode} instr\n";
print "dMisses $dMiss{$mode} iMisses $iMiss{$mode} Upgrades $upgrades{$mode}\n";
print "TotalMiss ";
print $dMiss{$mode} + $iMiss{$mode};
print " countCycles $countCycles sampCycles $sampCycles\n";
}
}
}
print ("INT $cur{'exc_int'} MOD $cur{'exc_mod'} RMISS $cur{'exc_rmiss'} WMISS $cur{'exc_wmiss'} SYSCALL $cur{'exc_syscall'} ~CLK $cur{'clkCount'}\n");
print $cur{'pctcLine'};
__END__
print (($pcSamples{$mode} * $pcSampleRate) /
($cpuClock * 1000 * 1000 ));
print " sec (sim) $iCount{$mode} instr\n";
print "dMisses $dMiss{$mode} dMissStall ";
print $dMiss{$mode} * $memCycleTime;
print " dStall $dStall{$mode} Upgrades $upgrades{$mode}\n";
print "iMisses $iMiss{$mode} iMissStall ";
print $iMiss{$mode} * $memCycleTime;
print " iStall $iStall{$mode}\n";
print "countCycles $countCycles sampCycles $sampCycles\n";
EM_CPU 0 Cycle 33556000 PC 0x6010172c RA 0x60014120 Proc
EM_T Tran 8.114s/59843b/209697i TC 43t/1i/41k/0f
EM_C0 EXC 10716 INT 554 MOD 493 RMISS 1867/4684 WMISS 557/603 SYS 1936
EM_MMU (i/s/x) 0 3780765 5368383
EM_PCTC(in/ct/lk/bdr)(lk/ms) 40176 0.032% 369366 16.200% 5.318% 56543 81.503%
EM_QC V/P(i/s/x) 1690774 5250032 972072 587481 4661381 642263