Beispiel #1
0
 private bool NvFanCoolersGetControl(int busId, out PrivateFanCoolersControlV1 info)
 {
     info = new PrivateFanCoolersControlV1();
     if (NvapiNativeMethods.NvFanCoolersGetControl == null)
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(PrivateFanCoolersControlV1))));
         var r = NvapiNativeMethods.NvFanCoolersGetControl(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvFanCoolersGetControl)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }
Beispiel #2
0
 private static bool NvPowerPoliciesSetStatus(int busId, ref NvGpuPowerStatus info)
 {
     if (NvapiNativeMethods.NvPowerPoliciesSetStatus == null)
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         var r = NvapiNativeMethods.NvPowerPoliciesSetStatus(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvPowerPoliciesSetStatus)} {r.ToString()}");
         }
         if (r == NvStatus.NVAPI_OK)
         {
             return(true);
         }
     }
     catch {
     }
     return(false);
 }
Beispiel #3
0
 private bool GetCoolerSettings(int busId, out NvCoolerSettings info)
 {
     info = new NvCoolerSettings();
     if (NvapiNativeMethods.NvGetCoolerSettings == null)
     {
         return(false);
     }
     if (_nvGetCoolerSettingsNotSupporteds.Contains(busId))
     {
         return(false);
     }
     info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvCoolerSettings))));
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
         var            r           = NvapiNativeMethods.NvGetCoolerSettings(handle, coolerIndex, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             if (r == NvStatus.NVAPI_NOT_SUPPORTED || r == NvStatus.NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED || r == NvStatus.NVAPI_GPU_NOT_POWERED)
             {
                 _nvGetCoolerSettingsNotSupporteds.Add(busId);
             }
             Write.DevError($"{nameof(NvapiNativeMethods.NvGetCoolerSettings)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }
Beispiel #4
0
 private bool GetFanCoolersGetStatus(int busId, out PrivateFanCoolersStatusV1 info)
 {
     info = new PrivateFanCoolersStatusV1();
     if (NvapiNativeMethods.NvFanCoolersGetStatus == null)
     {
         return(false);
     }
     if (_nvFanCoolersGetStatusNotSupporteds.Contains(busId))
     {
         return(false);
     }
     info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(PrivateFanCoolersStatusV1))));
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         var r = NvapiNativeMethods.NvFanCoolersGetStatus(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             if (r == NvStatus.NVAPI_NOT_SUPPORTED || r == NvStatus.NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED)
             {
                 _nvFanCoolersGetStatusNotSupporteds.Add(busId);
             }
             Write.DevError($"{nameof(NvapiNativeMethods.NvFanCoolersGetStatus)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }
Beispiel #5
0
 private bool NvSetPStateV2(int busId, ref NvGpuPerfPStates20InfoV2 info)
 {
     if (NvapiNativeMethods.NvSetPStateV2 == null)
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         var r = NvapiNativeMethods.NvSetPStateV2(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvSetPStateV2)} {r.ToString()}");
         }
         if (r == NvStatus.NVAPI_OK)
         {
             return(true);
         }
     }
     catch {
     }
     return(false);
 }
Beispiel #6
0
        private NvGpuThermalLimit NvThermalPoliciesGetLimit(int busId)
        {
            NvGpuThermalLimit info = new NvGpuThermalLimit();

            if (NvapiNativeMethods.NvThermalPoliciesGetLimit == null)
            {
                return(info);
            }
            try {
                if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
                {
                    return(info);
                }
                info.version = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuThermalLimit))));
                var r = NvapiNativeMethods.NvThermalPoliciesGetLimit(handle, ref info);
                if (r != NvStatus.NVAPI_OK)
                {
                    Write.DevError($"{nameof(NvapiNativeMethods.NvThermalPoliciesGetLimit)} {r.ToString()}");
                }
                if (r == NvStatus.NVAPI_OK)
                {
                    return(info);
                }
            }
            catch {
            }
            return(info);
        }
Beispiel #7
0
 private bool NvThermalPoliciesGetInfo(int busId, out NvGpuThermalInfo info)
 {
     info = new NvGpuThermalInfo();
     if (NvapiNativeMethods.NvThermalPoliciesGetInfo == null)
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         info.version = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuThermalInfo))));
         var r = NvapiNativeMethods.NvThermalPoliciesGetInfo(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             Write.DevError($"{nameof(NvapiNativeMethods.NvThermalPoliciesGetInfo)} {r}");
             return(false);
         }
         return(true);
     }
     catch {
         return(false);
     }
 }
Beispiel #8
0
 private bool NvSetPStateV2(int busId, ref NvGpuPerfPStates20InfoV2 info)
 {
     if (NvapiNativeMethods.NvSetPStateV2 == null)
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         info.version = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuPerfPStates20InfoV2))));
         var r = NvapiNativeMethods.NvSetPStateV2(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             Write.DevError($"{nameof(NvapiNativeMethods.NvSetPStateV2)} {r}");
         }
         if (r == NvStatus.NVAPI_OK)
         {
             return(true);
         }
     }
     catch {
     }
     return(false);
 }
Beispiel #9
0
 public void GetTemperature(IGpu gpu, out uint coreTemperature, out uint memoryTemperature)
 {
     coreTemperature   = 0;
     memoryTemperature = 0;
     if (NvapiNativeMethods.NvGetThermalSettings == null)
     {
         return;
     }
     try {
         int busId = gpu.GetOverClockId();
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return;
         }
         NvGPUThermalSettings settings = NvGPUThermalSettings.Create();
         var r = NvapiNativeMethods.NvGetThermalSettings(handle, (int)NvThermalTarget.ALL, ref settings);
         if (r != NvStatus.NVAPI_OK)
         {
             settings.Count = 0;
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvGetThermalSettings)} {r.ToString()}");
         }
         if (settings.Count > 0)
         {
             coreTemperature = settings.Sensor[0].CurrentTemp;
         }
         // TODO:3090是支持显存温度的,但不知道用什么接口读取
         if (settings.Count > 1)
         {
             memoryTemperature = settings.Sensor[1].CurrentTemp;
         }
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
     }
 }
Beispiel #10
0
 private static bool GetFanCoolersGetStatus(int busId, out PrivateFanCoolersStatusV1 info)
 {
     info = PrivateFanCoolersStatusV1.Create();
     if (NvapiNativeMethods.NvFanCoolersGetStatus == null)
     {
         return(false);
     }
     if (_nvFanCoolersGetStatusNotSupporteds.Contains(busId))
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         var r = NvapiNativeMethods.NvFanCoolersGetStatus(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             if (r == NvStatus.NVAPI_NOT_SUPPORTED || r == NvStatus.NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED)
             {
                 _nvFanCoolersGetStatusNotSupporteds.Add(busId);
             }
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvFanCoolersGetStatus)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }
Beispiel #11
0
        private static NvGpuThermalLimit NvThermalPoliciesGetLimit(int busId)
        {
            NvGpuThermalLimit info = NvGpuThermalLimit.Create();

            if (NvapiNativeMethods.NvThermalPoliciesGetLimit == null)
            {
                return(info);
            }
            try {
                if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
                {
                    return(info);
                }
                var r = NvapiNativeMethods.NvThermalPoliciesGetLimit(handle, ref info);
                if (r != NvStatus.NVAPI_OK)
                {
                    NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvThermalPoliciesGetLimit)} {r.ToString()}");
                }
                if (r == NvStatus.NVAPI_OK)
                {
                    return(info);
                }
            }
            catch {
            }
            return(info);
        }
Beispiel #12
0
        private NvGpuClockFrequenciesV2 NvGetAllClockFrequenciesV2(int busId, uint type)
        {
            NvGpuClockFrequenciesV2 info = new NvGpuClockFrequenciesV2();

            if (NvapiNativeMethods.NvGetAllClockFrequenciesV2 == null)
            {
                return(info);
            }
            try {
                info.version   = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuClockFrequenciesV2))));
                info.ClockType = type;
                var r = NvapiNativeMethods.NvGetAllClockFrequenciesV2(HandlesByBusId[busId], ref info);
                if (r != NvStatus.OK)
                {
                    Write.DevError($"{nameof(NvapiNativeMethods.NvGetAllClockFrequenciesV2)} {r}");
                }
                if (r == NvStatus.OK)
                {
                    return(info);
                }
            }
            catch {
            }
            return(info);
        }
Beispiel #13
0
 private bool NvGetPStateV2(int busId, out NvGpuPerfPStates20InfoV2 info)
 {
     info = new NvGpuPerfPStates20InfoV2();
     if (NvapiNativeMethods.NvGetPStateV2 == null)
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         info.version = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuPerfPStates20InfoV2))));
         var r = NvapiNativeMethods.NvGetPStateV2(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvGetPStateV2)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(false);
     }
 }
Beispiel #14
0
 private bool NvPowerPoliciesSetStatus(int busId, ref NvGpuPowerStatus info)
 {
     if (NvapiNativeMethods.NvPowerPoliciesSetStatus == null)
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvGpuPowerStatus))));
         var r = NvapiNativeMethods.NvPowerPoliciesSetStatus(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             Write.DevError($"{nameof(NvapiNativeMethods.NvPowerPoliciesSetStatus)} {r.ToString()}");
         }
         if (r == NvStatus.NVAPI_OK)
         {
             return(true);
         }
     }
     catch {
     }
     return(false);
 }
Beispiel #15
0
 private static bool GetCoolerSettings(int busId, out NvCoolerSettings info)
 {
     info = NvCoolerSettings.Create();
     if (NvapiNativeMethods.NvGetCoolerSettings == null)
     {
         return(false);
     }
     if (_nvGetCoolerSettingsNotSupporteds.Contains(busId))
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
         var            r           = NvapiNativeMethods.NvGetCoolerSettings(handle, coolerIndex, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             if (r == NvStatus.NVAPI_NOT_SUPPORTED || r == NvStatus.NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED || r == NvStatus.NVAPI_GPU_NOT_POWERED)
             {
                 _nvGetCoolerSettingsNotSupporteds.Add(busId);
             }
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvGetCoolerSettings)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }
Beispiel #16
0
 private bool NvPowerPoliciesGetInfo(int busId, out NvGpuPowerInfo info)
 {
     info = new NvGpuPowerInfo();
     if (NvapiNativeMethods.NvPowerPoliciesGetInfo == null)
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvGpuPowerInfo))));
         var r = NvapiNativeMethods.NvPowerPoliciesGetInfo(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvPowerPoliciesGetInfo)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch {
         return(false);
     }
 }
Beispiel #17
0
 private static bool NvGetPStateV2(int busId, out NvGpuPerfPStates20InfoV2 info)
 {
     info = NvGpuPerfPStates20InfoV2.Create();
     if (NvapiNativeMethods.NvGetPStateV2 == null)
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         var r = NvapiNativeMethods.NvGetPStateV2(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvGetPStateV2)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(false);
     }
 }
Beispiel #18
0
 private bool NvThermalPoliciesSetLimit(int busId, ref NvGpuThermalLimit info)
 {
     if (NvapiNativeMethods.NvThermalPoliciesSetLimit == null)
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         info.version = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuThermalLimit))));
         var r = NvapiNativeMethods.NvThermalPoliciesSetLimit(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvThermalPoliciesSetLimit)} {r.ToString()}");
         }
         if (r == NvStatus.NVAPI_OK)
         {
             return(true);
         }
     }
     catch {
     }
     return(false);
 }
Beispiel #19
0
        private NvGpuClockFrequenciesV2 NvGetAllClockFrequenciesV2(int busId, uint type)
        {
            NvGpuClockFrequenciesV2 info = new NvGpuClockFrequenciesV2();

            if (NvapiNativeMethods.NvGetAllClockFrequenciesV2 == null)
            {
                return(info);
            }
            try {
                if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
                {
                    return(info);
                }
                info.version   = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuClockFrequenciesV2))));
                info.ClockType = type;
                var r = NvapiNativeMethods.NvGetAllClockFrequenciesV2(handle, ref info);
                if (r != NvStatus.NVAPI_OK)
                {
                    NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvGetAllClockFrequenciesV2)} {r.ToString()}");
                }
                if (r == NvStatus.NVAPI_OK)
                {
                    return(info);
                }
            }
            catch {
            }
            return(info);
        }
Beispiel #20
0
 private bool NvSetPStateV1(int busId, ref NvGpuPerfPStates20InfoV1 info)
 {
     if (NvapiNativeMethods.NvSetPStateV1 == null)
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         int len = Marshal.SizeOf(typeof(NvGpuPerfPStates20InfoV1));
         info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvGpuPerfPStates20InfoV1))));
         var r = NvapiNativeMethods.NvSetPStateV1(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvSetPStateV1)} {r.ToString()}");
         }
         if (r == NvStatus.NVAPI_OK)
         {
             return(true);
         }
     }
     catch {
     }
     return(false);
 }
Beispiel #21
0
        private bool SetCooler(int busId, uint value, bool isAutoMode)
        {
            #region GTX
            if (NvapiNativeMethods.NvSetCoolerLevels != null)
            {
                try {
                    NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
                    NvCoolerLevel  info        = new NvCoolerLevel()
                    {
                        version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvCoolerLevel)))),
                        coolers = new NvCoolerLevelItem[NvapiConst.NVAPI_MAX_COOLERS_PER_GPU]
                    };
                    info.coolers[0].currentLevel  = isAutoMode ? 0 : value;
                    info.coolers[0].currentPolicy = isAutoMode ? NvCoolerPolicy.NVAPI_COOLER_POLICY_AUTO : NvCoolerPolicy.NVAPI_COOLER_POLICY_MANUAL;
                    var r = NvapiNativeMethods.NvSetCoolerLevels(HandlesByBusId[busId], coolerIndex, ref info);
                    if (r != NvStatus.OK)
                    {
                        Write.DevError($"{nameof(NvapiNativeMethods.NvSetCoolerLevels)} {r}");
                    }
                    else
                    {
                        return(true);
                    }
                }
                catch {
                }
            }
            #endregion

            #region RTX
            if (NvapiNativeMethods.NvFanCoolersSetControl == null)
            {
                return(false);
            }
            try {
                if (NvFanCoolersGetControl(busId, out PrivateFanCoolersControlV1 info))
                {
                    for (int i = 0; i < info.FanCoolersControlCount; i++)
                    {
                        info.FanCoolersControlEntries[i].ControlMode = isAutoMode ? FanCoolersControlMode.Auto : FanCoolersControlMode.Manual;
                        info.FanCoolersControlEntries[i].Level       = isAutoMode ? 0u : (uint)value;
                    }
                    var r = NvapiNativeMethods.NvFanCoolersSetControl(HandlesByBusId[busId], ref info);
                    if (r != NvStatus.OK)
                    {
                        Write.DevError($"{nameof(NvapiNativeMethods.NvFanCoolersSetControl)} {r}");
                        return(false);
                    }
                    return(true);
                }
                return(false);
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
                return(false);
            }
            #endregion
        }
Beispiel #22
0
        private bool SetCooler(int busId, uint value, bool isAutoMode)
        {
            if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
            {
                return(false);
            }
            #region GTX
            if (NvapiNativeMethods.NvSetCoolerLevels != null)
            {
                try {
                    NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
                    NvCoolerLevel  info        = NvCoolerLevel.Create();
                    info.coolers[0].currentLevel  = isAutoMode ? 0 : value;
                    info.coolers[0].currentPolicy = isAutoMode ? NvCoolerPolicy.NVAPI_COOLER_POLICY_AUTO : NvCoolerPolicy.NVAPI_COOLER_POLICY_MANUAL;
                    var r = NvapiNativeMethods.NvSetCoolerLevels(handle, coolerIndex, ref info);
                    if (r != NvStatus.NVAPI_OK)
                    {
                        NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvSetCoolerLevels)} {r.ToString()}");
                    }
                    else
                    {
                        return(true);
                    }
                }
                catch {
                }
            }
            #endregion

            #region RTX
            if (NvapiNativeMethods.NvFanCoolersSetControl == null)
            {
                return(false);
            }
            try {
                if (NvFanCoolersGetControl(busId, out PrivateFanCoolersControlV1 info))
                {
                    for (int i = 0; i < info.FanCoolersControlCount; i++)
                    {
                        info.FanCoolersControlEntries[i].ControlMode = isAutoMode ? FanCoolersControlMode.Auto : FanCoolersControlMode.Manual;
                        info.FanCoolersControlEntries[i].Level       = isAutoMode ? 0u : (uint)value;
                    }
                    var r = NvapiNativeMethods.NvFanCoolersSetControl(handle, ref info);
                    if (r != NvStatus.NVAPI_OK)
                    {
                        NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvFanCoolersSetControl)} {r.ToString()}");
                        return(false);
                    }
                    return(true);
                }
                return(false);
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
                return(false);
            }
            #endregion
        }
Beispiel #23
0
 private static void SetVoltage(int busId, int voltage)
 {
     voltage *= 1000;
     if (NvapiNativeMethods.NvSetClockBoostLock == null)
     {
         return;
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return;
         }
         NvGpuClockLock clockLock = NvGpuClockLock.Create();
         var            r         = NvapiNativeMethods.NvGetClockBoostLock(HandlesByBusId[busId], ref clockLock);
         if (r != NvStatus.NVAPI_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvGetClockBoostLock)} {r.ToString()}");
         }
         if (r == NvStatus.NVAPI_OK)
         {
             uint index = clockLock.Enties[0].index;
             foreach (var item in clockLock.Enties)
             {
                 if (item.index > index)
                 {
                     index = item.index;
                 }
             }
             if (voltage != 0)
             {
                 clockLock.Enties[index].mode = 3;
             }
             else
             {
                 clockLock.Enties[index].mode = 0;
             }
             clockLock.Enties[index].voltageUV = (uint)voltage;
             r = NvapiNativeMethods.NvSetClockBoostLock(handle, ref clockLock);
             if (r != NvStatus.NVAPI_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvSetClockBoostLock)} {r.ToString()}");
             }
         }
     }
     catch {
     }
 }
Beispiel #24
0
        private bool NvFanCoolersGetControl(int busId, out PrivateFanCoolersControlV1 info)
        {
            info = new PrivateFanCoolersControlV1();
            if (NvapiNativeMethods.NvFanCoolersGetControl == null)
            {
                return(false);
            }
            info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(PrivateFanCoolersControlV1))));
            var r = NvapiNativeMethods.NvFanCoolersGetControl(HandlesByBusId[busId], ref info);

            if (r != NvStatus.OK)
            {
                Write.DevError($"{nameof(NvapiNativeMethods.NvFanCoolersGetControl)} {r}");
                return(false);
            }
            return(true);
        }
Beispiel #25
0
 private bool NvPowerPoliciesGetInfo(int busId, out NvGpuPowerInfo info)
 {
     info = new NvGpuPowerInfo();
     if (NvapiNativeMethods.NvPowerPoliciesGetInfo == null)
     {
         return(false);
     }
     try {
         info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvGpuPowerInfo))));
         var r = NvapiNativeMethods.NvPowerPoliciesGetInfo(HandlesByBusId[busId], ref info);
         if (r != NvStatus.OK)
         {
             Write.DevError($"{nameof(NvapiNativeMethods.NvPowerPoliciesGetInfo)} {r}");
             return(false);
         }
         return(true);
     }
     catch {
         return(false);
     }
 }
Beispiel #26
0
 private bool NvThermalPoliciesSetLimit(int busId, ref NvGpuThermalLimit info)
 {
     if (NvapiNativeMethods.NvThermalPoliciesSetLimit == null)
     {
         return(false);
     }
     try {
         info.version = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuThermalLimit))));
         var r = NvapiNativeMethods.NvThermalPoliciesSetLimit(HandlesByBusId[busId], ref info);
         if (r != NvStatus.OK)
         {
             Write.DevError($"{nameof(NvapiNativeMethods.NvThermalPoliciesSetLimit)} {r}");
         }
         if (r == NvStatus.OK)
         {
             return(true);
         }
     }
     catch {
     }
     return(false);
 }
Beispiel #27
0
 private bool NvSetPStateV2(int busId, ref NvGpuPerfPStates20InfoV2 info)
 {
     if (NvapiNativeMethods.NvSetPStateV2 == null)
     {
         return(false);
     }
     try {
         info.version = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuPerfPStates20InfoV2))));
         var r = NvapiNativeMethods.NvSetPStateV2(HandlesByBusId[busId], ref info);
         if (r != NvStatus.OK)
         {
             Write.DevError($"{nameof(NvapiNativeMethods.NvSetPStateV2)} {r}");
         }
         if (r == NvStatus.OK)
         {
             return(true);
         }
     }
     catch {
     }
     return(false);
 }
Beispiel #28
0
 // 20卡不支持该方法,所以尝试两次返回值不正确不再尝试
 private bool GetCoolerSettings(int busId, out NvCoolerSettings info)
 {
     info = new NvCoolerSettings();
     if (NvapiNativeMethods.NvGetCoolerSettings == null)
     {
         return(false);
     }
     info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvCoolerSettings))));
     try {
         NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
         var            r           = NvapiNativeMethods.NvGetCoolerSettings(HandlesByBusId[busId], coolerIndex, ref info);
         if (r != NvStatus.OK)
         {
             Write.DevError($"{nameof(NvapiNativeMethods.NvGetCoolerSettings)} {r}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }
Beispiel #29
0
 private bool NvGetPStateV2(int busId, out NvGpuPerfPStates20InfoV2 info)
 {
     info = new NvGpuPerfPStates20InfoV2();
     if (NvapiNativeMethods.NvGetPStateV2 == null)
     {
         return(false);
     }
     try {
         info.version = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuPerfPStates20InfoV2))));
         var r = NvapiNativeMethods.NvGetPStateV2(HandlesByBusId[busId], ref info);
         if (r != NvStatus.OK)
         {
             Write.DevError($"{nameof(NvapiNativeMethods.NvGetPStateV2)} {r}");
             return(false);
         }
         return(true);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(false);
     }
 }
Beispiel #30
0
 private static bool NvFanCoolersGetControl(int busId, out PrivateFanCoolersControlV1 info)
 {
     info = PrivateFanCoolersControlV1.Create();
     if (NvapiNativeMethods.NvFanCoolersGetControl == null)
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         var r = NvapiNativeMethods.NvFanCoolersGetControl(handle, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvFanCoolersGetControl)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }