Skip to content

Instantly share code, notes, and snippets.

@SteveBronder
Created July 9, 2020 18:38
Show Gist options
  • Select an option

  • Save SteveBronder/d98ca4335fc07dd84f18c8a25b7cc9dc to your computer and use it in GitHub Desktop.

Select an option

Save SteveBronder/d98ca4335fc07dd84f18c8a25b7cc9dc to your computer and use it in GitHub Desktop.
#!/bin/bash -e
usage() {
echo "=====!!!WARNING!!!===="
echo "This will clean all repos involved! Use only on a clean checkout."
echo "$0 \"<arguments to runPerformanceTests.py>\" <reference-cmdstan-git-hash> <cmdstan_pr_or_hash> <stan_pr> <math_pr>"
}
write_makelocal() {
echo "CXXFLAGS += -march=native -mtune=native -g -Wno-ignored-attributes" > make/local
}
write_makelocalnew() {
echo "CXXFLAGS += -march=native -g -Wno-ignored-attributes -fdevirtualize-at-ltrans -flto -fuse-linker-plugin -fipa-pta" > make/local
}
clean_checkout() {
make revert
cd cmdstan
#Checkout CmdStan
if [[ "$1" == "PR-"* ]] ; then
prNumber=$(echo $1 | cut -d "-" -f 2)
git fetch https://github.com/stan-dev/cmdstan +refs/pull/$prNumber/merge:refs/remotes/origin/pr/$prNumber/merge
git checkout refs/remotes/origin/pr/$prNumber/merge
else
git fetch && git checkout "$1" && git pull origin "$1"
fi
git reset --hard HEAD
git clean -xffd
git submodule update --init --recursive
#Checkout stan
cd stan
if [[ "$2" == "PR-"* ]] ; then
prNumber=$(echo $2 | cut -d "-" -f 2)
git fetch https://github.com/stan-dev/stan +refs/pull/$prNumber/merge:refs/remotes/origin/pr/$prNumber/merge
git checkout refs/remotes/origin/pr/$prNumber/merge
elif [ "$2" != "false" ] ; then
git fetch && git checkout "$2" && git pull origin "$2"
fi
git reset --hard HEAD
git clean -xffd
cd ..
#Checkout math
pushd stan/lib/stan_math
if [[ "$3" == "PR-"* ]] ; then
prNumber=$(echo $3 | cut -d "-" -f 2)
git fetch https://github.com/stan-dev/math +refs/pull/$prNumber/merge:refs/remotes/origin/pr/$prNumber/merge
git checkout refs/remotes/origin/pr/$prNumber/merge
elif [ "$3" != "false" ] ; then
git fetch && git checkout "$3" && git pull origin "$3"
fi
git reset --hard HEAD
git clean -xffd
popd
cd ..
make clean
cd cmdstan
dirty=$(git status --porcelain)
#if [ "$dirty" != "" ]; then
# echo "ERROR: Git repo isn't clean - I'd recommend you make a separate recursive clone of CmdStan for this."
# exit
#fi
if [[ "$3" == "false"* ]] ; then
write_makelocal
else
write_makelocal
fi
git status
cd ..
}
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
usage
exit
fi
set -e -x
# First checkout the first arg cmdstan hash, assuming stan and math are as specified
# by that cmdstan commit
clean_checkout "$2" "false" "false"
#./runPerformanceTests.py --overwrite-golds $1
./runPerformanceTests.py --make-only $1
#for i in performance.*; do
# mv $i "${2}_${i}"
#done
cp stat_comp_benchmarks/benchmarks/sir/sir ../sir_old
perf record -g --freq=2800 --call-graph dwarf -d -o sir_old_perf.data ../sir_old method=sample num_samples=1000 num_warmup=1000 data file=stat_comp_benchmarks/benchmarks/sir/sir.data.R random seed=1234 output file=golds/stat_comp_benchmarks_benchmarks_sir_sir.gold.tmp
clean_checkout "$3" "$4" "$5"
./runPerformanceTests.py --make-only $1
cp stat_comp_benchmarks/benchmarks/sir/sir ../sir_new
perf record -g --freq=2800 --call-graph dwarf -d -o sir_new_perf.data ../sir_new method=sample num_samples=1000 num_warmup=1000 data file=stat_comp_benchmarks/benchmarks/sir/sir.data.R random seed=1234 output file=golds/stat_comp_benchmarks_benchmarks_sir_sir.gold.tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment