summaryrefslogtreecommitdiffstats
path: root/all_pairs/Makefile
Commit message (Expand)AuthorAge
* Unify all the versions of extra.h into a single multipurpose headerJoshua Bakita2020-10-19
* Reorganize and commit all the modified TACLeBench code and run scriptsJoshua Bakita2019-10-07
'>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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
#!/bin/bash

firstCore=$1
secondCore=$2
maxJobs=$3
userRunID=$4
#template_input=$9
tacleNames=tacleNames.txt

if [ $# -lt 7 ]; then
    echo "Usage $0 <first core ID> <second core ID> <number of iterations> <run ID> [bench names file] [WSS setings] [cache settings] [--contend]" # [input file]"
    exit
fi

if [ $# -gt 4 ]; then
    echo "Using list of benchmarks from $5"
    tacleNames=$5
fi

if [ $# -gt 5 ]; then
    echo "Using WSS settings from $6"
    wss_settings=$6
fi

if [ $# -gt 6 ]; then
    echo "Using cache settings from $7"
    cache_settings=$7
fi
#echo "Using template input from $9"

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/cpu15/cpufreq/scaling_governor
echo "performance" > /sys/devices/system/cpu/cpu31/cpufreq/scaling_governor

# 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 L3 to benchmark
echo "L3:0=0000;1=0000;2=0000;3=ffff" > /sys/fs/resctrl/benchmarks/schemata
echo "L3:0=0000;1=0000;2=0000;3=ffff" > /sys/fs/resctrl/benchmarks2/schemata
echo "MB:0=2048;1=2048;2=2048;3=2048" > /sys/fs/resctrl/benchmarks/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 and $secondCore Config ==="
cat /sys/fs/resctrl/benchmarks/schemata
if [[ $8 == "--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. This benchmark requires MC^2! Exiting..."
    exit
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 [[ $8 == "--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 (( ii = 0; ii < $num_tests ; ii++ ))
do
    for (( jj = $ii+1; jj < $num_tests ; jj++ ))  #loop through programs
    do
# Execute the benchmark for each WSS and cache config
while read k; do
    echo $k > /sys/fs/resctrl/benchmarks/schemata
    while read j; do
        echo $j > /sys/fs/resctrl/benchmarks2/schemata
        while read i; do
            ./gen_input.py matrix inputs/Matrix/in0 $i | chrt -r 97 numactl -m 0 taskset -c $firstCore ./${tacleProg[$ii]} ${tacleProg[$ii]}-$i-$k $maxJobs $firstCore $secondCore ${tacleProg[$jj]}-$i-$j $runID-$userRunID-A 1 > /dev/null & PID1=$!;
            ./gen_input.py transitive inputs/Transitive/in0 $i | chrt -r 97 numactl -m 1 taskset -c $secondCore ./${tacleProg[$jj]} ${tacleProg[$jj]}-$i-$j $maxJobs $secondCore $firstCore ${tacleProg[$ii]}-$i-$k $runID-$userRunID-B 2 > /dev/null & PID2=$!;
            wait $PID1 $PID2
        done < $wss_settings
        echo "Done with $k $j"
    done < $cache_settings
done < $cache_settings

#        ./gen_input.py $benchmark $template_input $i | chrt -r 97 numactl -m 0 taskset -c $core ./$benchmark $benchmark-$i-$j $maxJobs $core $runID 1
#        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=$!;
#        wait $PID1 $PID2
        echo ${tacleProg[$i]} ${tacleProg[$j]}
    done
    echo COMPLETE: ${tacleProg[$i]}
done

# End contending tasks
if [[ $8 == "--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