From dd8c08f3ee2633e9b7392b2f870492f97ea9c986 Mon Sep 17 00:00:00 2001 From: Thara Gopinath Date: Mon, 20 Sep 2021 11:10:12 -0400 Subject: Initial commit with scripts and dhrystone binary Signed-off-by: Thara Gopinath --- bin/dhrystone | Bin 0 -> 4884472 bytes dhrystone-performance-opp.sh | 92 +++++++++++++++++++++++++++++++++++++++++++ record-temp.sh | 44 +++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100755 bin/dhrystone create mode 100755 dhrystone-performance-opp.sh create mode 100755 record-temp.sh diff --git a/bin/dhrystone b/bin/dhrystone new file mode 100755 index 0000000..a24ec03 Binary files /dev/null and b/bin/dhrystone differ diff --git a/dhrystone-performance-opp.sh b/dhrystone-performance-opp.sh new file mode 100755 index 0000000..7ad9a13 --- /dev/null +++ b/dhrystone-performance-opp.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +#CPU_BASE=cpu4 +#CPU_GROUP=$(cat /sys/devices/system/cpu/$CPU_BASE/cpufreq/related_cpus) +#NR_CPUS=$(echo $CPU_GROUP | wc -w) +#CPU_GROUP=$(echo $CPU_GROUP | tr ' ' ',') +MSG=10000 + +OUTPUT_FILE="dhry-output" +rm -Rf $OUTPUT_FILE + +#Check if workload cpu and stat cpu are valid +if [ "$#" -ne "2" ]; +then + echo "Please specify workload cpu and stat collection cpu" + exit 1 +fi +WORK_CPU=$1 +STAT_CPU=$2 +if [ "$WORK_CPU" -lt "0" ] || [ "$WORK_CPU" -gt "7" ]; +then + echo "Invalid workload cpu. Enter cpu number between 0 and 7" + exit 1 +fi +if [ "$STAT_CPU" -lt "0" ] || [ "$STAT_CPU" -gt "7" ]; +then + echo "Invalid stat collection cpu. Enter cpu number between 0 and 7" + exit 1 +fi + +#WORK_CPU=$(echo "cpu"$WORK_CPU) + +echo "Workload cpu is: $WORK_CPU; Stat Collection cpu is: $STAT_CPU" +# Check we are root +if [ "$(id -u)" != "0" ]; then + echo "Script needs the root privilege" + exit 1 +fi + +# Check the userspace governor exists +cat /sys/devices/system/cpu/cpu$WORK_CPU/cpufreq/scaling_available_governors | grep -q userspace +RET=$? +if [ "$RET" != "0" ]; +then + echo "No 'userspace' governor available" + exit 1 +fi + +# Check the dhrystone binary is accessible +#DHRYSTONE=$(which dhrystone) +#if [ "$DHRYSTONE" == "" ]; then +# echo "No dhrystone program found" +# exit 1 +#fi + +DHRYSTONE="bin/dhrystone" + +# Grab all the frequencies +FREQUENCIES=$(cat /sys/devices/system/cpu/cpu$WORK_CPU/cpufreq/scaling_available_frequencies) + +# Save the old governor +OLD_GOVERNOR=$(cat /sys/devices/system/cpu/cpu$WORK_CPU/cpufreq/scaling_governor) + +#Change governor to userspace +echo userspace > /sys/devices/system/cpu/cpu$WORK_CPU/cpufreq/scaling_governor + + +# Run test pinning to WORK_CPU + +echo +echo "Testing one process pinned to cpu $WORK_CPU" +echo + +for i in $FREQUENCIES; +do + echo "Testing at frequency: "$i + echo "##### Testing at frequency: $i #####" >> $OUTPUT_FILE + echo $i > /sys/devices/system/cpu/cpu$WORK_CPU/cpufreq/scaling_setspeed + taskset -c $STAT_CPU ./record-temp.sh $WORK_CPU >> $OUTPUT_FILE & + pid=$! + taskset -c $WORK_CPU $DHRYSTONE -t 1 -l $MSG >> $OUTPUT_FILE + echo >> $OUTPUT_FILE + kill $pid + sleep 1 + echo >> $OUTPUT_FILE + echo >> $OUTPUT_FILE +done + +# Set back the previous governor +echo $OLD_GOVERNOR > /sys/devices/system/cpu/cpu$WORK_CPU/cpufreq/scaling_governor + +echo "Testing Done. Results Available in "$OUTPUT_FILE diff --git a/record-temp.sh b/record-temp.sh new file mode 100755 index 0000000..a2478e4 --- /dev/null +++ b/record-temp.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +tzone_array=( "$@" ) +OUTPUT_DIR="output" + +trap 'gather_results' EXIT +gather_results() +{ + for tzone in ${tzone_array[@]} + do + echo "Thermal Zone "$tzone":" + FILE="$OUTPUT_DIR/temp_tzone_$tzone" + awk 'BEGIN { total = 0 + count=0 + } + { if(max== "" || $1 > max) {max=$1} + total=total+$1 + count++ + } + END { avg=total/count + print ("Max Temp: " max, "Avg Temp: " avg) + }' $FILE + done + exit +} + +mkdir -p $OUTPUT_DIR + +for tzone in ${tzone_array[@]} +do + FILE="$OUTPUT_DIR/temp_tzone_$tzone" + rm -Rf $FILE +done + +while : +do + for tzone in ${tzone_array[@]} + do + temp=$(cat /sys/class/thermal/thermal_zone$tzone/temp) + FILE="$OUTPUT_DIR/temp_tzone_$tzone" + echo $temp >> $FILE + done + sleep 1 +done -- cgit v1.2.3