Skip to content

Instantly share code, notes, and snippets.

@jamiely
Created December 5, 2010 19:26
Show Gist options
  • Save jamiely/729377 to your computer and use it in GitHub Desktop.
Save jamiely/729377 to your computer and use it in GitHub Desktop.
A file to run all the Wattch experiments.
#!/bin/bash
# runs a single experiment
base=$1
commandstring=$2
echo "Operating on file ${1} ${base}"
sim_opts=" -fastfwd 1000000 -max:inst 10000000 "
xor=1 # whether to xor the history with the PC
mkdir output/$base
rm -rf output/$base/*
echo "Benchmark ${base}";
# taken and nottaken have the same config
for bpred in nottaken taken perfect
do
# what's going on?
echo "file=${base} bpred=${bpred}"
filebase=$bpred.$base
pathbase="output/${base}/${filebase}"
full_command_string="time sim-outorder ${sim_opts} -redir:sim ${pathbase}.simout -bpred $bpred \
$commandstring > ${pathbase}.stdout"
eval $full_command_string
done
# bimodal predictor only requires table size in bytes
bpred="bimod"
for table_size_logbytes in {1..10} # powers of 2
do
# what's going on?
echo "file=${base} bpred=${bpred} bimod=${table_size_logbytes}"
filebase=$bpred.$base.$table_size_logbytes
pathbase="output/${base}/${filebase}"
let "table_size_bytes=2**${table_size_logbytes}"
full_command_string="time sim-outorder ${sim_opts} -redir:sim ${pathbase}.simout -bpred $bpred -bpred:bimod ${table_size_bytes} $commandstring > ${pathbase}.stdout"
eval $full_command_string
done
# 2level predictor
bpred="2lev"
for table_size_logbytes in 1 2 4 8 16 # powers of 2
do
# what's going on?
echo "file=${base} bpred=${bpred} gshare=${table_size_logbytes}"
filebase=$bpred.$base.$table_size_logbytes
pathbase="output/${base}/${filebase}"
# according to the README, these settings result in gshare type func
let "table_size_bytes=2**${table_size_logbytes}" # will be history size
full_command_string="time sim-outorder ${sim_opts} -redir:sim ${pathbase}.simout -bpred $bpred -bpred:2lev 1 ${table_size_logbytes} ${table_size_bytes} ${xor} $commandstring > ${pathbase}.stdout"
eval $full_command_string
done
bpred="comb"
for combo_size_logbytes in {5..10} # powers of 2
do
let "combo_size_bytes=2**${combo_size_logbytes}"
for table_size_logbytes in 1 2 4 8 # powers of 2
do
# bimodal table size
let "table_size_bytes=2**${table_size_logbytes}"
for gshare_size_logbytes in 1 2 4 8 # powers of 2
do
# what's going on?
echo "file=${base} bpred=${bpred} combo=${combo_size_logbytes} bimod=${table_size_logbytes} gshare=${gshare_size_logbytes}"
# according to the README, these settings result in gshare type func
let "history_size_bytes=2**${gshare_size_logbytes}" # will be history size
filebase=$bpred.$base.$combo_size_logbytes.$table_size_logbytes.$gshare_size_logbytes
pathbase="output/${base}/${filebase}"
full_command_string="time sim-outorder ${sim_opts} -redir:sim ${pathbase}.simout -bpred $bpred -bpred:comb ${combo_size_bytes} -bpred:bimod ${table_size_bytes} -bpred:2lev 1 ${gshare_size_logbytes} ${history_size_bytes} ${xor} $commandstring > ${pathbase}.stdout"
eval $full_command_string
done
done
done
# report statistics
awk -v OFS=',' '/^(((max|avg|total)_)?bpred|sim_|avg_total_|total_)/ {print FILENAME,$1,$2}' output/$base/*.simout > output/$base.csv
# transposes the file
BEGIN {FS=","}
{
for (i=1;i<=NF;i++)
{
arr[NR,i]=$i;
if(big <= NF)
big=NF;
}
}
END {
for(i=1;i<=big;i++)
{
for(j=1;j<=NR;j++)
{
printf("%s,",arr[j,i]);
}
printf("\n");
}
}
# remove all the csvs in the output dir
rm output/*.csv
for bpred in nottaken taken perfect bimod 2lev comb
do
let i=0
for file in `find output | grep ${bpred}.*\.simout$`
do
echo "Processing $file"
path=${file%/*}
# To get: /tmp/my.dir (like dirname)
filename=${file##*/}
# To get: filename.tar.gz (like basename)
base=${filename%%.*}
#To get: filename
ext=${filename#*.}
parts=`echo $filename | awk -F'.' '{for(i=1;i<=NF;i++) printf("%s,", $i); printf("\n")}'`
if [ $i -eq 0 ]
then
# this is just to get the headers field names into the file
awk -v OFS=',' '/^(((max|avg|total)_)?bpred|sim_|avg_total_|total_)/ {print $1,$2}' $file | \
sort | \
awk -f experiment_output.awk | \
head -1 | \
sed "s/^/filename,${parts}/" \
>> output/all.$bpred.csv
fi
# transpose each file
awk -v OFS=',' '/^(((max|avg|total)_)?bpred|sim_|avg_total_|total_)/ {print $1,$2}' $file | \
sort | \
awk -f experiment_output.awk | \
sed -e '1d;n;d' | \
sed "s/^/${filename},${parts}/" \
>> output/all.$bpred.csv
let i=i+1
done
done
#!/bin/bash
# runs all the experiments
./experiment.sh "anagram" "benchmarks/anagram.alpha benchmarks/words < benchmarks/anagram.in"
./experiment.sh "cc1" "benchmarks/cc1.alpha -O benchmarks/1stmt.i"
# not correct?
./experiment.sh "compress95" "benchmarks/compress95.alpha < benchmarks/c95.in2"
./experiment.sh "go" "benchmarks/go.alpha 50 9 benchmarks/2stone9.in"
# no example present
# ./experiment.sh "perl" "benchmarks/perl.alpha"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment