diff --git a/group_vars/all b/group_vars/all index 1ef3a9d..fe42e39 100644 --- a/group_vars/all +++ b/group_vars/all @@ -1,17 +1,14 @@ --- # 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 }}" +board_watts: "{{ power_max|int/1000000 }}" -# convert discovered board power limit (int) to a float -# for some math in the tuned config template -power_max_float: "{{ power_max_b64['content'] | b64decode |float }}" - -# determine the microWatt limits based on the provided multipliers -power_cap_custom_float: "{{ power_max |float * power_max_custom_multi }}" -power_cap_default_float: "{{ power_max |float * power_max_default_multi }}" - -# 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 }}" +# internals for profile power calculations +# item in the context of the with_nested loops in the play +profile_name: "{{ item.0.key }}" +profile_percentage: "{{ (item.0.value.pwr_cap_multi * 100.0) | round(2) }}" +profile_multi: "{{ item.0.value.pwr_cap_multi }}" +profile_microwatts: "{{ power_max | float * profile_multi | float }}" +profile_watts: "{{ profile_microwatts | int/1000000 }}" diff --git a/host_vars/localhost.yml b/host_vars/localhost.yml index f753b94..2b88e84 100644 --- a/host_vars/localhost.yml +++ b/host_vars/localhost.yml @@ -1,17 +1,26 @@ --- -# statically defined mapping of the contents in /sys/class/drm/card*/device/pp_power_profile_mode -# more may be added, but do not remove default/custom. new profiles require a script template, see 'templates' +# statically defined mapping of gpu profiles +# 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: default: pwrmode: 0 + pwr_cap_multi: 0.789473684210526 # 255W - default 3D: pwrmode: 1 + pwr_cap_multi: 0.789473684210526 # 255W - default VR: pwrmode: 4 + pwr_cap_multi: 0.789473684210526 # 255W - default + compute: + pwrmode: 5 + pwr_cap_multi: 0.789473684210526 # 255W - default custom: 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) # # 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 # 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 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 # these do *not* apply to the resulting 'amdgpu-default' tuned profile diff --git a/templates/amdgpu-clock.sh.j2 b/templates/amdgpu-clock.sh.j2 index 9be91f4..4efd30a 100644 --- a/templates/amdgpu-clock.sh.j2 +++ b/templates/amdgpu-clock.sh.j2 @@ -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) {# 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 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 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 -# {{ power_cap_default|int/1000000 }} Watts of {{ power_max|int/1000000 }} total -echo '{{ power_cap_default }}' | tee {{ powercap_set.files.0.path }} +# give '{{ profile_name }}' profile ~{{ profile_percentage }}% (rounded) of the max power capability +# {{ profile_watts }} Watts of {{ board_watts }} total +echo '{{ profile_microwatts | int }}' | tee '{{ powercap_set.files.0.path }}' {% else %} - {# begin the templated script for non-default AMD GPU profiles, eg: 'VR' or '3D_FULL_SCREEN' #} # 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 @@ -43,12 +41,12 @@ echo '{{ power_cap_default }}' | tee {{ powercap_set.files.0.path }} # GPU clocks are dynamic based on (load) condition 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 -# give this profile {{ power_max_custom_multi * 100.0 |int }}% of the max power capability -# {{ power_cap_custom|int/1000000 }} Watts of {{ power_max|int/1000000 }} total -echo '{{ power_cap_custom }}' | tee {{ powercap_set.files.0.path }} +# give '{{ profile_name }}' profile ~{{ profile_percentage }}% (rounded) of the max power capability +# {{ profile_watts }} Watts of {{ board_watts }} total +echo '{{ profile_microwatts | int }}' | tee '{{ powercap_set.files.0.path }}' # set the minimum GPU clock echo 's 0 {{ gpu_clock_min }}' | tee /sys/class/drm/"${CARD}"/device/pp_od_clk_voltage