From ec0512af6bbb8ba05eb13fc1aac7754283dd13aa Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Tue, 20 Oct 2020 18:20:39 -0400 Subject: Unify unpaired timing scripts for DIS, TACLe, and SD-VBS Now supports specifying an input generation command for each benchmark - see dis/dis2MbInNames.txt for an example. --- run_bench.sh | 181 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 138 insertions(+), 43 deletions(-) (limited to 'run_bench.sh') diff --git a/run_bench.sh b/run_bench.sh index c5b67b6..4e09faa 100755 --- a/run_bench.sh +++ b/run_bench.sh @@ -1,30 +1,110 @@ #!/bin/bash -core=$1 -maxJobs=$2 -userRunID=$3 -tacleNames=tacleNames.txt +if [ $# -lt 5 ]; then + echo "Usage $0 -m MODE -p CPU -l LOOPS -b FILE [-c] RUN_ID" + echo " -m base|dis Which benchmarking mode to use" + echo " -p CPU Which CPU to run each benchmark on" + echo " -l LOOPS How many loops of each benchmark to do" + echo " -b FILE List of benchmarks to execute. Optional tab-" + echo " delimited 2nd column specifies an input" + echo " generation command (fed to bench via stdin)" + echo " -B Enable background contenders on other CCXes" + echo "Mode base requires no additional options." + echo "Mode dis does not support the 2nd col. of -b and needs:" + echo " -W FILE List of working set sizes to pass gen_input.py" + echo " -T FILE Input template to pass to gen_input.py" + echo " -C FILE List of cache configurations to test" + exit +fi -if [ $# -lt 3 ]; then - echo "Usage $0 [TACLe names file] [--contend]" +# Name options similarly to rtspin +while getopts “m:p:l:b:BW:T:C:” opt; do + case $opt in +# Required + m) mode=$OPTARG ;; + p) core=$OPTARG ;; + l) maxJobs=$OPTARG ;; + b) benchNames=$OPTARG ;; +# Optional + B) contend=1 ;; + W) wss_settings=$OPTARG ;; + T) template_input=$OPTARG ;; + C) cache_settings=$OPTARG ;; + esac +done +# Reset to read operands +shift $((OPTIND -1)) +userRunID=$1 + +# Required argument checking +if [[ "$mode" != "base" ]] && [[ "$mode" != "dis" ]]; then + echo "Invalid argument: MODE must be either 'base' or 'dis'" + exit +fi +if [[ ! -v core ]] || [[ ! -v maxJobs ]] || [[ ! -v benchNames ]]; then + echo "Missing argument: -p, -l, and -b are required" + exit +fi +if [[ ! -f "$benchNames" ]]; then + echo "Invalid argument: $benchNames des not exist" + exit +fi +if [[ ! -v userRunID ]]; then + echo "Missing argument: RUN_ID is required" exit fi -if [ $# -gt 3 ]; then - echo "Using alternate list of TACLe benchmarks from $4" - tacleNames=$4 +# DIS argument checking +if [[ "$mode" == "dis" ]] && [[ ! -v wss_settings || ! -v template_input || -z $cache_settings ]]; then + echo "Missing argument: DIS needs -W FILE -T FILE and -C FILE" + exit +fi +if [[ "$mode" == "dis" ]] && [[ ! -f "$wss_settings" ]]; then + echo "Invalid argument: $wss_settings does not exist" + exit +fi +if [[ "$mode" == "dis" ]] && [[ ! -f "$template_input" ]]; then + echo "Invalid argument: $template_input does not exist" + exit +fi +if [[ "$mode" == "dis" ]] && [[ ! -f "$cache_settings" ]]; then + echo "Invalid argument: $cache_settings does not exist" + exit fi +# Check permissions and update state if [ "$EUID" -ne 0 ] then echo "You need to be root to enable interrupt isolation and real-time execution!" exit fi -echo "Making sure that binaries are up to date..." +echo "Done. Loading benchmark names and input..." + +# Read the names of each benchmark and load input. +# This might look a bit scary, but all it does is +# separate the two fields (1 or more tabs in-between), +# save the benchmark name, and execute the input +# command (storing its output in-memory for later). +j=0 +IFS=$'\r\n' while read i; do - make bin/$i -done < $tacleNames + bench[$j]=$(echo $i | tr -s "\t" | cut -f1) + input[$j]=$(eval $(echo $i | tr -s "\t" | cut -s -f2)) + j=$(( $j + 1 )) +done < $benchNames +echo "Making sure that binaries are up to date..." + +for b in ${bench[@]}; do + make bin/$b + if [[ $? ]]; then + make $b + fi + if [[ ! -f $b && ! -f "./bin/$b" ]]; then + echo "Unable to find benchmark $b" + exit + fi +done echo "Done. Disabling real-time throttling..." # Turn off rt throttling @@ -43,28 +123,20 @@ do i=$(( $i + 1 )) done -# Read the names of each benchmark -j=0 -while read i; do - tacleProg[$j]=$i - j=$(( $j + 1 )) -done < $tacleNames - echo "Done. Checking for wbinvd module..." if [[ ! -f "/proc/wbinvd" ]]; then echo "ERROR: wbinvd module not loaded. Exiting..." exit fi -echo "Done. Setting cores $firstCore and $secondCore to 'performance'..." -echo "performance" > /sys/devices/system/cpu/cpu15/cpufreq/scaling_governor -echo "performance" > /sys/devices/system/cpu/cpu31/cpufreq/scaling_governo +echo "Done. Setting core $core to 'performance'..." +echo "performance" > /sys/devices/system/cpu/cpu$core/cpufreq/scaling_governor # Enable L3 isolation echo "Done. Enabling L3 isolation..." mount -t resctrl resctrl /sys/fs/resctrl mkdir -p /sys/fs/resctrl/benchmarks -echo $1 > /sys/fs/resctrl/benchmarks/cpus_list +echo $core > /sys/fs/resctrl/benchmarks/cpus_list # Reset global bandwith control and remove L3 from global echo "L3:0=ffff;1=ffff;2=ffff;3=0000" > /sys/fs/resctrl/schemata echo "MB:0=2048;1=2048;2=2048;3=2048" > /sys/fs/resctrl/schemata @@ -80,9 +152,9 @@ runID=$(date +"%b%d-%H") # Confirm configuration with user echo "=== Global Config ===" cat /sys/fs/resctrl/schemata -echo "=== Core $1 Config ===" +echo "=== Core $core Config ===" cat /sys/fs/resctrl/benchmarks/schemata -if [[ $5 == "--contend" ]]; then +if [[ -v contend ]]; then if [[ ! -f "/playpen/mc2/imx6q-thrasher/thrasher" ]]; then echo "ERROR: thrasher binary not fonud. Exiting..." exit @@ -99,15 +171,12 @@ else echo "MC^2 not detected." runID=$runID-xi fi -if pwd | grep -qi dis; then - echo "Autodetected DIS. Will use script-level looping." -fi echo "Results will be saved as $runID-$userRunID.txt" echo "Press enter to confirm environment, Ctrl-C to exit..." read # Start contending tasks -if [[ $5 == "--contend" ]]; then +if [[ -v contend ]]; then echo "Done. Starting 6 contending tasks..." # Run two contending tasks on each other CCX taskset -c 1 /playpen/mc2/imx6q-thrasher/thrasher & @@ -120,27 +189,53 @@ fi sleep 1 # Wait for contending tasks to start echo "Done. Beginning benchmarks..." -num_tests=$(wc -l < $tacleNames) -for (( i = 0; i < $num_tests ; i++ )) -do - # If using DIS, we have to iterate in the script as DIS won't do it for us - pwd | grep -qi dis - iters=$(python3 -c "print(int(not "$?")*("$maxJobs"-1))") - for ((k=0;k<=iters;k++)); do +# Output coloring +FAIL_COLOR="\033[0;31m" +GOOD_COLOR="\033[0;32m" +RESET_COLOR="\033[0m" + +num_tests=$(wc -l < $benchNames) +# For each benchmark +for (( i = 0; i < $num_tests ; i++ )); do + if [[ -f ${bench[$i]} ]]; then + binary="${bench[$i]}" + else + binary="./bin/${bench[$i]}" + fi + if [[ "$mode" == "base" ]]; then + # Just run the benchmark if TACLeBench # Check if we're using LITMUS^RT or not - if [[ -f source/extra.h ]] && grep -q "#define LITMUS 1" source/extra.h; then - ./bin/${tacleProg[$i]} ${tacleProg[$i]} $maxJobs $core $runID-$userRunID 1 + if grep -q "#define LITMUS 1" ../extra.h; then + echo "Using LITMUS-RT!" + echo "${input[$i]}" | numactl -m 0 ./bin/$binary ${bench[$i]} $maxJobs $core $runID-$userRunID 1 else # Interleave memory allocations between all nodes (only 1 node w/out MC^2) - chrt -r 97 numactl --interleave=all taskset -c $core ./bin/${tacleProg[$i]} ${tacleProg[$i]} $maxJobs $core $runID-$userRunID 1 -#chrt -r 97 numactl -m 0 taskset -c $core ./bin/${tacleProg[$i]} ${tacleProg[$i]} $maxJobs $core $runID-$userRunID-NOINTERLEAVE 1 + # (this is right because we're testing a task w/out SMT, so it gets both colors) + echo "${input[$i]}" | chrt -r 97 numactl --interleave=all taskset -c $core ./$binary ${bench[$i]} $maxJobs $core $runID-$userRunID 1 fi - done - echo COMPLETE: ${tacleProg[$i]} + elif [[ "$mode" == "dis" ]]; then + # Loop through each WSS and cache config if DIS + while read j; do # For cache setting + echo $j > /sys/fs/resctrl/benchmarks/schemata + while read ii; do # For WSS setting + if grep -q "#define LITMUS 1" ../extra.h; then + echo "Using LITMUS-RT!" + ./gen_input.py ${bench[$i]} inputs/${bench[$i]^}/$template_input $ii | numactl -m 0 ./$binary $bench[$i]}-$ii-$j $maxJobs $core $runID 1 + else + ./gen_input.py ${bench[$i]} $template_input $ii | chrt -r 97 numactl -m 0 taskset -c $core ./$binary ${bench[$i]}-$ii-$j $maxJobs $core $runID 1 + fi + done < $wss_settings + done < $cache_settings + fi + if [[ $? != 0 ]]; then + echo -e ${FAIL_COLOR}FAILED${RESET_COLOR}: ${bench[$i]} + else + echo -e ${GOOD_COLOR}COMPLETE${RESET_COLOR}: ${bench[$i]} + fi done # End contending tasks -if [[ $5 == "--contend" ]]; then +if [[ -v contend ]]; then killall thrasher fi -- cgit v1.2.2