InitMaxGPUPower

This commit is contained in:
Serge
2024-03-09 13:11:33 +01:00
parent 5401ea952a
commit 62cac76200
3 changed files with 28 additions and 10 deletions

View File

@@ -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())

View File

@@ -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();
}

View File

@@ -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