make power multi var generic, attribute of each profile

This commit is contained in:
Josh Lay 2022-11-26 22:43:52 -06:00
parent 4dff0b95ab
commit 40028e5229
Signed by: jlay
GPG key ID: B265E45CACAD108A
3 changed files with 29 additions and 37 deletions

View file

@ -1,17 +1,14 @@
--- ---
# misc default vars handling unit conversion RE: power capabilities/limits # misc default vars handling unit conversion RE: power capabilities/limits
# #
# the discovered board limit for power capability # the discovered board limit for power capability (in microWatts)
power_max: "{{ power_max_b64['content'] | b64decode }}" power_max: "{{ power_max_b64['content'] | b64decode }}"
board_watts: "{{ power_max|int/1000000 }}"
# convert discovered board power limit (int) to a float # internals for profile power calculations
# for some math in the tuned config template # item in the context of the with_nested loops in the play
power_max_float: "{{ power_max_b64['content'] | b64decode |float }}" profile_name: "{{ item.0.key }}"
profile_percentage: "{{ (item.0.value.pwr_cap_multi * 100.0) | round(2) }}"
# determine the microWatt limits based on the provided multipliers profile_multi: "{{ item.0.value.pwr_cap_multi }}"
power_cap_custom_float: "{{ power_max |float * power_max_custom_multi }}" profile_microwatts: "{{ power_max | float * profile_multi | float }}"
power_cap_default_float: "{{ power_max |float * power_max_default_multi }}" profile_watts: "{{ profile_microwatts | int/1000000 }}"
# convert the microWatt limits to ints for some math - also in the tuned config template
power_cap_custom: "{{ power_cap_custom_float |int }}"
power_cap_default: "{{ power_cap_default_float |int }}"

View file

@ -1,17 +1,26 @@
--- ---
# statically defined mapping of the contents in /sys/class/drm/card*/device/pp_power_profile_mode # statically defined mapping of gpu profiles
# more may be added, but do not remove default/custom. new profiles require a script template, see 'templates' # nets adjusted tuned profiles based on the contents in /sys/class/drm/card*/device/pp_power_profile_mode
# adds a power multiplier, see comments below for more info
# more reference driver profiles may be added, but do not remove default.
amdgpu_profiles: amdgpu_profiles:
default: default:
pwrmode: 0 pwrmode: 0
pwr_cap_multi: 0.789473684210526 # 255W - default
3D: 3D:
pwrmode: 1 pwrmode: 1
pwr_cap_multi: 0.789473684210526 # 255W - default
VR: VR:
pwrmode: 4 pwrmode: 4
pwr_cap_multi: 0.789473684210526 # 255W - default
compute:
pwrmode: 5
pwr_cap_multi: 0.789473684210526 # 255W - default
custom: custom:
pwrmode: 6 pwrmode: 6
pwr_cap_multi: 0.869969040247678 # 281W - slight boost
# the multipliers against power capability to determine power limits for the non-OC (default)/OC (custom) profiles # pwr_cap_multi is multiplier against *board power capability* to determine power limits on the associated profile
# 0.5 = 50%, 1.0 = 100% (of card power capability, not stock limits) # 0.5 = 50%, 1.0 = 100% (of card power capability, not stock limits)
# #
# should not exceed 1.0, must be a float. driver will do some rounding/stepping # should not exceed 1.0, must be a float. driver will do some rounding/stepping
@ -20,18 +29,6 @@ amdgpu_profiles:
# adjust cell F14 (board max power) and the 'effective watts' column to update calculations # adjust cell F14 (board max power) and the 'effective watts' column to update calculations
# microWatt board power capability can be discovered like so: 'cat /sys/class/drm/card*/device/hwmon/hwmon*/power1_cap_max' # microWatt board power capability can be discovered like so: 'cat /sys/class/drm/card*/device/hwmon/hwmon*/power1_cap_max'
# power_max_default_multi: 0.75 # 242.25W, slightly lower than true default # power_max_default_multi: 0.75 # 242.25W, slightly lower than true default
# power for the default profile
power_max_default_multi: 0.789473684210526 # 255W - default
# power_max_default_multi: 0.820433436532508 # 265W
# power_max_default_multi: 0.851393188854489 # 275W
# power_max_default_multi: 0.869969040247678 # 281W
# power for the custom profile
#power_max_custom_multi: 0.789473684210526 # 255W - default
power_max_custom_multi: 0.869969040247678 # 281W
# alt default power limits
# power_max_default_multi: 0.696594427244582 # 225W
# power_max_default_multi: 0.869969040247678 # 281W
# #
# minimum/maximum GPU clocks using 'powerplay' below # minimum/maximum GPU clocks using 'powerplay' below
# these do *not* apply to the resulting 'amdgpu-default' tuned profile # these do *not* apply to the resulting 'amdgpu-default' tuned profile

View file

@ -19,8 +19,7 @@
CARD=$(/usr/bin/grep -ls ^connected /sys/class/drm/*/status | /usr/bin/grep -o 'card[0-9]' | /usr/bin/sort | /usr/bin/uniq | /usr/bin/sort -h | /usr/bin/tail -1) CARD=$(/usr/bin/grep -ls ^connected /sys/class/drm/*/status | /usr/bin/grep -o 'card[0-9]' | /usr/bin/sort | /usr/bin/uniq | /usr/bin/sort -h | /usr/bin/tail -1)
{# begin the templated script for 'default' profiles to reset state #} {# begin the templated script for 'default' profiles to reset state #}
{% if 'default' in item.0.key %} {% if 'default' in profile_name %}
# set power state transition heuristics to default # set power state transition heuristics to default
echo '{{ item.0.value.pwrmode }}' | tee /sys/class/drm/"${CARD}"/device/pp_power_profile_mode echo '{{ item.0.value.pwrmode }}' | tee /sys/class/drm/"${CARD}"/device/pp_power_profile_mode
@ -31,11 +30,10 @@ echo 'auto' | tee /sys/class/drm/"${CARD}"/device/power_dpm_force_performance_le
# reset any existing profile clock changes # reset any existing profile clock changes
echo 'r' | tee /sys/class/drm/"${CARD}"/device/pp_od_clk_voltage echo 'r' | tee /sys/class/drm/"${CARD}"/device/pp_od_clk_voltage
# give default profile {{ power_max_default_multi * 100.0 |int }}% of the max power capability # give '{{ profile_name }}' profile ~{{ profile_percentage }}% (rounded) of the max power capability
# {{ power_cap_default|int/1000000 }} Watts of {{ power_max|int/1000000 }} total # {{ profile_watts }} Watts of {{ board_watts }} total
echo '{{ power_cap_default }}' | tee {{ powercap_set.files.0.path }} echo '{{ profile_microwatts | int }}' | tee '{{ powercap_set.files.0.path }}'
{% else %} {% else %}
{# begin the templated script for non-default AMD GPU profiles, eg: 'VR' or '3D_FULL_SCREEN' #} {# begin the templated script for non-default AMD GPU profiles, eg: 'VR' or '3D_FULL_SCREEN' #}
# set manual control mode # set manual control mode
# allows control via 'pp_dpm_mclk', 'pp_dpm_sclk', 'pp_dpm_pcie', 'pp_dpm_fclk', and 'pp_power_profile_mode' files # allows control via 'pp_dpm_mclk', 'pp_dpm_sclk', 'pp_dpm_pcie', 'pp_dpm_fclk', and 'pp_power_profile_mode' files
@ -43,12 +41,12 @@ echo '{{ power_cap_default }}' | tee {{ powercap_set.files.0.path }}
# GPU clocks are dynamic based on (load) condition # GPU clocks are dynamic based on (load) condition
echo 'manual' | tee /sys/class/drm/"${CARD}"/device/power_dpm_force_performance_level echo 'manual' | tee /sys/class/drm/"${CARD}"/device/power_dpm_force_performance_level
# set power state transition heuristics to '{{ item.0.key }}' profile # set power state transition heuristics to '{{ profile_name }}' profile
echo '{{ item.0.value.pwrmode }}' | tee /sys/class/drm/"${CARD}"/device/pp_power_profile_mode echo '{{ item.0.value.pwrmode }}' | tee /sys/class/drm/"${CARD}"/device/pp_power_profile_mode
# give this profile {{ power_max_custom_multi * 100.0 |int }}% of the max power capability # give '{{ profile_name }}' profile ~{{ profile_percentage }}% (rounded) of the max power capability
# {{ power_cap_custom|int/1000000 }} Watts of {{ power_max|int/1000000 }} total # {{ profile_watts }} Watts of {{ board_watts }} total
echo '{{ power_cap_custom }}' | tee {{ powercap_set.files.0.path }} echo '{{ profile_microwatts | int }}' | tee '{{ powercap_set.files.0.path }}'
# set the minimum GPU clock # set the minimum GPU clock
echo 's 0 {{ gpu_clock_min }}' | tee /sys/class/drm/"${CARD}"/device/pp_od_clk_voltage echo 's 0 {{ gpu_clock_min }}' | tee /sys/class/drm/"${CARD}"/device/pp_od_clk_voltage