#!/bin/bash fast=false sequential=false ncpus="" cpurange="" while [ -n "$1" ]; do if [ "$1" == "--fast" ]; then fast=true elif [ "$1" == "-s" ]; then sequential=true elif [ "$1" == "-n" ]; then ncpus="$2" shift elif [ "$1" == "-N" ]; then cpurange="$2" shift fi shift done if [ -z "$ncpus" ]; then ncpus=$(nproc) fi if [ -z "$cpurange" ]; then cpurange="0-$((ncpus - 1))" fi abort() { echo "Step $1 failed." echo "To restart from this step, try running:" if [ "$1" == "setup" ]; then echo " rm -rf belarus-2020-2021 cmz lox-new lox-old sigma-compiler simga-proofs spongefish" elif [ "$1" == "belarus" ]; then echo " rm -rf appendix-a-results.{pdf,tex} section-3-results" echo " docker stop tp-belarus" echo " docker rm tp-belarus" elif [ "$1" == "lox-gen" ]; then echo " rm -rf parsing-results/{lox-{old,new},troll-patrol}" echo " docker stop {lox-{old,new},troll-patrol}-{trust_levels,invitations,blockage_migration{05,50,100}}.log troll-patrol-reporting.log" echo " docker rm {lox-{old,new},troll-patrol}-{trust_levels,invitations,blockage_migration{05,50,100}}.log troll-patrol-reporting.log" elif [ "$1" == "lox-eval" ]; then echo " rm -f appendix-b-results.{pdf,tex} table-{2,3}-results.{pdf,tex}" echo " docker stop tp-lox" echo " docker rm tp-lox" fi echo "Then run this script again." echo "Exiting..." exit 1 } if [ -z "$(command -v numactl)" ]; then echo "This script uses numactl to isolate each experiment to a single processing unit." echo "You do not seem to have numactl installed. You can still run this script without numactl, but this may affect the results." read -p "Continue without numactl? [y/N] " confirm confirm=$(echo "$confirm" | tr '[:lower:]' '[:upper:]') if [[ "$confirm" != "Y" && "$confirm" != "YES" ]]; then exit 1 else echo "Continuing without numactl" fi fi # Set up dockers if [ ! -d troll-patrol ]; then # Clean up any remnants of previous attempts and try again rm -rf belarus-2020-2021 cmz lox-new lox-old sigma-compiler simga-proofs spongefish # Set up our dockers ./scripts/setup.sh || abort "setup" fi # Get Belarus results if [[ ! -f appendix-a-results.pdf || ! -f section-3-results ]]; then # Clean up any remnants of previous attempts and try again rm -f appendix-a-results.{pdf,tex} section-3-results if [ "$fast" == "true" ]; then ./scripts/belarus.sh --fast || abort "belarus" elif [ "$sequential" == "true" ]; then ./scripts/belarus.sh -s || abort "belarus" else ./scripts/belarus.sh || abort "belarus" fi fi # Run Lox benchmarks if [[ ! -d parsing-results/lox-old || ! -d parsing-results/lox-new || ! -d parsing-results/troll-patrol ]]; then # Clean up any remnants of previous attempts and try again rm -rf parsing-results/{lox-{old,new},troll-patrol} ./scripts/generate-lox-results.sh -N "$cpurange" -n "$ncpus" || abort "lox-gen" fi # Process Lox benchmark results if [[ ! -f appendix-b-results.pdf || ! -f table-2-results.pdf || ! -f table-3-results.pdf ]]; then # Clean up any remnants of previous attempts and try again rm -f appendix-b-results.{pdf,tex} table-{2,3}-results.{pdf,tex} ./scripts/process-lox-results.sh || abort "lox-eval" fi echo "Done!" echo "Results from Section 3 can be found in the section-3-results file." echo "Table 4 (in Appendix A) can be found in appendix-a-results.pdf." echo "Results from Section 6 (Tables 2 and 3) can be found in the table-2-results.pdf and table-3-results.pdf files." echo "Table 5 (in Appendix B) can be found in appendix-b-results.pdf."