2015-02-21 02:20:34 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-02-26 23:12:58 +08:00
|
|
|
# Examples of environment variables to be set:
|
|
|
|
# PREFIX="haswell-fma-"
|
|
|
|
# CXX_FLAGS="-mfma"
|
|
|
|
|
|
|
|
# Options:
|
|
|
|
# -up : enforce the recomputation of existing data, and keep best results as a merging strategy
|
2015-03-06 18:47:13 +08:00
|
|
|
# -s : recompute selected changesets only and keep bests
|
2015-02-26 23:12:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
if echo "$*" | grep '\-up' > /dev/null; then
|
|
|
|
update=true
|
|
|
|
else
|
|
|
|
update=false
|
|
|
|
fi
|
|
|
|
|
2015-03-06 18:47:13 +08:00
|
|
|
if echo "$*" | grep '\-s' > /dev/null; then
|
|
|
|
selected=true
|
|
|
|
else
|
|
|
|
selected=false
|
|
|
|
fi
|
|
|
|
|
|
|
|
global_args="$*"
|
|
|
|
|
|
|
|
if [ $selected == true ]; then
|
|
|
|
echo "Recompute selected changesets only and keep bests"
|
|
|
|
elif [ $update == true ]; then
|
2015-02-26 23:12:58 +08:00
|
|
|
echo "(Re-)Compute all changesets and keep bests"
|
|
|
|
else
|
|
|
|
echo "Skip previously computed changesets"
|
|
|
|
fi
|
|
|
|
|
2015-03-06 18:47:13 +08:00
|
|
|
|
|
|
|
|
2015-02-21 02:20:34 +08:00
|
|
|
if [ ! -d "eigen_src" ]; then
|
|
|
|
hg clone https://bitbucket.org/eigen/eigen eigen_src
|
2015-03-06 18:47:13 +08:00
|
|
|
else
|
|
|
|
cd eigen_src
|
|
|
|
hg pull -u
|
|
|
|
cd ..
|
2015-02-21 02:20:34 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z '$CXX' ]; then
|
|
|
|
CXX=g++
|
|
|
|
fi
|
|
|
|
|
2015-02-26 23:12:58 +08:00
|
|
|
function make_backup
|
|
|
|
{
|
|
|
|
if [ -f "$1.out" ]; then
|
|
|
|
mv "$1.out" "$1.backup"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function merge
|
|
|
|
{
|
|
|
|
count1=`echo $1 | wc -w`
|
|
|
|
count2=`echo $2 | wc -w`
|
|
|
|
|
|
|
|
if [ $count1 == $count2 ]; then
|
|
|
|
a=( $1 ); b=( $2 )
|
|
|
|
res=""
|
|
|
|
for (( i=0 ; i<$count1 ; i++ )); do
|
|
|
|
ai=${a[$i]}; bi=${b[$i]}
|
|
|
|
tmp=`echo "if ($ai > $bi) $ai else $bi " | bc -l`
|
|
|
|
res="$res $tmp"
|
|
|
|
done
|
|
|
|
echo $res
|
|
|
|
|
|
|
|
else
|
|
|
|
echo $1
|
|
|
|
fi
|
|
|
|
}
|
2015-02-21 02:20:34 +08:00
|
|
|
|
|
|
|
function test_current
|
|
|
|
{
|
|
|
|
rev=$1
|
|
|
|
scalar=$2
|
|
|
|
name=$3
|
|
|
|
|
2015-03-06 18:47:13 +08:00
|
|
|
prev=""
|
|
|
|
if [ -e "$name.backup" ]; then
|
|
|
|
prev=`grep $rev "$name.backup" | cut -c 14-`
|
|
|
|
fi
|
2015-02-26 23:12:58 +08:00
|
|
|
res=$prev
|
|
|
|
count_rev=`echo $prev | wc -w`
|
|
|
|
count_ref=`cat "settings.txt" | wc -l`
|
2015-03-06 18:47:13 +08:00
|
|
|
if echo "$global_args" | grep "$rev" > /dev/null; then
|
|
|
|
rev_found=true
|
|
|
|
else
|
|
|
|
rev_found=false
|
|
|
|
fi
|
|
|
|
# echo $update et $selected et $rev_found because $rev et "$global_args"
|
|
|
|
# echo $count_rev et $count_ref
|
|
|
|
if [ $update == true ] || [ $count_rev != $count_ref ] || ([ $selected == true ] && [ $rev_found == true ]); then
|
2015-02-26 23:12:58 +08:00
|
|
|
if $CXX -O2 -DNDEBUG -march=native $CXX_FLAGS -I eigen_src gemm.cpp -DSCALAR=$scalar -o $name; then
|
|
|
|
curr=`./$name`
|
2015-03-06 18:47:13 +08:00
|
|
|
if [ $count_rev == $count_ref ]; then
|
|
|
|
echo "merge previous $prev"
|
|
|
|
echo "with new $curr"
|
|
|
|
else
|
|
|
|
echo "got $curr"
|
|
|
|
fi
|
2015-02-26 23:12:58 +08:00
|
|
|
res=`merge "$curr" "$prev"`
|
2015-03-06 18:47:13 +08:00
|
|
|
# echo $res
|
2015-02-26 23:12:58 +08:00
|
|
|
echo "$rev $res" >> $name.out
|
|
|
|
else
|
|
|
|
echo "Compilation failed, skip rev $rev"
|
|
|
|
fi
|
2015-02-21 02:20:34 +08:00
|
|
|
else
|
2015-02-26 23:12:58 +08:00
|
|
|
echo "Skip existing results for $rev / $name"
|
|
|
|
echo "$rev $res" >> $name.out
|
2015-02-21 02:20:34 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:12:58 +08:00
|
|
|
make_backup $PREFIX"sgemm"
|
|
|
|
make_backup $PREFIX"dgemm"
|
|
|
|
make_backup $PREFIX"cgemm"
|
|
|
|
|
2015-03-06 18:47:13 +08:00
|
|
|
cut -f1 -d"#" < changesets.txt | grep -E '[[:alnum:]]' | while read rev
|
2015-02-21 02:20:34 +08:00
|
|
|
do
|
|
|
|
if [ ! -z '$rev' ]; then
|
|
|
|
echo "Testing rev $rev"
|
|
|
|
cd eigen_src
|
2015-03-06 18:47:13 +08:00
|
|
|
hg up -C $rev > /dev/null
|
2015-02-21 02:20:34 +08:00
|
|
|
actual_rev=`hg identify | cut -f1 -d' '`
|
|
|
|
cd ..
|
|
|
|
|
2015-02-26 23:12:58 +08:00
|
|
|
test_current $actual_rev float $PREFIX"sgemm"
|
|
|
|
test_current $actual_rev double $PREFIX"dgemm"
|
|
|
|
test_current $actual_rev "std::complex<double>" $PREFIX"cgemm"
|
2015-02-21 02:20:34 +08:00
|
|
|
fi
|
|
|
|
|
2015-02-26 23:12:58 +08:00
|
|
|
done
|
2015-02-21 02:20:34 +08:00
|
|
|
|
|
|
|
echo "Float:"
|
2015-02-26 23:12:58 +08:00
|
|
|
cat $PREFIX"sgemm.out"
|
2015-02-21 02:20:34 +08:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo "Double:"
|
2015-02-26 23:12:58 +08:00
|
|
|
cat $PREFIX"dgemm.out"
|
2015-02-21 02:20:34 +08:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo "Complex:"
|
2015-02-26 23:12:58 +08:00
|
|
|
cat $PREFIX"cgemm.out"
|
2015-02-21 02:20:34 +08:00
|
|
|
echo ""
|
|
|
|
|
2015-02-26 23:12:58 +08:00
|
|
|
./make_plot.sh $PREFIX"sgemm"
|
|
|
|
./make_plot.sh $PREFIX"dgemm"
|
|
|
|
./make_plot.sh $PREFIX"cgemm"
|
2015-02-21 02:20:34 +08:00
|
|
|
|
|
|
|
|