falahati/NvAPIWrapper

Setting Clockspeed

MaynardMiner opened this issue · 3 comments

I am trying to figure out how to use the wrapper to set graphics clock speed. So far this is what I have done:

in IPerformanceClockStates20ClockEntry.cs

I changed:

        /// <inheritdoc />
        public PerformanceStates20ParameterDelta FrequencyDeltaInkHz
        {
            get => _FrequencyDeltaInkHz;
        }

to

        /// <inheritdoc />
        public PerformanceStates20ParameterDelta FrequencyDeltaInkHz
        {
            get => _FrequencyDeltaInkHz;
            set => _FrequencyDeltaInkHz = value;
        }

In PerformanceStates20Infov1.cs I added the following to PerformanceState20 so I could see what current clocks are.

from

            /// <inheritdoc />
            public bool IsEditable
            {
                get => _Flags.GetBit(0);
            }

to

            /// <inheritdoc />
            public bool IsEditable
            {
                get => _Flags.GetBit(0);
            }

            /// <inheritdoc />
            public PerformanceStates20ClockEntryV1[] Clocks
            {
                get => _Clocks;
            }

Finally in IPerformanceState20.cs:
from

        /// <summary>
        ///     Gets the performance state identification
        /// </summary>
        PerformanceStateId StateId { get; }

to

        /// <summary>
        ///     Gets the performance state identification
        /// </summary>
        PerformanceStateId StateId { get; }

        /// <summary>
        ///     Gets the performance state clock entries
        /// </summary>
        PerformanceStates20ClockEntryV1[] Clocks { get; }

Here is what I am trying to do:

int index = 0;
int core = 100;

var GPUs = PhysicalGPU.GetPhysicalGPUs();
var Performance = GPUApi.GetPerformanceStates20(GPUs[index].Handle);
var min = Performance.PerformanceStates[0].Clocks[0].FrequencyDeltaInkHz.DeltaRange.Minimum;
var max = Performance.PerformanceStates[0].Clocks[0].FrequencyDeltaInkHz.DeltaRange.Maximum;
var delta = new PerformanceStates20ParameterDelta((core * 1000), min, max);
Performance.PerformanceStates[0].Clocks[0].FrequencyDeltaInkHz = delta;
GPUApi.SetPerformanceStates20(GPUs[index].Handle, Performance);

I get:

NvAPIWrapper.Native.Exceptions.NVIDIAApiException
  HResult=0x80131500
  Source=NvAPIWrapper
  StackTrace:
   at NvAPIWrapper.Native.GPUApi.SetPerformanceStates20(PhysicalGPUHandle physicalGPUHandle, IPerformanceStates20Info performanceStates20Info) in C:\Users\Mayna\Documents\GitHub\NvAPIWrapper\NvAPIWrapper\Native\GPUApi.Performance.cs:line 524
   at NVClocks.Program.Main(String[] args) in C:\Users\Mayna\Documents\GitHub\NvAPIWrapper\NvAPISample\Program.cs:line 198

status is returning NvAPIWrapper.Native.General.Status.NotSupported

I don't think the small change I made makes a difference in reference to the exception, but I could be wrong. Is there a way to debug it deeper to find what is causing the issue?

If I change to:

var Performance = GPUApi.GetPerformanceStates20(GPUs[index].Handle);
GPUApi.SetPerformanceStates20(GPUs[index].Handle, Performance);

And just send the same IPerformance20statesInfo back it fails. This includes undoing all changes I have made so I can get the current clock settings.

is this solved or did you just lost interest? :)

E4zily commented

i can reproduce this issue, getting the pstates20 and then setting it back to the exact same thing throws an NVAPI_NOT_SUPPORTED. other apps are successful at changing the pstates.

same thing here