From 62cac76200444b7dd9a677fb75579d01162c619e Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Sat, 9 Mar 2024 13:11:33 +0100 Subject: [PATCH] InitMaxGPUPower --- app/AsusACPI.cs | 8 +------- app/Fans.cs | 16 +++++++++++++--- app/Gpu/NVidia/NvidiaSmi.cs | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/app/AsusACPI.cs b/app/AsusACPI.cs index ebbf0fc2..4ed16f4a 100644 --- a/app/AsusACPI.cs +++ b/app/AsusACPI.cs @@ -154,7 +154,7 @@ public class AsusACPI public static int MaxGPUBoost = 25; public static int MinGPUPower = 0; - public static int MaxGPUPower = 60; + public static int MaxGPUPower = 70; public const int MinGPUTemp = 75; public const int MaxGPUTemp = 87; @@ -291,12 +291,6 @@ public class AsusACPI if (AppConfig.IsIntelHX()) { MaxTotal = 175; - MaxGPUPower = 70; - } - - if (AppConfig.IsSlash()) - { - MaxGPUPower = AppConfig.Get("max_gpu_power", 25); } if (AppConfig.DynamicBoost5()) diff --git a/app/Fans.cs b/app/Fans.cs index 34710d3c..d15dd1dd 100644 --- a/app/Fans.cs +++ b/app/Fans.cs @@ -32,6 +32,7 @@ namespace GHelper FanSensorControl fanSensorControl; static int gpuPowerBase = 0; + static bool isGPUPower => gpuPowerBase > 0; public Fans() { @@ -526,8 +527,16 @@ namespace GHelper private void InitGPUPower() { gpuPowerBase = Program.acpi.DeviceGet(AsusACPI.GPU_BASE); - panelGPUPower.Visible = gpuPowerBase > 0; - if (gpuPowerBase <= 0) return; + panelGPUPower.Visible = isGPUPower; + if (!isGPUPower) return; + + int maxGPUPower = NvidiaSmi.GetMaxGPUPower(); + if (maxGPUPower > 0) + { + AsusACPI.MaxGPUPower = maxGPUPower - gpuPowerBase - 15; + trackGPUPower.Minimum = AsusACPI.MinGPUPower; + trackGPUPower.Maximum = AsusACPI.MaxGPUPower; + } Task.Run(async () => { @@ -678,7 +687,8 @@ namespace GHelper { AppConfig.SetMode("gpu_boost", trackGPUBoost.Value); AppConfig.SetMode("gpu_temp", trackGPUTemp.Value); - AppConfig.SetMode("gpu_power", trackGPUPower.Value); + + if (isGPUPower) AppConfig.SetMode("gpu_power", trackGPUPower.Value); VisualiseGPUSettings(); } diff --git a/app/Gpu/NVidia/NvidiaSmi.cs b/app/Gpu/NVidia/NvidiaSmi.cs index c3ff47fa..b400b71d 100644 --- a/app/Gpu/NVidia/NvidiaSmi.cs +++ b/app/Gpu/NVidia/NvidiaSmi.cs @@ -30,6 +30,20 @@ public static class NvidiaSmi return false; // Return false if the "Display Active" status is not found } + public static int GetMaxGPUPower() + { + string output = RunNvidiaSmiCommand("--query-gpu=power.max_limit --format csv,noheader,nounits"); + output = output.Trim().Trim('\n', '\r'); + + if (float.TryParse(output, out float floatValue)) + { + int intValue = (int)floatValue; + return intValue; + } + + return -1; + } + private static string RunNvidiaSmiCommand(string arguments = "-i 0 -q") { ProcessStartInfo startInfo = new ProcessStartInfo