diff --git a/NvAPIWrapper/Native/Delegates/GPU.cs b/NvAPIWrapper/Native/Delegates/GPU.cs index 5ff8659..4c5690b 100644 --- a/NvAPIWrapper/Native/Delegates/GPU.cs +++ b/NvAPIWrapper/Native/Delegates/GPU.cs @@ -683,6 +683,12 @@ public delegate Status NvAPI_GPU_SetPStates20( [In] ValueTypeReference performanceStatesInfo); + [FunctionId(FunctionId.NvAPI_GPU_SetForcePstate)] + public delegate Status NvAPI_GPU_SetForcePstate( + [In] PhysicalGPUHandle physicalGpu, + [In] int pstate, + [In] int fallback); + [FunctionId(FunctionId.NvAPI_GPU_SetThermalPoliciesStatus)] public delegate Status NvAPI_GPU_SetThermalPoliciesStatus( [In] PhysicalGPUHandle physicalGpu, diff --git a/NvAPIWrapper/Native/GPUApi.Performance.cs b/NvAPIWrapper/Native/GPUApi.Performance.cs index 06ce3ee..9853daa 100644 --- a/NvAPIWrapper/Native/GPUApi.Performance.cs +++ b/NvAPIWrapper/Native/GPUApi.Performance.cs @@ -523,5 +523,36 @@ public static void SetPerformanceStates20( } } } + + /// + /// [PRIVATE] + /// This function exists to force the P-State of a GPU when SetPerformanceStates20 cannot. + /// Works with Tesla P40 and T4, likely other TCC cards. + /// In the fallback state, the driver automatically switches between high and low performance states + /// as needed by the running software. + /// + /// GPU handle to get information about. + /// The pstate you want to force 0 - 15. 0 = highest performance. 16 = use fallback state. + /// 1 = fallback to high perf, 2 = fallback to low perf. + /// Status.InvalidArgument: gpuHandle is NULL + /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle + public static void SetForcePstate( + PhysicalGPUHandle physicalGPUHandle, + int pstate, + int fallback) + { + var status = DelegateFactory.GetDelegate()( + physicalGPUHandle, + pstate, + fallback + ); + + if (status != Status.Ok) + { + throw new NVIDIAApiException(status); + } + } + + } } \ No newline at end of file diff --git a/NvAPIWrapper/Native/Helpers/FunctionId.cs b/NvAPIWrapper/Native/Helpers/FunctionId.cs index 446f8b4..23c3d31 100644 --- a/NvAPIWrapper/Native/Helpers/FunctionId.cs +++ b/NvAPIWrapper/Native/Helpers/FunctionId.cs @@ -622,6 +622,7 @@ internal enum FunctionId : uint NvAPI_GPU_SetPstates20 = 0x0F4DAE6B, NvAPI_GPU_SetPstatesInfo = 0x0CDF27911, NvAPI_GPU_SetThermalPoliciesStatus = 0x034C0B13D, + NvAPI_GPU_SetForcePstate = 0x025BFB10, NvAPI_Hybrid_IsAppMigrationStateChangeable = 0x584CB0B6, NvAPI_Hybrid_QueryBlockedMigratableApps = 0x0F4C2F8CC, NvAPI_Hybrid_QueryUnblockedNonMigratableApps = 0x5F35BCB5, diff --git a/NvAPIWrapper/NvAPIWrapper.csproj b/NvAPIWrapper/NvAPIWrapper.csproj index 2a854c2..c555add 100644 --- a/NvAPIWrapper/NvAPIWrapper.csproj +++ b/NvAPIWrapper/NvAPIWrapper.csproj @@ -2,7 +2,7 @@ netstandard2.0;net45 - 0.8.1.101 + 0.8.1.103 falahati.net NvAPIWrapper is a .Net wrapper for NVIDIA public API Soroush Falahati