ampere_research/pytorch/power.sh.bak
2024-12-09 10:57:15 -05:00

32 lines
834 B
Bash

#! /bin/bash
baseline_time_s="$1"
arch=$(uname -m)
if [[ $arch = aarch64 ]]; then
iter=0
function aarch64_power {
sensors | awk '/CPU power:/ {print $3; exit}'
((iter++))
sleep 1s
}
if [[ -z "$baseline_time_s" ]]; then
baseline_time_s=-1
fi
while [[ "$iter" -ne "$baseline_time_s" ]]; do
aarch64_power
done
elif [[ $arch = x86_64 ]]; then
if [[ -z "$baseline_time_s" ]]; then
#turbostat -s PkgWatt -i 1 2>/dev/null | awk -F: '/PkgWatt/ {getline; print $0}'
#turbostat -s PkgWatt -i 1 | awk '/PkgWatt/ {getline; print $0}'
turbostat -s PkgWatt -i 1 | sed -n "/PkgWatt/{n;p}"
else
#turbostat -s PkgWatt -n "$baseline_time_s" -i 1 2>/dev/null | awk -F: '/PkgWatt/ {getline; print $0}'
turbostat -s PkgWatt -n "$baseline_time_s" -i 1 | sed -n "/PkgWatt/{n;p}"
fi
else
echo "Unrecognized arch!"
exit 1
fi