Update 'scripts/tdp'
This commit is contained in:
parent
f59fb295fc
commit
609712d4bd
40
scripts/tdp
40
scripts/tdp
|
@ -1,7 +1,12 @@
|
||||||
#! /usr/bin/bash
|
#! /usr/bin/bash
|
||||||
|
|
||||||
# Set up help text
|
# Global vars/settings
|
||||||
command_name=$(basename $0)
|
command_name=$(basename $0)
|
||||||
|
rapl_base="/sys/class/powercap/intel-rapl:0"
|
||||||
|
pl1_path="${rapl_base}/constraint_0_power_limit_uw"
|
||||||
|
pl2_path="${rapl_base}/constraint_1_power_limit_uw"
|
||||||
|
|
||||||
|
# Set up help text
|
||||||
help_text="${command_name}: GDP Win 3 TDP management script
|
help_text="${command_name}: GDP Win 3 TDP management script
|
||||||
|
|
||||||
This script checks and sets the TDP using intel_rapl
|
This script checks and sets the TDP using intel_rapl
|
||||||
|
@ -55,14 +60,33 @@ print_unknown () {
|
||||||
}
|
}
|
||||||
# End of help text
|
# End of help text
|
||||||
|
|
||||||
|
# Conversion tools
|
||||||
|
uw_to_w () {
|
||||||
|
if ! [[ $1 =~ ^-?[0-9]+$ ]]; then
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
echo $(expr $1 / 1000000)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
w_to_uw () {
|
||||||
|
if ! [[ $1 =~ ^-?[0-9]+$ ]]; then
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
echo $(expr $1 '*' 1000000)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Retrieves current TDP and prints it
|
# Retrieves current TDP and prints it
|
||||||
check_tdp () {
|
check_tdp () {
|
||||||
if [[ "$@" == *"--detail"* ]] || [[ "$@" == *"-d"* ]]; then
|
if [[ "$@" == *"--detail"* ]] || [[ "$@" == *"-d"* ]]; then
|
||||||
echo "Placeholder"
|
local detailed=yes
|
||||||
echo "Extra placeholder"
|
fi
|
||||||
|
|
||||||
elif [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "Placeholder"
|
echo "PL1 is $(uw_to_w 10000000)W" # Placeholder
|
||||||
|
if [ $detailed == "yes" ]; then
|
||||||
|
echo "PL2 is $(uw_to_w 12000000)W" # Placeholder
|
||||||
|
|
||||||
elif [ "$1" == "--help" ]; then
|
elif [ "$1" == "--help" ]; then
|
||||||
print_help "check"
|
print_help "check"
|
||||||
|
@ -72,7 +96,7 @@ check_tdp () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Sets TDP to number provided as first argument
|
# Sets PL1 to number provided as first argument, and PL2 2W higher
|
||||||
set_tdp () {
|
set_tdp () {
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "Please specify wattage"
|
echo "Please specify wattage"
|
||||||
|
@ -92,11 +116,11 @@ set_tdp () {
|
||||||
else
|
else
|
||||||
#PL1
|
#PL1
|
||||||
local watts=$1
|
local watts=$1
|
||||||
local uwatts=$(expr $watts '*' 1000000)
|
local uwatts=$(w_to_uw $watts)
|
||||||
|
|
||||||
#PL2
|
#PL2
|
||||||
local watts2=$(expr $watts + 2)
|
local watts2=$(expr $watts + 2)
|
||||||
local uwatts2=$(expr $watts2 '*' 1000000)
|
local uwatts2=$(w_to_uw $watts2)
|
||||||
|
|
||||||
echo $uwatts
|
echo $uwatts
|
||||||
echo "PL1 is now ${watts}W (Long-term)"
|
echo "PL1 is now ${watts}W (Long-term)"
|
||||||
|
|
Loading…
Reference in New Issue