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. --- dis/bin/field_2mb | 2 - dis/bin/matrix_2mb | 2 - dis/bin/neighborhood_2mb | 2 - dis/bin/pointer_2mb | 2 - dis/bin/transitive_2mb | 2 - dis/bin/update_2mb | 2 - dis/dis2MbInNames.txt | 6 ++ dis/run_dis.sh | 92 ------------------------ run_all_dis.sh | 70 ------------------ run_bench.sh | 181 ++++++++++++++++++++++++++++++++++++----------- run_dis_cache_vs_wss.sh | 69 ++++++++++++++++++ run_tacle_all.sh | 49 +++++++++++++ run_tacle_rtss20.sh | 48 ------------- 13 files changed, 262 insertions(+), 265 deletions(-) delete mode 100755 dis/bin/field_2mb delete mode 100755 dis/bin/matrix_2mb delete mode 100755 dis/bin/neighborhood_2mb delete mode 100755 dis/bin/pointer_2mb delete mode 100755 dis/bin/transitive_2mb delete mode 100755 dis/bin/update_2mb create mode 100644 dis/dis2MbInNames.txt delete mode 100755 dis/run_dis.sh delete mode 100755 run_all_dis.sh create mode 100755 run_dis_cache_vs_wss.sh create mode 100755 run_tacle_all.sh delete mode 100755 run_tacle_rtss20.sh diff --git a/dis/bin/field_2mb b/dis/bin/field_2mb deleted file mode 100755 index 31f2a8d..0000000 --- a/dis/bin/field_2mb +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -taskset -c 0 ./gen_input.py field inputs/Field/in0 2097152 | ./field $@ diff --git a/dis/bin/matrix_2mb b/dis/bin/matrix_2mb deleted file mode 100755 index 72710ab..0000000 --- a/dis/bin/matrix_2mb +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -taskset -c 0 ./gen_input.py matrix inputs/Matrix/in4 2097152 | ./matrix $@ > /dev/null diff --git a/dis/bin/neighborhood_2mb b/dis/bin/neighborhood_2mb deleted file mode 100755 index 226bd98..0000000 --- a/dis/bin/neighborhood_2mb +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -taskset -c 0 ./gen_input.py neighborhood inputs/Neighborhood/in0 2097152 | ./neighborhood $@ > /dev/null diff --git a/dis/bin/pointer_2mb b/dis/bin/pointer_2mb deleted file mode 100755 index 3ce8f2b..0000000 --- a/dis/bin/pointer_2mb +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -taskset -c 0 ./gen_input.py pointer inputs/Pointer/in0 2097152 | ./pointer $@ diff --git a/dis/bin/transitive_2mb b/dis/bin/transitive_2mb deleted file mode 100755 index b8bcf5a..0000000 --- a/dis/bin/transitive_2mb +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -taskset -c 0 ./gen_input.py transitive inputs/Transitive/in0 2097152 | ./transitive $@ diff --git a/dis/bin/update_2mb b/dis/bin/update_2mb deleted file mode 100755 index 3bc33f4..0000000 --- a/dis/bin/update_2mb +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -taskset -c 0 ./gen_input.py update inputs/Update/in0 2097152 | ./update $@ diff --git a/dis/dis2MbInNames.txt b/dis/dis2MbInNames.txt new file mode 100644 index 0000000..00e6a22 --- /dev/null +++ b/dis/dis2MbInNames.txt @@ -0,0 +1,6 @@ +field ./gen_input.py field inputs/Field/in0 2097152 +matrix ./gen_input.py matrix inputs/Matrix/in0 2097152 +neighborhood ./gen_input.py neighborhood inputs/Neighborhood/in0 2097152 +pointer ./gen_input.py pointer inputs/Pointer/in0 2097152 +transitive ./gen_input.py transitive inputs/Transitive/in0 2097152 +update ./gen_input.py update inputs/Update/in0 2097152 diff --git a/dis/run_dis.sh b/dis/run_dis.sh deleted file mode 100755 index 78745ec..0000000 --- a/dis/run_dis.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash - -core=$1 -maxJobs=$2 -runID=$3 -benchmark=${4,} -template_input=inputs/$4/in0 -wss_settings=inputs/WSSS -cache_settings=inputs/caches - -if [ $# -lt 4 ]; then - echo "Usage $0 [template input] [DIS WSS file] [DIS cache file]" - exit -fi - -if [ $# -gt 4 ]; then - echo "Using alternate input template from $5" - template_input=$5 -fi - -if [ $# -gt 5 ]; then - echo "Using alternate WSS settings from $6" - wss_settings=$6 -fi - -if [ $# -gt 6 ]; then - echo "Using alternate cache settings from $7" - cache_settings=$7 -fi - -echo "Making sure that binary is up to date..." -make $benchmark -echo "Done. Disabling real-time throttling..." - -# Turn off rt throttling -echo -1 > /proc/sys/kernel/sched_rt_runtime_us -echo "Done. Redirecting all interrupts to core 0..." - -# Redirect all interrupts to core 0 -i=0 -for IRQ in /proc/irq/* -do - # Skip default_smp_affinity - if [ -d $IRQ ]; then - irqList[$i]=$(cat $IRQ/smp_affinity_list) - echo 0 2> /dev/null > $IRQ/smp_affinity_list - fi - i=$(( $i + 1 )) -done - -echo "Done. Checking for wbinvd module..." -if [[ ! -f "/proc/wbinvd" ]]; then - echo "ERROR: wbinvd module not loaded. Exiting..." - exit -fi - -# 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 -# 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 -# Alloc L3 to benchmark -echo "L3:0=0000;1=0000;2=0000;3=ffff" > /sys/fs/resctrl/benchmarks/schemata -echo "MB:0=2048;1=2048;2=2048;3=2048" > /sys/fs/resctrl/benchmarks/schemata -echo "Done. Beginning benchmarks..." - -# Execute the benchmark for each WSS and cache config -while read j; do - echo $j > /sys/fs/resctrl/benchmarks/schemata - while read i; do - if grep -q "#define LITMUS 1" ../baseline/source/extra.h; then - echo "Using LITMUS-RT!" - ./gen_input.py $benchmark $template_input $i | numactl -m 0 ./$benchmark $benchmark-$i-$j $maxJobs $core $runID 1 - else - ./gen_input.py $benchmark $template_input $i | chrt -r 97 numactl -m 0 taskset -c $core ./$benchmark $benchmark-$i-$j $maxJobs $core $runID 1 - fi - done < $wss_settings -done < $cache_settings - -# Put IRQs back as they were -i=0 -for IRQ in /proc/irq/* -do - if [ -d $IRQ ]; then - echo ${irqList[$i]} 2> /dev/null > $IRQ/smp_affinity_list - fi - i=$(( $i + 1 )) -done - diff --git a/run_all_dis.sh b/run_all_dis.sh deleted file mode 100755 index 5a6b6e1..0000000 --- a/run_all_dis.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# Run baselines for all the DIS tasks -if [ "$EUID" -ne 0 ] -then - echo "You need to be root to enable cache way and interrupt isolation!" - exit -fi - -if uname -a | grep -q "mc2"; then - echo "MC^2 detected! Cache isolation will be enabled" - iso="i" -else - echo "MC^2 not detected." - iso="xi" -fi - -datestring=$(date +"%b%d-%H") -if ! grep -q irqaffinity /proc/cmdline; then - /playpen/move_interrupts_off_core15.sh -else - echo "performance" > /sys/devices/system/cpu/cpu15/cpufreq/scaling_governor -fi -WSSS=WSSS_maxstride2mb -caches=caches_all -# Consider re-enabling this only if you're interested in exploring bandwidth effects -#./setup_mem_and_global.sh -if [[ $1 == "--contend" ]]; then - echo "Will run 6 contending tasks" - echo "Files will be named $datestring--c-"$iso".txt" - echo "Please verify the above settings. Press enter to continue..." - read - # Run two contending tasks on each other CCX - taskset -c 1 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 2 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 5 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 6 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 9 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 10 /playpen/mc2/imx6q-thrasher/thrasher & - ./run_dis.sh 15 10 $datestring-field-c-$iso Field inputs/Field/in0 inputs/$WSSS inputs/$caches - ./postproc.sh $datestring-field-c-$iso - ./run_dis.sh 15 10 $datestring-matrix-c-$iso Matrix inputs/Matrix/in0 inputs/$WSSS inputs/$caches - ./postproc.sh $datestring-matrix-c-$iso - ./run_dis.sh 15 10 $datestring-neighborhood-c-$iso Neighborhood inputs/Neighborhood/in0 inputs/$WSSS inputs/$caches - ./postproc.sh $datestring-neighborhood-c-$iso - ./run_dis.sh 15 10 $datestring-pointer-c-$iso Pointer inputs/Pointer/in0 inputs/$WSSS inputs/$caches - ./postproc.sh $datestring-pointer-c-$iso - ./run_dis.sh 15 10 $datestring-transitive-c-$iso Transitive inputs/Transitive/in0 inputs/$WSSS inputs/$caches - ./postproc.sh $datestring-transitive-c-$iso - ./run_dis.sh 15 10 $datestring-update-c-$iso Update inputs/Update/in0 inputs/$WSSS inputs/$caches - ./postproc.sh $datestring-update-c-$iso - killall thrasher -else - echo "Will run no contending tasks (use --contend for contending tasks)" - echo "Files will be named $datestring--xc-"$iso".txt" - echo "Please verify the above settings. Press enter to continue..." - read - killall thrasher - ./run_dis.sh 15 10 $datestring-field-xc-$iso Field inputs/Field/in0 inputs/$WSSS inputs/$caches - ./postproc.sh $datestring-field-xc-$iso - ./run_dis.sh 15 10 $datestring-matrix-xc-$iso Matrix inputs/Matrix/in0 inputs/$WSSS inputs/$caches - ./postproc.sh $datestring-matrix-xc-$iso - ./run_dis.sh 15 10 $datestring-neighborhood-xc-$iso Neighborhood inputs/Neighborhood/in0 inputs/$WSSS inputs/$caches - ./postproc.sh $datestring-neighborhood-xc-$iso - ./run_dis.sh 15 10 $datestring-pointer-xc-$iso Pointer inputs/Pointer/in0 inputs/$WSSS inputs/$caches - ./postproc.sh $datestring-pointer-xc-$iso - ./run_dis.sh 15 10 $datestring-transitive-xc-$iso Transitive inputs/Transitive/in0 inputs/$WSSS inputs/$caches - ./postproc.sh $datestring-transitive-xc-$iso - ./run_dis.sh 15 10 $datestring-update-xc-$iso Update inputs/Update/in0 inputs/$WSSS inputs/$caches - ./postproc.sh $datestring-update-xc-$iso -fi 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 diff --git a/run_dis_cache_vs_wss.sh b/run_dis_cache_vs_wss.sh new file mode 100755 index 0000000..46a12ff --- /dev/null +++ b/run_dis_cache_vs_wss.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# Run baselines for all the DIS tasks +if [ "$EUID" -ne 0 ] +then + echo "You need to be root to enable cache way and interrupt isolation!" + exit +fi + +if uname -a | grep -q "mc2"; then + echo "MC^2 detected! Cache isolation will be enabled" + iso="i" +else + echo "MC^2 not detected." + iso="xi" +fi + +cd dis + +WSSS=WSSS_maxstride2mb +caches=caches_all +# Consider re-enabling this only if you're interested in exploring bandwidth effects +#./setup_mem_and_global.sh +if [[ $1 == "--contend" ]]; then + echo "Will run 6 contending tasks" + echo "Files will be named $datestring--10-c-"$iso".txt" + echo "Please verify the above settings. Press enter to continue..." + read + echo "field" > /tmp/disNames.txt + ../run_bench.sh -p 15 -B -l 10 -b /tmp/disNames.txt -W WSSS -C caches -T in0 field-10 + ./postproc.sh $datestring-field-10-c-$iso + echo "matrix" > /tmp/disNames.txt + ../run_bench.sh -p 15 -B -l 10 -b /tmp/disNames.txt -W WSSS -C caches -T in0 matrix-10 + ./postproc.sh $datestring-matrix-10-c-$iso + echo "neighborhood" > /tmp/disNames.txt + ../run_bench.sh -p 15 -B -l 10 -b /tmp/disNames.txt -W WSSS -C caches -T in0 neighborhood-10 + ./postproc.sh $datestring-neighborhood-10-c-$iso + echo "pointer" > /tmp/disNames.txt + ../run_bench.sh -p 15 -B -l 10 -b /tmp/disNames.txt -W WSSS -C caches -T in0 pointer-10 + ./postproc.sh $datestring-pointer-10-c-$iso + echo "transitive" > /tmp/disNames.txt + ../run_bench.sh -p 15 -B -l 10 -b /tmp/disNames.txt -W WSSS -C caches -T in0 transitive-10 + ./postproc.sh $datestring-transitive-10-c-$iso + echo "update" > /tmp/disNames.txt + ../run_bench.sh -p 15 -B -l 10 -b /tmp/disNames.txt -W WSSS -C caches -T in0 update-10 + ./postproc.sh $datestring-update-10-c-$iso +else + echo "Will run no contending tasks (use --contend for contending tasks)" + echo "Files will be named $datestring--10-xc-"$iso".txt" + echo "Please verify the above settings. Press enter to continue..." + read + echo "field" > /tmp/disNames.txt + ../run_bench.sh -p 15 -l 10 -b /tmp/disNames.txt -W WSSS -C caches -T in0 field-10 + ./postproc.sh $datestring-field-10-xc-$iso + echo "matrix" > /tmp/disNames.txt + ../run_bench.sh -p 15 -l 10 -b /tmp/disNames.txt -W WSSS -C caches -T in0 matrix-10 + ./postproc.sh $datestring-matrix-10-xc-$iso + echo "neighborhood" > /tmp/disNames.txt + ../run_bench.sh -p 15 -l 10 -b /tmp/disNames.txt -W WSSS -C caches -T in0 neighborhood-10 + ./postproc.sh $datestring-neighborhood-10-xc-$iso + echo "pointer" > /tmp/disNames.txt + ../run_bench.sh -p 15 -l 10 -b /tmp/disNames.txt -W WSSS -C caches -T in0 pointer-10 + ./postproc.sh $datestring-pointer-10-xc-$iso + echo "transitive" > /tmp/disNames.txt + ../run_bench.sh -p 15 -l 10 -b /tmp/disNames.txt -W WSSS -C caches -T in0 transitive-10 + ./postproc.sh $datestring-transitive-10-xc-$iso + echo "update" > /tmp/disNames.txt + ../run_bench.sh -p 15 -l 10 -b /tmp/disNames.txt -W WSSS -C caches -T in0 update-10 + ./postproc.sh $datestring-update-10-xc-$iso +fi diff --git a/run_tacle_all.sh b/run_tacle_all.sh new file mode 100755 index 0000000..dd5a443 --- /dev/null +++ b/run_tacle_all.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Copyright 2020 Joshua Bakita +# This script runs the baselines and Level-A/B and Level-C all_pairs +# for TACLe w/out MC^2 + +if uname -a | grep -q mc2; then + echo "You need to run this without MC^2!" + exit +fi + +if [ "$EUID" -ne 0 ]; then + echo "You need to be root to enable interrupt isolation and real-time execution!" + exit +fi + +echo "This will run the contended and uncontended TACLe baseline, all-pairs, and Level-C micro-benchamarks in non-interactive mode." +echo "Please press enter to confirm (Ctrl-C to abort)..." +read + +echo "performance" > /sys/devices/system/cpu/cpu15/cpufreq/scaling_governor +echo "performance" > /sys/devices/system/cpu/cpu31/cpufreq/scaling_governor + +cd baseline +baseNo=baseline/$(date +"%b%d-%H")-xc-xi-1k.txt +echo "" | ../run_bench.sh -m base -p 15 -l 1001 -b ../all_pairs/tacleNames.txt 1k +baseYes=baseline/$(date +"%b%d-%H")-c-xi-1k.txt +echo "" | ../run_bench.sh -B -m make -p 15 -l 1001 -b ../all_pairs/tacleNames.txt 1k + +cd ../all_pairs +pairsNo=all_pairs/$(date +"%b%d-%H")-xc-xi-1k +echo "" | ./run_all_pairs.sh 15 31 1001 1k ./tacleNames.txt +pairsYes=all_pairs/$(date +"%b%d-%H")-c-xi-1k +echo "" | ./run_all_pairs.sh 15 31 1001 1k ./tacleNames.txt --contend + +cd ../baseline +echo "" | ../smt_analysis_rtss20/run_all_pairs_Level-C_TACLe.sh 15 31 1001 1k ./tacleNames.txt +cNo=all_pairs/$(date +"%b%d-%H")-xc-xi-1k-LC-TACLe.txt +echo "" | ../smt_analysis_rtss20/run_all_pairs_Level-C_TACLe.sh 15 31 1001 1k ./tacleNames.txt --contend +cYes=all_pairs/$(date +"%b%d-%H")-c-xi-1k-LC-TACLe.txt + +echo "==== DONE ===" +echo "Results are in:" +echo "- "$baseNo +echo "- "$baseYes +echo "- "$pairsNo" (A/B)" +echo "- "$pairsYes" (A/B)" +echo "- "$cNo +echo "- "$cYes + diff --git a/run_tacle_rtss20.sh b/run_tacle_rtss20.sh deleted file mode 100755 index 6770c55..0000000 --- a/run_tacle_rtss20.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# Copyright 2020 Joshua Bakita -# This script runs the baselines and Level-A/B and Level-C all_pairs for TACLe w/out MC^2 - -if uname -a | grep -q mc2; then - echo "You need to run this without MC^2!" - exit -fi - -if [ "$EUID" -ne 0 ]; then - echo "You need to be root to enable interrupt isolation and real-time execution!" - exit -fi - -echo "This will run the contended and uncontended TACLe baseline, all-pairs, and Level-C micro-benchamarks in non-interactive mode." -echo "Please press enter to confirm (Ctrl-C to abort)..." -read - -echo "performance" > /sys/devices/system/cpu/cpu15/cpufreq/scaling_governor -echo "performance" > /sys/devices/system/cpu/cpu31/cpufreq/scaling_governor - -cd baseline -baseNo=baseline/$(date +"%b%d-%H")-xc-xi-1k.txt -echo "" | ./run_baseline.sh 15 1001 1k ../all_pairs/tacleNames.txt -baseYes=baseline/$(date +"%b%d-%H")-c-xi-1k.txt -echo "" | ./run_baseline.sh 15 1001 1k ../all_pairs/tacleNames.txt --contend - -cd ../all_pairs -pairsNo=all_pairs/$(date +"%b%d-%H")-xc-xi-1k -echo "" | ./run_all_pairs.sh 15 31 1001 1k ./tacleNames.txt -pairsYes=all_pairs/$(date +"%b%d-%H")-c-xi-1k -echo "" | ./run_all_pairs.sh 15 31 1001 1k ./tacleNames.txt --contend - -cd ../baseline -echo "" | ../smt_analysis_rtss20/run_all_pairs_Level-C_TACLe.sh 15 31 1001 1k ./tacleNames.txt -cNo=all_pairs/$(date +"%b%d-%H")-xc-xi-1k-LC-TACLe.txt -echo "" | ../smt_analysis_rtss20/run_all_pairs_Level-C_TACLe.sh 15 31 1001 1k ./tacleNames.txt --contend -cYes=all_pairs/$(date +"%b%d-%H")-c-xi-1k-LC-TACLe.txt - -echo "==== DONE ===" -echo "Results are in:" -echo "- "$baseNo -echo "- "$baseYes -echo "- "$pairsNo" (A/B)" -echo "- "$pairsYes" (A/B)" -echo "- "$cNo -echo "- "$cYes - -- cgit v1.2.2 From 859a1095e19eef6a10e429d1a2c58ffba7238a76 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Wed, 21 Oct 2020 14:08:09 -0400 Subject: Remove duplicate summary script and don't output memory info if non present --- baseline/summarize.py | 34 ---------------------- dis/summarize.py | 69 --------------------------------------------- summarize.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 103 deletions(-) delete mode 100755 baseline/summarize.py delete mode 100755 dis/summarize.py create mode 100755 summarize.py diff --git a/baseline/summarize.py b/baseline/summarize.py deleted file mode 100755 index 82f82d9..0000000 --- a/baseline/summarize.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/python3 -import sys - -f = sys.argv[1] -res = {} -mem_res = {} -memw_res = {} -samples = {} - -with open(f) as fp: - for line in fp: - s = line.split() - if s[0] not in res: - print(s[0]) - res[s[0]] = int(s[5]) - mem_res[s[0]] = int(s[8]) - memw_res[s[0]] = int(s[9]) - samples[s[0]] =int(s[4]) - else: - res[s[0]] += int(s[5]) - mem_res[s[0]] += int(s[8]) - memw_res[s[0]] += int(s[9]) - -print("Average times:") -for r in res.keys(): - print(res[r]/samples[r]) - -print("Average memory read:") -for r in mem_res.keys(): - print(mem_res[r]/samples[r]) - -print("Average memory write:") -for r in memw_res.keys(): - print(memw_res[r]/samples[r]) diff --git a/dis/summarize.py b/dis/summarize.py deleted file mode 100755 index 31dcccc..0000000 --- a/dis/summarize.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/python3 -import sys - -f = sys.argv[1] -if len(sys.argv) < 2: - print("Usage "+sys.argv[0]+" --inf-precision") -res = {} -mem_res = {} -memw_res = {} -samples = {} -max_res = {} - -with open(f) as fp: - for line in fp: - s = line.split() - if s[0] not in res: -# print(s[0]) - res[s[0]] = list([int(s[5])])#)int(s[5]) - mem_res[s[0]] = int(s[8]) - memw_res[s[0]] = int(s[9]) - samples[s[0]] = int(s[4]) - max_res[s[0]] = int(s[5]) - else: - res[s[0]].append(int(s[5])) - mem_res[s[0]] += int(s[8]) - memw_res[s[0]] += int(s[9]) - max_res[s[0]] = max(int(s[5]), max_res[s[0]]) -## {{{ http://code.activestate.com/recipes/511478/ (r1) -import math -import functools - -def percentile(N, percent, key=lambda x:x): - """ - Find the percentile of a list of values. - - @parameter N - is a list of values. Note N MUST BE already sorted. - @parameter percent - a float value from 0.0 to 1.0. - @parameter key - optional key function to compute value from each element of N. - - @return - the percentile of the values - """ - if not N: - return None - k = (len(N)-1) * percent - f = math.floor(k) - c = math.ceil(k) - if f == c: - return key(N[int(k)]) - d0 = key(N[int(f)]) * (c-k) - d1 = key(N[int(c)]) * (k-f) - return d0+d1 -## end of http://code.activestate.com/recipes/511478/ }}} -avg_max = 0 -avg_99th = 0 -avg_avg = 0 -print("Name\t\tAverage\t\tMax\t\t99th %\t\tAvg Mem Read\tAvg Mem Write\t") -for r in sorted(res.keys()): -# print(r + "\t\t" + str(res[r]/samples[r]) + "\t\t" + str(max_res[r])) - avg_avg += sum(res[r])/len(res[r]) - avg_max += max(res[r]) - avg_99th += percentile(sorted(res[r]), 0.99) - if len(sys.argv) > 2 and sys.argv[2] == "--inf-precision": - print("{:12}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}".format(r, sum(res[r])/len(res[r]), max(res[r]), percentile(sorted(res[r]), 0.99), mem_res[r]/samples[r], memw_res[r]/samples[r])) - else: - print("{:12.12}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}".format(r, sum(res[r])/len(res[r]), max(res[r]), percentile(sorted(res[r]), 0.99), mem_res[r]/samples[r], memw_res[r]/samples[r])) - -print("Average average:", avg_avg/len(res.keys())) -print("Average max:", avg_max/len(res.keys())) -print("Average 99th:", avg_99th/len(res.keys())) diff --git a/summarize.py b/summarize.py new file mode 100755 index 0000000..2183c41 --- /dev/null +++ b/summarize.py @@ -0,0 +1,78 @@ +#!/usr/bin/python3 +import sys + +f = sys.argv[1] +if len(sys.argv) < 2: + print("Usage "+sys.argv[0]+" --inf-precision") +res = {} +mem_res = {} +memw_res = {} +samples = {} +max_res = {} + +with open(f) as fp: + for line in fp: + s = line.split() + if s[0] not in res: +# print(s[0]) + res[s[0]] = list([int(s[5])])#)int(s[5]) + mem_res[s[0]] = int(s[8]) + memw_res[s[0]] = int(s[9]) + samples[s[0]] = int(s[4]) + max_res[s[0]] = int(s[5]) + else: + res[s[0]].append(int(s[5])) + mem_res[s[0]] += int(s[8]) + memw_res[s[0]] += int(s[9]) + max_res[s[0]] = max(int(s[5]), max_res[s[0]]) +## {{{ http://code.activestate.com/recipes/511478/ (r1) +import math +import functools + +def percentile(N, percent, key=lambda x:x): + """ + Find the percentile of a list of values. + + @parameter N - is a list of values. Note N MUST BE already sorted. + @parameter percent - a float value from 0.0 to 1.0. + @parameter key - optional key function to compute value from each element of N. + + @return - the percentile of the values + """ + if not N: + return None + k = (len(N)-1) * percent + f = math.floor(k) + c = math.ceil(k) + if f == c: + return key(N[int(k)]) + d0 = key(N[int(f)]) * (c-k) + d1 = key(N[int(c)]) * (k-f) + return d0+d1 +## end of http://code.activestate.com/recipes/511478/ }}} +def memstring(memr, memw, samples): + if memr or memw: + return "\t{:>12.f}\t{:>12.f}".format(memr/samples, memw/samples) + else: + return "" +avg_max = 0 +avg_99th = 0 +avg_avg = 0 +# Only include memory info in the header if relevant +if mem_res[s[0]] == 0: + print("Name\t\tAverage\t\tMax\t\t99th %") +else: + print("Name\t\tAverage\t\tMax\t\t99th %\t\tAvg Mem Read\tAvg Mem Write\t") +for r in sorted(res.keys()): +# print(r + "\t\t" + str(res[r]/samples[r]) + "\t\t" + str(max_res[r])) + avg_avg += sum(res[r])/len(res[r]) + avg_max += max(res[r]) + avg_99th += percentile(sorted(res[r]), 0.99) + if len(sys.argv) > 2 and sys.argv[2] == "--inf-precision": + print("{:12}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}".format(r, sum(res[r])/len(res[r]), max(res[r]), percentile(sorted(res[r]), 0.99)) + memstring(mem_res[r], memw_res[r], samples[r])) + else: + print("{:12.12}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}".format(r, sum(res[r])/len(res[r]), max(res[r]), percentile(sorted(res[r]), 0.99)) + memstring(mem_res[r], memw_res[r], samples[r])) + +print("Average average:", avg_avg/len(res.keys())) +print("Average max:", avg_max/len(res.keys())) +print("Average 99th:", avg_99th/len(res.keys())) -- cgit v1.2.2 From edb491490ccd0cae4bd28ca9c9a7e095a47c749b Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Wed, 21 Oct 2020 14:09:25 -0400 Subject: Fix infinite looping with libextra --- extra.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/extra.h b/extra.h index a15313a..30940df 100644 --- a/extra.h +++ b/extra.h @@ -125,7 +125,7 @@ static void _rt_load_params_itrl(int argc, char **argv) { _rt_will_output = atoi(argv[5]); #endif /* PAIRED */ if (_rt_max_jobs < 0 && _rt_will_output != 0) { - fprintf(stderr, "Infinite loops only supported when _rt_will_output is disabled!\n"); + fprintf(stderr, "Infinite loops only supported when output is disabled!\n"); exit(1); } if (strlen(_rt_run_id) + 5 > _RT_FILENAME_LEN) { @@ -326,28 +326,28 @@ static void _rt_load_params_itrl(int argc, char **argv) { // Buffer timing result from a single job static void _rt_save_job_result() { + if (!_rt_will_output) + return; if (_rt_jobs_complete >= _rt_max_jobs) { fprintf(stderr, "Max jobs setting too small! Trying to record job #%ld when we only have space for %ld jobs. Exiting...\n", _rt_jobs_complete, _rt_max_jobs); exit(1); } - if (_rt_jobs_complete > -1 && _rt_will_output) { #ifdef PAIRED - _rt_start_time[_rt_jobs_complete] = _rt_start.tv_sec; - _rt_start_time[_rt_jobs_complete] *= _BILLION; - _rt_start_time[_rt_jobs_complete] += _rt_start.tv_nsec; - _rt_end_time[_rt_jobs_complete] = _rt_end.tv_sec; - _rt_end_time[_rt_jobs_complete] *= _BILLION; - _rt_end_time[_rt_jobs_complete] += _rt_end.tv_nsec; + _rt_start_time[_rt_jobs_complete] = _rt_start.tv_sec; + _rt_start_time[_rt_jobs_complete] *= _BILLION; + _rt_start_time[_rt_jobs_complete] += _rt_start.tv_nsec; + _rt_end_time[_rt_jobs_complete] = _rt_end.tv_sec; + _rt_end_time[_rt_jobs_complete] *= _BILLION; + _rt_end_time[_rt_jobs_complete] += _rt_end.tv_nsec; #else - _rt_exec_time[_rt_jobs_complete] = _rt_end.tv_sec - _rt_start.tv_sec; - _rt_exec_time[_rt_jobs_complete] *= _BILLION; - _rt_exec_time[_rt_jobs_complete] += _rt_end.tv_nsec - _rt_start.tv_nsec; + _rt_exec_time[_rt_jobs_complete] = _rt_end.tv_sec - _rt_start.tv_sec; + _rt_exec_time[_rt_jobs_complete] *= _BILLION; + _rt_exec_time[_rt_jobs_complete] += _rt_end.tv_nsec - _rt_start.tv_nsec; #endif /* PAIRED */ #if MMDC_PROF - _rt_mmdc_read[_rt_jobs_complete] = mmdc_res.read_bytes; - _rt_mmdc_write[_rt_jobs_complete] = mmdc_res.write_bytes; -#endif - } + _rt_mmdc_read[_rt_jobs_complete] = mmdc_res.read_bytes; + _rt_mmdc_write[_rt_jobs_complete] = mmdc_res.write_bytes; +#endif /* MMDC_PROF */ } // Save all buffered timing results to disk @@ -465,7 +465,7 @@ static void _rt_stop_loop() { * result. We use this to call our void function from inside a comparison. */ #define for_each_job \ - for (; _rt_jobs_complete < _rt_max_jobs && (_rt_start_loop(),1); \ + for (; (_rt_max_jobs == -1 || _rt_jobs_complete < _rt_max_jobs) && (_rt_start_loop(),1); \ _rt_stop_loop()) /****** Legacy API ****** -- cgit v1.2.2 From 3b0aa125061b362b23ecf66afe8319e3a268c874 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Thu, 22 Oct 2020 00:08:12 -0400 Subject: Add pair benchmarking and isolation specification into run_bench.sh This allows `run_bench.sh` to replace all previous general paired benchmarking scripts. See `run_everything.sh` for an example of how to use the new script. This also fixes two critical bugs present in the old scripts: 1. The cpus_list was incorrectly set for resctrl when running synchronous pair timing with L2+L3 isolation (i). Each write to that file replaces the previous contents, and it was previously written once for each core. This prevented the entire 1st core from using any L3 cache. 2. The competing task list was indexed improperly in the asynchronous pair timing script. This caused the competing task to always be identical to the task being profiled. These issues combine to imply that in the rejected RTSS'20 paper: - All Level-C SMT timing data is suspect - Level-A and -B SMT timing data with L2+L3 isolation (i) is wildly optimistic --- all_pairs/run_all_pairs.sh | 168 ------------- all_pairs/run_all_pairs_L3_ONLY.sh | 170 -------------- all_pairs/tacleNames.txt | 18 +- baseline/run_baseline_L3_ONLY.sh | 152 ------------ baseline/tacleNames.txt | 18 +- run_all_tacle.sh | 58 +++++ run_bench.sh | 261 ++++++++++++++++----- run_everything.sh | 21 -- run_tacle_all.sh | 49 ---- smt_analysis_rtss20/run_all_pairs_Level-C_DIS.sh | 175 -------------- smt_analysis_rtss20/run_all_pairs_Level-C_TACLe.sh | 161 ------------- 11 files changed, 284 insertions(+), 967 deletions(-) delete mode 100755 all_pairs/run_all_pairs.sh delete mode 100755 all_pairs/run_all_pairs_L3_ONLY.sh delete mode 100755 baseline/run_baseline_L3_ONLY.sh create mode 100755 run_all_tacle.sh delete mode 100755 run_everything.sh delete mode 100755 run_tacle_all.sh delete mode 100755 smt_analysis_rtss20/run_all_pairs_Level-C_DIS.sh delete mode 100755 smt_analysis_rtss20/run_all_pairs_Level-C_TACLe.sh diff --git a/all_pairs/run_all_pairs.sh b/all_pairs/run_all_pairs.sh deleted file mode 100755 index 2260216..0000000 --- a/all_pairs/run_all_pairs.sh +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/bash - -firstCore=$1 -secondCore=$2 -maxJobs=$3 -userRunID=$4 -tacleNames=tacleNames.txt - -if [ $# -lt 4 ]; then - echo "Usage $0 [TACLe names file] [--contend]" - exit -fi - -if [ $# -gt 4 ]; then - echo "Using alternate list of TACLe benchmarks from $5" - tacleNames=$5 -fi - -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..." -while read i; do - make bin/$i -done < $tacleNames -echo "Done. Disabling real-time throttling..." - -# Turn off rt throttling -echo -1 > /proc/sys/kernel/sched_rt_runtime_us -echo "Done. Redirecting all interrupts to core 0..." - -# Redirect all interrupts to core 0 -i=0 -for IRQ in /proc/irq/* -do - # Skip default_smp_affinity - if [ -d $IRQ ]; then - irqList[$i]=$(cat $IRQ/smp_affinity_list) - echo 0 2> /dev/null > $IRQ/smp_affinity_list - fi - 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/cpu$firstCore/cpufreq/scaling_governor -echo "performance" > /sys/devices/system/cpu/cpu$secondCore/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 $firstCore > /sys/fs/resctrl/benchmarks/cpus_list -echo $secondCore > /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 -# Alloc L3 to benchmark -echo "L3:0=0000;1=0000;2=0000;3=ffff" > /sys/fs/resctrl/benchmarks/schemata -echo "MB:0=2048;1=2048;2=2048;3=2048" > /sys/fs/resctrl/benchmarks/schemata -echo "Done. Verifying configuration with user..." - -# Generate file name string -# We append to this as we parse the environment settings -runID=$(date +"%b%d-%H") - -# Confirm configuration with user -echo "=== Global Config ===" -cat /sys/fs/resctrl/schemata -echo "=== Core $firstCore and $secondCore Config ===" -cat /sys/fs/resctrl/benchmarks/schemata -if [[ $6 == "--contend" ]]; then - if [[ ! -f "/playpen/mc2/imx6q-thrasher/thrasher" ]]; then - echo "ERROR: thrasher binary not fonud. Exiting..." - exit - fi - echo "Will run 6 contending tasks" - runID=$runID-c -else - runID=$runID-xc -fi -if uname -a | grep -q "mc2"; then - echo "MC^2 Autodetected. Cache coloring will be enabled." - runID=$runID-i -else - echo "MC^2 not detected. Cache coloring will be DISABLED." - 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-A.txt and $runID-$userRunID-B.txt" -echo "Press enter to confirm environment, Ctrl-C to exit..." -read - -# Start contending tasks -if [[ $6 == "--contend" ]]; then - echo "Done. Starting 6 contending tasks..." - # Run two contending tasks on each other CCX - taskset -c 1 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 2 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 5 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 6 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 9 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 10 /playpen/mc2/imx6q-thrasher/thrasher & -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 - for (( j = $i; j < $num_tests ; j++ )) #loop through programs - 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 - # Autodetect MC^2 - if uname -a | grep -q "mc2"; then - chrt -r 97 numactl -m 0 taskset -c $firstCore ./bin/${tacleProg[$i]} ${tacleProg[$i]} $maxJobs $firstCore $secondCore ${tacleProg[$j]} $runID-$userRunID"-A" 1 & PID1=$!; - chrt -r 97 numactl -m 1 taskset -c $secondCore ./bin/${tacleProg[$j]} ${tacleProg[$j]} $maxJobs $secondCore $firstCore ${tacleProg[$i]} $runID-$userRunID"-B" 2 & PID2=$!; - else - chrt -r 97 taskset -c $firstCore ./bin/${tacleProg[$i]} ${tacleProg[$i]} $maxJobs $firstCore $secondCore ${tacleProg[$j]} $runID-$userRunID-A 1 & PID1=$!; - chrt -r 97 taskset -c $secondCore ./bin/${tacleProg[$j]} ${tacleProg[$j]} $maxJobs $secondCore $firstCore ${tacleProg[$i]} $runID-$userRunID-B 2 & PID2=$!; - fi - wait $PID1 $PID2 - done - echo ${tacleProg[$i]} ${tacleProg[$j]} - done - echo COMPLETE: ${tacleProg[$i]} -done - -# End contending tasks -if [[ $6 == "--contend" ]]; then - killall thrasher -fi - -# Remove semaphores from system -# Leaving them won't hurt these tests, but would be messy and is bad practice -# TODO: Do this directly in the benchmarks. They should clean up after themselves -./bin/cleanupSemaphores - -# Put smp_affinty back the way it was -i=0 -for IRQ in /proc/irq/* -do - if [ -d $IRQ ]; then - echo ${irqList[$i]} 2> /dev/null > $IRQ/smp_affinity_list - fi - i=$(( $i + 1 )) -done - diff --git a/all_pairs/run_all_pairs_L3_ONLY.sh b/all_pairs/run_all_pairs_L3_ONLY.sh deleted file mode 100755 index 8ed5eeb..0000000 --- a/all_pairs/run_all_pairs_L3_ONLY.sh +++ /dev/null @@ -1,170 +0,0 @@ -#!/bin/bash - -firstCore=$1 -secondCore=$2 -maxJobs=$3 -userRunID=$4 -tacleNames=tacleNames.txt - -if [ $# -lt 4 ]; then - echo "Usage $0 [TACLe names file] [--contend]" - exit -fi - -if [ $# -gt 4 ]; then - echo "Using alternate list of TACLe benchmarks from $5" - tacleNames=$5 -fi - -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..." -while read i; do - make bin/$i -done < $tacleNames -echo "Done. Disabling real-time throttling..." - -# Turn off rt throttling -echo -1 > /proc/sys/kernel/sched_rt_runtime_us -echo "Done. Redirecting all interrupts to core 0..." - -# Redirect all interrupts to core 0 -i=0 -for IRQ in /proc/irq/* -do - # Skip default_smp_affinity - if [ -d $IRQ ]; then - irqList[$i]=$(cat $IRQ/smp_affinity_list) - echo 0 2> /dev/null > $IRQ/smp_affinity_list - fi - 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 - -# Enable L3 isolation -echo "Done. Enabling L3 isolation..." -mount -t resctrl resctrl /sys/fs/resctrl -mkdir -p /sys/fs/resctrl/benchmarks -mkdir -p /sys/fs/resctrl/benchmarks2 -echo $firstCore > /sys/fs/resctrl/benchmarks/cpus_list -echo $secondCore > /sys/fs/resctrl/benchmarks2/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 -# Alloc half L3 to benchmark -echo "L3:0=0000;1=0000;2=0000;3=ff00" > /sys/fs/resctrl/benchmarks/schemata -echo "MB:0=2048;1=2048;2=2048;3=2048" > /sys/fs/resctrl/benchmarks/schemata -# Alloc other half L3 to benchmark2 -echo "L3:0=0000;1=0000;2=0000;3=00ff" > /sys/fs/resctrl/benchmarks2/schemata -echo "MB:0=2048;1=2048;2=2048;3=2048" > /sys/fs/resctrl/benchmarks2/schemata -echo "Done. Verifying configuration with user..." - -# Generate file name string -# We append to this as we parse the environment settings -runID=$(date +"%b%d-%H") - -# Confirm configuration with user -echo "=== Global Config ===" -cat /sys/fs/resctrl/schemata -echo "=== Core $firstCore Config ===" -cat /sys/fs/resctrl/benchmarks/schemata -echo "=== Core $secondCore Config ===" -cat /sys/fs/resctrl/benchmarks2/schemata -if [[ $6 == "--contend" ]]; then - if [[ ! -f "/playpen/mc2/imx6q-thrasher/thrasher" ]]; then - echo "ERROR: thrasher binary not found. Exiting..." - exit - fi - echo "Will run 6 contending tasks" - runID=$runID-c -else - runID=$runID-xc -fi -if uname -a | grep -q "mc2"; then - echo "MC^2 Autodetected. Not supported by this script!." - exit -else - echo "MC^2 not detected. Cache coloring will be enabled in the L3 only.." - runID=$runID-i3 -fi -if pwd | grep -qi dis; then - echo "Autodetected DIS. Will use script-level looping." -fi -echo "Results will be saved as $runID-$userRunID-A.txt and $runID-$userRunID-B.txt" -echo "Press enter to confirm environment, Ctrl-C to exit..." -read - -# Start contending tasks -if [[ $6 == "--contend" ]]; then - echo "Done. Starting 6 contending tasks..." - # Run two contending tasks on each other CCX - taskset -c 1 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 2 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 5 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 6 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 9 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 10 /playpen/mc2/imx6q-thrasher/thrasher & -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 - for (( j = $i; j < $num_tests ; j++ )) #loop through programs - 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 - # Autodetect MC^2 - if uname -a | grep -q "mc2"; then - chrt -r 97 numactl -m 0 taskset -c $firstCore ./bin/${tacleProg[$i]} ${tacleProg[$i]} $maxJobs $firstCore $secondCore ${tacleProg[$j]} $runID-$userRunID"-A" 1 & PID1=$!; - chrt -r 97 numactl -m 1 taskset -c $secondCore ./bin/${tacleProg[$j]} ${tacleProg[$j]} $maxJobs $secondCore $firstCore ${tacleProg[$i]} $runID-$userRunID"-B" 2 & PID2=$!; - else - chrt -r 97 taskset -c $firstCore ./bin/${tacleProg[$i]} ${tacleProg[$i]} $maxJobs $firstCore $secondCore ${tacleProg[$j]} $runID-$userRunID-A 1 & PID1=$!; - chrt -r 97 taskset -c $secondCore ./bin/${tacleProg[$j]} ${tacleProg[$j]} $maxJobs $secondCore $firstCore ${tacleProg[$i]} $runID-$userRunID-B 2 & PID2=$!; - fi - wait $PID1 $PID2 - done - echo ${tacleProg[$i]} ${tacleProg[$j]} - done - echo COMPLETE: ${tacleProg[$i]} -done - -# End contending tasks -if [[ $6 == "--contend" ]]; then - killall thrasher -fi - -# Remove semaphores from system -# Leaving them won't hurt these tests, but would be messy and is bad practice -# TODO: Do this directly in the benchmarks. They should clean up after themselves -./bin/cleanupSemaphores - -# Put smp_affinty back the way it was -i=0 -for IRQ in /proc/irq/* -do - if [ -d $IRQ ]; then - echo ${irqList[$i]} 2> /dev/null > $IRQ/smp_affinity_list - fi - i=$(( $i + 1 )) -done - diff --git a/all_pairs/tacleNames.txt b/all_pairs/tacleNames.txt index 8f4845a..2e02966 100644 --- a/all_pairs/tacleNames.txt +++ b/all_pairs/tacleNames.txt @@ -1,19 +1,23 @@ petrinet -ndes statemate -adpcm_dec +ndes +h264_dec +huff_dec cjpeg_wrbmp +fmref +audiobeam +adpcm_dec adpcm_enc +g723_enc +huff_enc +gsm_dec cjpeg_transupp -dijkstra epic -fmref -gsm_dec -h264_dec -huff_enc +anagram rijndael_enc rijndael_dec gsm_enc susan +dijkstra ammunition mpeg2 diff --git a/baseline/run_baseline_L3_ONLY.sh b/baseline/run_baseline_L3_ONLY.sh deleted file mode 100755 index 4183653..0000000 --- a/baseline/run_baseline_L3_ONLY.sh +++ /dev/null @@ -1,152 +0,0 @@ -#!/bin/bash - -core=$1 -maxJobs=$2 -userRunID=$3 -tacleNames=tacleNames.txt - -if [ $# -lt 3 ]; then - echo "Usage $0 [TACLe names file] [--contend]" - exit -fi - -if [ $# -gt 3 ]; then - echo "Using alternate list of TACLe benchmarks from $4" - tacleNames=$4 -fi - -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..." -while read i; do - make bin/$i -done < $tacleNames -echo "Done. Disabling real-time throttling..." - -# Turn off rt throttling -echo -1 > /proc/sys/kernel/sched_rt_runtime_us -echo "Done. Redirecting all interrupts to core 0..." - -# Redirect all interrupts to core 0 -i=0 -for IRQ in /proc/irq/* -do - # Skip default_smp_affinity - if [ -d $IRQ ]; then - irqList[$i]=$(cat $IRQ/smp_affinity_list) - echo 0 2> /dev/null > $IRQ/smp_affinity_list - fi - 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 - -# 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 -# 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 -# Alloc L3 to benchmark -echo "L3:0=0000;1=0000;2=0000;3=00ff" > /sys/fs/resctrl/benchmarks/schemata -echo "MB:0=2048;1=2048;2=2048;3=2048" > /sys/fs/resctrl/benchmarks/schemata -echo "Done. Verifying configuration with user..." - -# Generate file name string -# We append to this as we parse the environment settings -runID=$(date +"%b%d-%H") - -# Confirm configuration with user -echo "=== Global Config ===" -cat /sys/fs/resctrl/schemata -echo "=== Core $1 Config ===" -cat /sys/fs/resctrl/benchmarks/cpus_list -cat /sys/fs/resctrl/benchmarks/schemata -if [[ $5 == "--contend" ]]; then - if [[ ! -f "/playpen/mc2/imx6q-thrasher/thrasher" ]]; then - echo "ERROR: thrasher binary not fonud. Exiting..." - exit - fi - echo "Will run 6 contending tasks" - runID=$runID-c -else - runID=$runID-xc -fi -if uname -a | grep -q "mc2"; then - echo "MC^2 Autodetected. NOT SUPPORTED. Exiting..." - exit -else - echo "MC^2 not detected. 50% L3 allocation enabled." - runID=$runID-i3 -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 - echo "Done. Starting 6 contending tasks..." - # Run two contending tasks on each other CCX - taskset -c 1 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 2 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 5 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 6 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 9 /playpen/mc2/imx6q-thrasher/thrasher & - taskset -c 10 /playpen/mc2/imx6q-thrasher/thrasher & -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 - # 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 - 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 - fi - done - echo COMPLETE: ${tacleProg[$i]} -done - -# End contending tasks -if [[ $5 == "--contend" ]]; then - killall thrasher -fi - -# Put smp_affinty back the way it was -i=0 -for IRQ in /proc/irq/* -do - if [ -d $IRQ ]; then - echo ${irqList[$i]} 2> /dev/null > $IRQ/smp_affinity_list - fi - i=$(( $i + 1 )) -done - diff --git a/baseline/tacleNames.txt b/baseline/tacleNames.txt index 8f4845a..2e02966 100644 --- a/baseline/tacleNames.txt +++ b/baseline/tacleNames.txt @@ -1,19 +1,23 @@ petrinet -ndes statemate -adpcm_dec +ndes +h264_dec +huff_dec cjpeg_wrbmp +fmref +audiobeam +adpcm_dec adpcm_enc +g723_enc +huff_enc +gsm_dec cjpeg_transupp -dijkstra epic -fmref -gsm_dec -h264_dec -huff_enc +anagram rijndael_enc rijndael_dec gsm_enc susan +dijkstra ammunition mpeg2 diff --git a/run_all_tacle.sh b/run_all_tacle.sh new file mode 100755 index 0000000..c0f07cc --- /dev/null +++ b/run_all_tacle.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# Copyright 2020 Joshua Bakita +# Runs TACLeBench in every configuration needed +# for the paper and schedulability studies + +maxJobs=$1 +runID=$2 + +if [ $# -lt 2 ]; then + echo "Usage $0 " + exit +fi +date + +# Run the pairs baseline and some comparisons to examine the effect of less cache +cd baseline +make all -j32 +# Full L3, full L2 - xi is the baseline for the pairs +baseXI=baseline/$(date +"%b%d-%H")-c-xi-$runID.txt +echo "" | ../run_bench.sh -m base -p 15 -l $maxJobs -b tacleNames.txt -B -I xi $runID +# Half L3, full L2 - i3 sees effect of half L3 +baseI3=baseline/$(date +"%b%d-%H")-c-i3-$runID.txt +echo "" | ../run_bench.sh -m base -p 15 -l $maxJobs -b tacleNames.txt -B -I i3 $runID +# Half L3, half L2 - additional effect of half L2 +baseI=baseline/$(date +"%b%d-%H")-c-i-$runID.txt +echo "" | ../run_bench.sh -m base -p 15 -l $maxJobs -b tacleNames.txt -B -I i $runID +date + +# Run the Level-A/-B pairs +cd ../all_pairs +make all -j32 +# No cache isolation +pairXI=all_pairs/$(date +"%b%d-%H")-c-xi-$runID.txt +echo "" | ../run_bench.sh -m pair -p 15 -P 31 -l $maxJobs -b tacleNames.txt -B -I xi $runID +# Shared L2, split L3 +pairI3=all_pairs/$(date +"%b%d-%H")-c-i3-$runID.txt +echo "" | ../run_bench.sh -m pair -p 15 -P 31 -l $maxJobs -b tacleNames.txt -B -I i3 $runID +# Split L2, split L3 +pairI=all_pairs/$(date +"%b%d-%H")-c-i-$runID.txt +echo "" | ../run_bench.sh -m pair -p 15 -P 31 -l $maxJobs -b tacleNames.txt -B -I i $runID +date + +# Run the Level-C pairs +cd ../baseline +pairC=baseline/$(date +"%b%d-%H")-c-xi-async-$runID.txt +echo "" | ../run_bench.sh -m pair -p 15 -P 31 -l $maxJobs -b tacleNames.txt -B -I xi -A $runID +date + +echo "==== DONE ====" +echo "Results are in:" +echo "- $baseXI" +echo "- $baseI3" +echo "- $baseI" +echo "- $pairXI" +echo "- $pairI3" +echo "- $pairI" +echo "- $pairC" + diff --git a/run_bench.sh b/run_bench.sh index 4e09faa..250d843 100755 --- a/run_bench.sh +++ b/run_bench.sh @@ -1,24 +1,43 @@ #!/bin/bash +# Copyright 2020 Joshua Bakita +# A unified script for timing: +# - SMT pairs with synchronous launches (hard real-time methodolgy) +# - SMT pairs with asynchronous launches (soft real-time methodolgy) +# - Unpaired tasks +# - The cache alloc vs WSS setting exploration for DIS +# These can all be done with: +# - No cache management +# - L3 cache splitting +# - L2+L3 cache splitting (if OS supported) + +if grep -q "#define LITMUS 1" ../extra.h ./extra.h 2> /dev/null; then + LITMUS=1 +fi 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 "Usage $0 -m MODE -p CPU -l LOOPS -b FILE [-B] [-I] RUN_ID" + echo " -m base|dis|pair 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 " -I xi|i3|i Isolation mode: none (xi) (default), way-based" + echo " L3-only (i3), or color-based L2+L3 (i)" 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 + echo "Mode pair options:" + echo " -P CPU CPU to run the 2nd benchmark on" + echo " -A Async. (Don't synchronize the pair at job" + echo " boundries.) Typically used SMT in soft realtime" fi # Name options similarly to rtspin -while getopts “m:p:l:b:BW:T:C:” opt; do +while getopts “m:p:l:b:BI:W:T:C:P:A” opt; do case $opt in # Required m) mode=$OPTARG ;; @@ -27,9 +46,14 @@ while getopts “m:p:l:b:BW:T:C:” opt; do b) benchNames=$OPTARG ;; # Optional B) contend=1 ;; + I) iso_mode=$OPTARG ;; +# DIS W) wss_settings=$OPTARG ;; T) template_input=$OPTARG ;; C) cache_settings=$OPTARG ;; +# Pair + P) core_two=$OPTARG ;; + A) async=1 ;; esac done # Reset to read operands @@ -37,7 +61,7 @@ shift $((OPTIND -1)) userRunID=$1 # Required argument checking -if [[ "$mode" != "base" ]] && [[ "$mode" != "dis" ]]; then +if [[ "$mode" != "base" && "$mode" != "dis" && $mode != pair ]]; then echo "Invalid argument: MODE must be either 'base' or 'dis'" exit fi @@ -72,14 +96,37 @@ if [[ "$mode" == "dis" ]] && [[ ! -f "$cache_settings" ]]; then exit fi +# Pair argument checking +if [[ "$mode" == "pair" && ! -v core_two ]]; then + echo "Missing argument: mode=pair reqires -P" + exit +fi +if [[ "$mode" != "pair" ]] && [[ -v async || -v core_two ]]; then + echo "Invalid argument: -A and -P require mode=pair" + exit +fi + +# Additional checks +if [[ $userRunID == "" ]]; then + echo "Missing argument: a run ID is required" + exit +fi +if [[ -v contend && ! -f "/playpen/mc2/imx6q-thrasher/thrasher" ]]; then + echo "ERROR: cannot find thrasher binary for -B. Exiting..." + exit +fi +if [[ $iso_mode == "i" && ! $(uname -a | grep "mc2") ]]; then + echo "Isolation mode 'i' requires the MC^2 kernel. Exiting..." + exit +fi + # Check permissions and update state -if [ "$EUID" -ne 0 ] -then +if [[ "$EUID" != 0 ]]; then echo "You need to be root to enable interrupt isolation and real-time execution!" exit fi -echo "Done. Loading benchmark names and input..." +echo "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 @@ -96,11 +143,16 @@ done < $benchNames echo "Making sure that binaries are up to date..." for b in ${bench[@]}; do - make bin/$b - if [[ $? ]]; then + # Build "bin/bench" if bin directory + if [[ -d bin ]]; then + make bin/$b + fi + # If that failed, try a different name + if [[ "$?" != 0 || ! -d bin ]]; then make $b fi - if [[ ! -f $b && ! -f "./bin/$b" ]]; then + # If bench is still not in bin or curr dir, fail + if [[ ! -f "./$b" && ! -f "./bin/$b" ]]; then echo "Unable to find benchmark $b" exit fi @@ -123,26 +175,86 @@ do i=$(( $i + 1 )) done +echo "Done. Creating cleanup handler..." +function cleanup { + # End contending tasks + if [[ -v contend ]]; then + killall thrasher + fi + + # Restore cache access to everyone + echo "L3:0=ffff;1=ffff;2=ffff;3=ffff" > /sys/fs/resctrl/schemata + if [[ -e /sys/fs/resctrl/benchmarks ]]; then + echo "" > /sys/fs/resctrl/benchmarks/cpus_list + fi + if [[ -e /sys/fs/resctrl/benchmarks2 ]]; then + echo "" > /sys/fs/resctrl/benchmarks2/cpus_list + fi + + # Put smp_affinty back the way it was + i=0 + for IRQ in /proc/irq/* + do + if [ -d $IRQ ]; then + echo ${irqList[$i]} 2> /dev/null > $IRQ/smp_affinity_list + fi + i=$(( $i + 1 )) + done +} +# This sets the cleanup function to be called when we exit for any reason +trap cleanup EXIT + echo "Done. Checking for wbinvd module..." if [[ ! -f "/proc/wbinvd" ]]; then echo "ERROR: wbinvd module not loaded. Exiting..." exit fi -echo "Done. Setting core $core to 'performance'..." +echo "Done. Setting cores to 'performance'..." echo "performance" > /sys/devices/system/cpu/cpu$core/cpufreq/scaling_governor +if [[ -v core_two ]]; then + echo "performance" > /sys/devices/system/cpu/cpu$core_two/cpufreq/scaling_governor +fi # Enable L3 isolation -echo "Done. Enabling L3 isolation..." +echo "Done. Setting up L3 isolation..." mount -t resctrl resctrl /sys/fs/resctrl -mkdir -p /sys/fs/resctrl/benchmarks -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 # Alloc L3 to benchmark -echo "L3:0=0000;1=0000;2=0000;3=ffff" > /sys/fs/resctrl/benchmarks/schemata -echo "MB:0=2048;1=2048;2=2048;3=2048" > /sys/fs/resctrl/ben