Experimental GPU overclock

This commit is contained in:
Serge
2023-05-06 14:40:52 +02:00
parent 8e1099545a
commit c61f4d1608
497 changed files with 46937 additions and 232 deletions

View File

@@ -1,12 +1,20 @@
using NvAPIWrapper.GPU;
using NvAPIWrapper.Native;
using NvAPIWrapper.Native.GPU;
using NvAPIWrapper.Native.GPU.Structures;
using NvAPIWrapper.Native.Interfaces.GPU;
namespace GHelper.Gpu;
public class NvidiaGpuControl : IGpuControl
{
public const int MaxCoreOffset = 300;
public const int MaxMemoryOffset = 300;
public const int MinCoreOffset = -300;
public const int MinMemoryOffset = -300;
private readonly PhysicalGPU? _internalGpu;
public NvidiaGpuControl()
@@ -35,6 +43,44 @@ public class NvidiaGpuControl : IGpuControl
{
}
public void GetClocks(out int core, out int memory)
{
PhysicalGPU internalGpu = _internalGpu!;
PerformanceStates20InfoV3 states = (PerformanceStates20InfoV3)GPUApi.GetPerformanceStates20(internalGpu.Handle);
core = states.Clocks[PerformanceStateId.P0_3DPerformance][0].FrequencyDeltaInkHz.DeltaValue / 1000;
memory = states.Clocks[PerformanceStateId.P0_3DPerformance][1].FrequencyDeltaInkHz.DeltaValue / 1000;
}
public int SetClocks(int core, int memory)
{
if (core < MinCoreOffset || core > MaxCoreOffset) return 0;
if (memory < MinMemoryOffset || memory > MaxMemoryOffset) return 0;
PhysicalGPU internalGpu = _internalGpu!;
PerformanceStates20InfoV3 states = (PerformanceStates20InfoV3)GPUApi.GetPerformanceStates20(internalGpu.Handle);
states._NumberOfPerformanceStates = 1;
states._NumberOfClocks = 2;
states.PerformanceStates[0]._Clocks[0]._FrequencyDeltaInkHz = new PerformanceStates20ParameterDelta(core * 1000);
states.PerformanceStates[0]._Clocks[1]._FrequencyDeltaInkHz = new PerformanceStates20ParameterDelta(memory * 1000);
try
{
GPUApi.SetPerformanceStates20(internalGpu.Handle, states);
}
catch (Exception ex)
{
Logger.WriteLine(ex.Message);
return -1;
}
return 1;
}
private static PhysicalGPU? GetInternalDiscreteGpu()
{
try