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
|
#!/bin/bash
# This is a script for PGO - Profile Guided Optimisations in gcc.
compiler="$1"
shift
mode="$1"
shift
pgo_flags=""
make_vars=()
src="$(perl -e 'use File::Basename qw(dirname); use File::Spec; print File::Spec->rel2abs(dirname(shift(@ARGV))."/..");' "$0")"
# echo "src_dir=$src"
# theme="-l te"
# theme="--read-from-file 4,$(pwd)/Presets/testing-presets/all-star-4.sh"
theme="-l as"
run_make()
{
make -r -j4 -f "$src"/Makefile.gnu SRC_DIR="$src" "$@"
}
m_clean()
{
run_make clean
}
run_self()
{
local cmd="$1"
shift
bash "$src"/scripts/pgo.bash "$compiler" "$cmd"
}
run_timing()
{
if [ -x ~/bin/sudo_time_fcs ] ; then
sudo ~/bin/sudo_time_fcs "$@"
else
sudo_renice ./freecell-solver-range-parallel-solve "$@"
fi
}
if test "$mode" = "total" ; then
m_clean && \
run_self "gen" && \
rm -f *.gcda && \
run_timing 1 32000 4000 $theme && \
m_clean && \
run_self "use" && \
rm -f *.gcda *.o
exit 0
elif test "$mode" = "use" ; then
if test "$compiler" = "gcc" ; then
pgo_flags="-fprofile-use"
elif test "$compiler" = "icc" ; then
pgo_flags="-prof-use"
else
echo "Unknown compiler '$compiler'!" 1>&2
exit -1
fi
make_vars=(OPT_AND_DEBUG=0 DEBUG=0)
elif test "$mode" = "gen" ; then
if test "$compiler" = "gcc" ; then
pgo_flags="-fprofile-generate"
elif test "$compiler" = "icc" ; then
pgo_flags="-prof-gen"
else
echo "Unknown compiler '$compiler'!" 1>&2
exit -1
fi
else
echo "Unknown mode '$mode'!" 1>&2
exit -1
fi
run_make FREECELL_ONLY=1 \
EXTRA_CFLAGS="$pgo_flags" \
COMPILER="$compiler" \
$make_vars
|