perfex.pl
3.3 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
#!/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.
#
#
# Parse the output of the "perfex" command.
#
# Steve Herrod
if (($#ARGV+1) < 1) {
die "Usage: $0 <file>\n";
}
$FILENAME = shift(@ARGV);
open(FILE, $FILENAME) || die "Can't open $FILENAME: $!\n";
while (<FILE>) {
if (/ 0 Cycles......................................................\s+(\d+)*/) {
$cycleCount = $1;
}
if (/^ 6 Decoded branches............................................\s+(\d+)*/) {
$branchCount = $1;
}
if (/^ 9 Primary instruction cache misses............................\s+(\d+)*/) {
$pIMisses = $1;
}
if (/^10 Secondary instruction cache misses..........................\s+(\d+)*/) {
$sIMisses = $1;
}
if (/^15 Graduated instructions......................................\s+(\d+)*/) {
$instCount = $1;
}
if (/^18 Graduated loads.............................................\s+(\d+)*/) {
$loadCount = $1;
}
if (/^19 Graduated stores............................................\s+(\d+)*/) {
$storeCount = $1;
}
if (/^21 Graduated floating point instructions.......................\s+(\d+)*/) {
$fpInstCount = $1;
}
if (/^23 TLB misses..................................................\s+(\d+)*/) {
$tlbCount = $1;
}
if (/^24 Mispredicted branches.......................................\s+(\d+)*/) {
$mispredictedBranches = $1;
}
if (/^25 Primary data cache misses...................................\s+(\d+)*/) {
$pDMisses = $1;
}
if (/^26 Secondary data cache misses.................................\s+(\d+)*/) {
$sDMisses = $1;
}
}
$totalDRefs = $loadCount + $storeCount;
$totalIRefs = $instCount;
$totalRefs = $totalDRefs + $totalIRefs;
$sMisses = $sDMisses + $sIMisses;
&DO_HEADER_INFO();
&DO_SUMMARY_STATS();
exit(0);
#################################################################
# Procedures that manipulate and print the scanned in numbers
#################################################################
sub numerically { $a <=> $b;}
sub div {
my $x = shift;
my $y = shift;
if ($y == 0) {
return 0.0;
} else {
return $x/$y;
}
}
sub DO_HEADER_INFO {
printf("****************************\n");
printf("* PERFEX SIMULATION RESULTS *\n");
printf("****************************\n\n");
}
sub DO_SUMMARY_STATS {
printf("Total Instructions: %12.0lf\n", $instCount);
printf("(Floating Point): %12.0lf\n", $fpInstCount);
printf("Total Cycles: %12.0lf (%d seconds)\n", $cycleCount,
$cycleCount * .000000005);
printf("CPI: %12.2lf\n", &div($cycleCount, $instCount));
printf("Data Cache Miss: %12.2lf %%\n", 100.0 * &div($pDMisses, $totalDRefs));
printf("Inst Cache Miss: %12.2lf %%\n", 100.0 * &div($pIMisses, $totalIRefs));
printf("L2 Cache Miss: %12.2lf %%\n", 100.0 * &div($sMisses, $totalRefs));
printf("Branch prediction: %12.2lf %%\n",
100.0 * &div($mispredictedBranches, $branchCount));
printf("TLB Miss every: %12.0lf cycles\n", &div($cycleCount, $tlbCount));
}