Mostly finish TDP script
This commit is contained in:
parent
609712d4bd
commit
348bc0de07
60
scripts/tdp
60
scripts/tdp
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
# Global vars/settings
|
# Global vars/settings
|
||||||
command_name=$(basename $0)
|
command_name=$(basename $0)
|
||||||
rapl_base="/sys/class/powercap/intel-rapl:0"
|
#rapl_path="/sys/class/powercap/intel-rapl:0"
|
||||||
pl1_path="${rapl_base}/constraint_0_power_limit_uw"
|
rapl_path="testfolder"
|
||||||
pl2_path="${rapl_base}/constraint_1_power_limit_uw"
|
pl1_path="${rapl_path}/constraint_0_power_limit_uw"
|
||||||
|
pl2_path="${rapl_path}/constraint_1_power_limit_uw"
|
||||||
|
|
||||||
# Set up help text
|
# Set up help text
|
||||||
help_text="${command_name}: GDP Win 3 TDP management script
|
help_text="${command_name}: GDP Win 3 TDP management script
|
||||||
|
@ -77,16 +78,47 @@ w_to_uw () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Common checks/tasks
|
||||||
|
is_detailed () {
|
||||||
|
if [[ "$@" == *"--detail"* ]] || [[ "$@" == *"-d"* ]]; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
set_pl () {
|
||||||
|
if [ $1 -eq 1 ] || [ $1 -eq 2 ] || [ ! -z $2 ]; then
|
||||||
|
if [ $1 -eq 1 ]; then
|
||||||
|
pl_path=$pl1_path
|
||||||
|
elif [ $1 -eq 2 ]; then
|
||||||
|
pl_path=$pl2_path
|
||||||
|
fi
|
||||||
|
echo $(w_to_uw $2) > $pl_path
|
||||||
|
echo $pl_path
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_pl () {
|
||||||
|
if [ $1 -eq 1 ]; then
|
||||||
|
cat $pl1_path
|
||||||
|
elif [ $1 -eq 2 ]; then
|
||||||
|
cat $pl2_path
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Retrieves current TDP and prints it
|
# Retrieves current TDP and prints it
|
||||||
check_tdp () {
|
check_tdp () {
|
||||||
if [[ "$@" == *"--detail"* ]] || [[ "$@" == *"-d"* ]]; then
|
if [ -z "$1" ] || ( is_detailed $@ ); then
|
||||||
local detailed=yes
|
local pl1=$(uw_to_w $(get_pl 1))
|
||||||
fi
|
local pl2=$(uw_to_w $(get_pl 2))
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
echo "PL1 is ${pl1}W" # Placeholder
|
||||||
echo "PL1 is $(uw_to_w 10000000)W" # Placeholder
|
if ( is_detailed $@ ); then
|
||||||
if [ $detailed == "yes" ]; then
|
echo "PL2 is ${pl2}W" # Placeholder
|
||||||
echo "PL2 is $(uw_to_w 12000000)W" # Placeholder
|
fi
|
||||||
|
|
||||||
elif [ "$1" == "--help" ]; then
|
elif [ "$1" == "--help" ]; then
|
||||||
print_help "check"
|
print_help "check"
|
||||||
|
@ -116,15 +148,15 @@ set_tdp () {
|
||||||
else
|
else
|
||||||
#PL1
|
#PL1
|
||||||
local watts=$1
|
local watts=$1
|
||||||
local uwatts=$(w_to_uw $watts)
|
set_pl 1 $watts
|
||||||
|
|
||||||
#PL2
|
#PL2
|
||||||
local watts2=$(expr $watts + 2)
|
local watts2=$(expr $watts + 2)
|
||||||
local uwatts2=$(w_to_uw $watts2)
|
set_pl 2 $watts2
|
||||||
|
|
||||||
|
|
||||||
echo $uwatts
|
|
||||||
echo "PL1 is now ${watts}W (Long-term)"
|
echo "PL1 is now ${watts}W (Long-term)"
|
||||||
if [[ "$@" == *"--detail"* ]] || [[ "$@" == *"-d"* ]]; then
|
if ( is_detailed $@ ); then
|
||||||
echo "PL2 is now ${watts2}W (Short-term)"
|
echo "PL2 is now ${watts2}W (Short-term)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue