. Like Hypnos said, that script doesn't yet indicate what options were added to -O2 and -O3 in 3.4 but I did make some changes and now it should.(I took them from the 3.4 config scripts)
Code: Select all
#!/usr/bin/env perl
#----------------------------------------------------------------------------
#
# Settings
#
# Names of benchmarks run by Acovea
@benches = ("alma", "evo", "fft", "huff", "lin", "mat1", "tree");
# Number of populations evolved per benchmark by Acovea
$pops = 5;
# Population size
$popsize = 40;
# Number of generations of evolution by Acovea
$gens = 20;
# Suppress output of statistical mumbo-jumbo?
$suppress = "1";
#----------------------------------------------------------------------------
#
# Digest data from *.run files
#
@switches = ();
$listflag = "";
foreach $bench (@benches) {
open(BENCHRUN, "$bench.run");
$genflag = "";
$countflag = "";
$blankflag = "";
$linecount = 0;
while (<BENCHRUN>) {
# Look for final iteration
if(/^iteration $gens/) {$genflag = "1"; next;}
# Look for start of option counts table
if($genflag && /^Option counts:/) {$countflag = "1"; next;}
# Look for end of option counts table (blank line)
if($genflag && $countflag && /^$/) {$blankflag = "1"; next;}
# Parse counts lines
if($genflag && $countflag && (! $blankflag)) {
# first bench
s/\n$//;
if($listflag) {
s/(^\s*?-\S+?\s+?)(\S)/$2/;
s/\s+/ /g;
s/\s$//;
my @line2 = split(/\s/);
$ref2 = $switches[$linecount];
push @$ref2, @line2;
}
# subsequent benches
else {
s/^\s*?-/-/;
s/\s+/ /g;
s/\s$//;
my @line = split(/\s/);
$ref= \@line;
@switches = (@switches, $ref);
}
$linecount += 1;
}
}
$listflag = "1";
}
#----------------------------------------------------------------------------
#
# Calculate mean (total/bench), standard deviation, confidence interval,
# and score for each switch across all the benchmarks
#
#
# Implementation of erf()
# (continuing fraction by Laplace, Legendre, Ramanujan)
#
$pi = 3.14159;
sub erffrac {
my($x, $count, $max) = @_;
if ($count > $max) {1;}
else{
if ($count % 2 == 0) {$a = 2;}
else {$a = 1;}
$a*$x+$count/&erffrac($x, $count + 1, $max);
};
}
sub erf {
my($x) = @_ ;
1-exp(-$x**2)/sqrt($pi)/&erffrac($x, 1, 10.*(1 + 1/$x));
}
#
# End implementation of erf()
#
@tswitches = ();
foreach $line (@switches) {
# Mean
$col = 1 + $pops;
$total = 0;
@line2 = @$line;
while ($col < $#line2 + 1) {
$total += $line2[$col];
$col += 1 + $pops ;
}
$mean = $total/$#benches;
# Standard deviation
$col = 1 + $pops;
$total = 0;
while ($col < $#line2 + 1) {
$total += ($line2[$col] - $mean)**2;
$col += 1 + $pops ;
}
$stddev = sqrt($total)/$pops/$popsize;
$mean = $mean/$pops/$popsize; # renormalize
# Confidence interval
$x=$mean/$stddev/sqrt(2); # cum. prob. = erf(n/sqrt(2))
# Gaussian approximation to Poisson distribution only works
# for counts >= 5 (or so)
if ($mean < 5/$popsize) {$confidence = 0.;}
else {$confidence = &erf($x);}
# score
$score = $mean * $confidence * 100;
# Store data
my @foo = ($line2[0], $mean, $stddev, $confidence, $score);
push @tswitches, \@foo;
}
#----------------------------------------------------------------------------
#
# Sort by score
#
sub byScore {
$b2 = $b; $a2 = $a;
@b3 = @$b2; @a3 = @$a2;
$b4 = @b3[4]; $a4 = @a3[4];
$b4 <=> $a4;
}
@sswitches = sort byScore @tswitches;
#----------------------------------------------------------------------------
#
# Set up annotation hash (GCC 3.3.x)
#
%annhash = ("-fno-merge-constants", "! -O1", "-fno-defer-pop", "! -O1", "-fno-thread-jumps", "! -O1", "-fno-omit-frame-pointer", "! -O1", "-fno-guess-branch-probability", "! -O1", "-fno-cprop-registers", "! -O1", "-fno-if-conversion", "! -O1", "-fno-if-conversion2", "! -O1", "-fno-delayed-branch", "! -O1", "-fno-loop-optimize", "! -O1", "-fno-crossjumping", "! -O1", "-foptimize-sibling-calls", "-O2", "-fcse-follow-jumps", "-O2", "-fcse-skip-blocks", "-O2", "-fgcse", "-O2", "-fexpensive-optimizations", "-O2", "-fstrength-reduce", "-O2", "-frerun-cse-after-loop", "-O2", "-frerun-loop-opt", "-O2", "-fcaller-saves", "-O2", "-fforce-mem", "-O2", "-fpeephole2", "-O2", "-fschedule-insns", "-O2", "-fschedule-insns2", "-O2", "-fregmove", "-O2", "-fstrict-aliasing", "-O2", "-fdelete-null-pointer-checks", "-O2", "-freorder-blocks", "-O2", "-fsched-interblock", "-O2 GCC 3.3", "-fsched-spec", "-O2 GCC 3.3", "-freorder-functions", "-O2 GCC 3.3", "-falign-loops", "-O2 GCC 3.3", "-falign-jumps", "-O2 GCC 3.3", "-falign-labels", "-O2 GCC 3.3", "-finline-functions", "-O3", "-frename-registers", "-O3", "-ffloat-store", "", "-fprefetch-loop-arrays", "", "-fmove-all-movables", "", "-freduce-all-givs", "", "-fno-inline", "", "-ftracer", "", "-fnew-ra", "", "-funroll-loops", "", "-funroll-all-loops", "", "-mieee-fp", "", "-malign-double", "", "-mno-push-args", "", "-maccumulate-outgoing-args", "", "-mno-align-stringops", "", "-minline-all-stringops", "", "-mfpmath=387", "", "-mfpmath=sse", "", "-mfpmath=sse,387", "", "-fomit-frame-pointer", "", "-momit-leaf-frame-pointer", "", "-fno-math-errno", "fast math", "-funsafe-math-optimizations", "fast math", "-fno-trapping-math", "fast math", "-ffinite-math-only", "fast math", "-fno-signaling-nans", "fast math", "-finline-limit", "" , "-fweb" , "-O3 GCC 3.4", "-funit-at-a-time", "-O2 GCC 3.4", "-falign-functions", "-O2 GCC 3.4");
#----------------------------------------------------------------------------
#
# Display results
#
sub printbar {
print "------------------------------------------------------------------------------\n";
}
if (not $suppress) {print " Mean | Std. Dev. | Conf. |";}
print " Score | So? | Switch (annotation)\n";
&printbar;
foreach $line (@sswitches) {
if (not $suppress) {
print sprintf(" %5.3f",@$line[1]);
print " | ";
print sprintf(" %5.3f ",@$line[2]);
print " | ";
print sprintf("%5.3f", @$line[3]);
print " |";
}
print " ";
print sprintf(" %4.1f", @$line[4]);
print " | ";
# Recommend based on confidence
if (@$line[3] < 0.683) {print " No ";}
elsif (@$line[3] < 0.866) {print "Maybe";}
else {print " Yes ";}
print " | ";
print @$line[0];
if ($annhash{@$line[0]}) {print " (".$annhash{@$line[0]}.")";}
print "\n";
}