Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions NvAPIWrapper/Native/Delegates/GPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
31 changes: 31 additions & 0 deletions NvAPIWrapper/Native/GPUApi.Performance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,5 +523,36 @@ public static void SetPerformanceStates20(
}
}
}

/// <summary>
/// [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.
/// </summary>
/// <param name="physicalGPUHandle">GPU handle to get information about.</param>
/// <param name="pstate">The pstate you want to force 0 - 15. 0 = highest performance. 16 = use fallback state.</param>
/// <param name="fallback">1 = fallback to high perf, 2 = fallback to low perf.</param>
/// <exception cref="NVIDIAApiException">Status.InvalidArgument: gpuHandle is NULL</exception>
/// <exception cref="NVIDIAApiException">Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle</exception>
public static void SetForcePstate(
PhysicalGPUHandle physicalGPUHandle,
int pstate,
int fallback)
{
var status = DelegateFactory.GetDelegate<Delegates.GPU.NvAPI_GPU_SetForcePstate>()(
physicalGPUHandle,
pstate,
fallback
);

if (status != Status.Ok)
{
throw new NVIDIAApiException(status);
}
}


}
}
1 change: 1 addition & 0 deletions NvAPIWrapper/Native/Helpers/FunctionId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion NvAPIWrapper/NvAPIWrapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<Version>0.8.1.101</Version>
<Version>0.8.1.103</Version>
<Company>falahati.net</Company>
<Description>NvAPIWrapper is a .Net wrapper for NVIDIA public API</Description>
<Authors>Soroush Falahati</Authors>
Expand Down