2022-12-13 15:35:41 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-01-23 22:50:37 +01:00
|
|
|
[[ -z "$1" ]] && echo "Use: $0 <binary> [-c <core>] [-f <freq>] [-n <nruns>] [-l <log>] [-s]" && exit
|
|
|
|
[[ ! -f "$1" ]] && echo "Binary file not found, make sure to use 'make'" && exit
|
|
|
|
[[ ! -f "$1-stub" ]] && echo "Binary file for stubbed case not found, make sure to use 'make VARIANT=stub'" && exit
|
|
|
|
|
|
|
|
MDBENCH_BIN=$1
|
|
|
|
BIN_INFO="${MDBENCH_BIN#*-}" # $OPT_SCHEME-$TAG-$ISA-$PREC
|
|
|
|
OPT_SCHEME="${BIN_INFO%%-*}"
|
|
|
|
PREC="${BIN_INFO##*-}"
|
|
|
|
BIN_INFO="${BIN_INFO#*-}" # $TAG-$ISA-$PREC
|
|
|
|
BIN_INFO="${BIN_INFO%-*}" # $TAG-$ISA
|
|
|
|
TAG="${BIN_INFO%%-*}"
|
|
|
|
ISA="${BIN_INFO##*-}"
|
2022-12-21 18:04:18 +01:00
|
|
|
CORE="${CORE:-0}"
|
|
|
|
FREQ="${FREQ:-2.4}"
|
|
|
|
NRUNS="${NRUNS:-3}"
|
|
|
|
LOG="${LOG:-latencies_and_cfds.log}"
|
|
|
|
STUB_ONLY="${STUB_ONLY:-false}"
|
|
|
|
|
2023-01-23 22:54:44 +01:00
|
|
|
OPTIND=2
|
|
|
|
while getopts "c:f:n:l:s" flag; do
|
2023-01-23 22:50:37 +01:00
|
|
|
case "${flag}" in
|
|
|
|
c) CORE=${OPTARG};;
|
|
|
|
f) FREQ=${OPTARG};;
|
|
|
|
n) NRUNS=${OPTARG};;
|
|
|
|
l) LOG=${OPTARG};;
|
|
|
|
s) STUB_ONLY=true;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2022-12-21 18:04:18 +01:00
|
|
|
# Other useful variables
|
2023-01-23 22:50:37 +01:00
|
|
|
MDBENCH_BIN=./MDBench-$OPT_SCHEME-$TAG-$ISA-$PREC
|
2022-12-20 18:51:54 +01:00
|
|
|
FIXED_PARAMS="--freq $FREQ"
|
|
|
|
CPU_VENDOR=$(lscpu | grep "Vendor ID" | tr -s ' ' | cut -d ' ' -f3)
|
2022-12-13 15:35:41 +01:00
|
|
|
|
2022-12-20 18:51:54 +01:00
|
|
|
if [ "$CPU_VENDOR" == "GenuineIntel" ]; then
|
|
|
|
ALL_PREFETCHERS="HW_PREFETCHER,CL_PREFETCHER,DCU_PREFETCHER,IP_PREFETCHER"
|
|
|
|
PREFETCHERS=("ALL HW_PREFETCHER CL_PREFETCHER DCU_PREFETCHER IP_PREFETCHER NONE")
|
2022-12-14 17:54:18 +01:00
|
|
|
else
|
2022-12-20 18:51:54 +01:00
|
|
|
ALL_PREFETCHERS=""
|
|
|
|
PREFETCHERS=("IGNORE")
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$OPT_SCHEME" == "gromacs" ]; then
|
|
|
|
STUB1_NAME=stub-33
|
|
|
|
STUB1_PARAMS="-na 4 -nn 33"
|
|
|
|
STUB2_NAME=stub-128
|
|
|
|
STUB2_PARAMS="-na 4 -nn 128"
|
|
|
|
else
|
|
|
|
STUB1_NAME=stub-76
|
|
|
|
STUB1_PARAMS="-nn 76"
|
|
|
|
STUB2_NAME=stub-1024
|
|
|
|
STUB2_PARAMS="-nn 1024"
|
2022-12-14 17:54:18 +01:00
|
|
|
fi
|
|
|
|
|
2022-12-13 15:35:41 +01:00
|
|
|
function run_benchmark() {
|
2022-12-20 18:51:54 +01:00
|
|
|
BEST=10000000
|
2022-12-13 15:35:41 +01:00
|
|
|
for i in $(seq $NRUNS); do
|
2022-12-20 18:51:54 +01:00
|
|
|
RES=$(likwid-pin -c $CORE "$* $FIXED_PARAMS" 2>&1 | grep "Cycles/SIMD iteration" | cut -d ' ' -f3)
|
|
|
|
if (( $(echo "$BEST > $RES" | bc -l ) )); then
|
|
|
|
BEST=$RES
|
|
|
|
fi
|
2022-12-13 15:35:41 +01:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-12-20 18:51:54 +01:00
|
|
|
echo "Tag: $TAG" | tee -a $LOG
|
|
|
|
echo "Optimization scheme: $OPT_SCHEME" | tee -a $LOG
|
2023-01-23 22:50:37 +01:00
|
|
|
echo "Instruction set: $ISA" | tee -a $LOG
|
|
|
|
echo "Precision: $PREC" | tee -a $LOG
|
2022-12-20 18:51:54 +01:00
|
|
|
echo "Binary: $MDBENCH_BIN(-stub)" | tee -a $LOG
|
|
|
|
echo "Frequency: $FREQ" | tee -a $LOG
|
|
|
|
echo "Number of runs: $NRUNS" | tee -a $LOG
|
2022-12-21 18:04:18 +01:00
|
|
|
echo "Run only stubbed cases: $STUB_ONLY" | tee -a $LOG
|
2022-12-13 15:47:17 +01:00
|
|
|
|
|
|
|
echo "Fixing frequencies..."
|
|
|
|
likwid-setFrequencies -f $FREQ -t 0
|
|
|
|
|
2022-12-20 18:51:54 +01:00
|
|
|
for p in $PREFETCHERS; do
|
|
|
|
if [ "$p" != "IGNORE" ]; then
|
|
|
|
if [ "$p" == "ALL" ]; then
|
|
|
|
likwid-features -c $CORE -e $ALL_PREFETCHERS
|
|
|
|
elif [ "$p" == "NONE" ]; then
|
|
|
|
likwid-features -c $CORE -d $ALL_PREFETCHERS
|
|
|
|
else
|
|
|
|
likwid-features -c $CORE -d $ALL_PREFETCHERS
|
|
|
|
likwid-features -c $CORE -e $p
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Prefetcher settings: $p"
|
|
|
|
likwid-features -c $CORE -l
|
|
|
|
fi
|
|
|
|
|
|
|
|
MSG="$p: "
|
2022-12-21 18:04:18 +01:00
|
|
|
if [ "$STUB_ONLY" == "false" ]; then
|
|
|
|
run_benchmark $MDBENCH_BIN
|
|
|
|
MSG+="standard=$BEST, "
|
|
|
|
run_benchmark $MDBENCH_BIN -i data/copper_melting/input_lj_cu_one_atomtype_20x20x20.dmp
|
|
|
|
MSG+="melt=$BEST, "
|
|
|
|
run_benchmark $MDBENCH_BIN -p data/argon_1000/mdbench_params.conf -i data/argon_1000/tprout.gro
|
|
|
|
MSG+="argon=$BEST, "
|
|
|
|
fi
|
|
|
|
|
2022-12-20 18:51:54 +01:00
|
|
|
run_benchmark $MDBENCH_BIN-stub $STUB1_PARAMS
|
|
|
|
MSG+="$STUB1_NAME=$BEST, "
|
|
|
|
run_benchmark $MDBENCH_BIN-stub $STUB2_PARAMS
|
|
|
|
MSG+="$STUB2_NAME=$BEST"
|
|
|
|
echo $MSG | tee -a $LOG
|
|
|
|
done
|