public void OverClock(IGpu gpu, OverClockValue value) { value.Correct(gpu); bool isSetCoreClock = value.GetIsSetCoreClock(gpu); bool isSetMemoryClock = value.GetIsSetMemoryClock(gpu); bool isSetPowerLimit = value.GetIsSetPowerLimit(gpu); bool isSetTempLimit = value.GetIsSetTempLimit(gpu); int busId = gpu.GetOverClockId(); if (isSetCoreClock) { SetCoreClock(busId, value.CoreClockMHz, value.CoreClockVoltage); } if (isSetMemoryClock) { SetMemoryClock(busId, value.MemoryClockMHz, value.MemoryClockVoltage); } if (isSetPowerLimit) { SetPowerLimit(busId, value.PowerLimit); } if (isSetTempLimit) { SetTempLimit(busId, value.TempLimit); } if (!value.IgnoreFanSpeed) { SetFanSpeed(gpu, value.FanSpeed); } }
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); } }
public void OverClock(IGpu gpu, OverClockValue value) { value.Correct(gpu); int busId = gpu.GetOverClockId(); SetCoreClock(busId, value.CoreClockMHz); int voltage = 0; if (value.CoreClockVoltage != 0 && value.MemoryClockVoltage != 0) { voltage = Math.Min(value.CoreClockVoltage, value.MemoryClockVoltage); } else { voltage = Math.Max(value.CoreClockVoltage, value.MemoryClockVoltage); } if (voltage >= 0) { SetVoltage(busId, voltage); } SetMemoryClock(busId, value.MemoryClockMHz); SetPowerLimit(busId, value.PowerLimit); SetTempLimit(busId, value.TempLimit); if (!value.IgnoreFanSpeed) { SetFanSpeed(gpu, value.FanSpeed); } }
public OverClockRange GetClockRange(IGpu gpu) { int busId = gpu.GetOverClockId(); OverClockRange result = new OverClockRange(busId); try { if (GetClockDelta(busId, out int outCoreCurrFreqDelta, out int outCoreMinFreqDelta, out int outCoreMaxFreqDelta, out int outMemoryCurrFreqDelta, out int outMemoryMinFreqDelta, out int outMemoryMaxFreqDelta)) { result.CoreClockMin = outCoreMinFreqDelta; result.CoreClockMax = outCoreMaxFreqDelta; result.CoreClockDelta = outCoreCurrFreqDelta; result.MemoryClockMin = outMemoryMinFreqDelta; result.MemoryClockMax = outMemoryMaxFreqDelta; result.MemoryClockDelta = outMemoryCurrFreqDelta; int voltage = GetVoltage(busId); result.CoreVoltage = voltage; result.MemoryVoltage = voltage; result.VoltMin = 0; result.VoltMax = 0; } if (GetPowerLimit(busId, out uint outCurrPower, out uint outMinPower, out uint outDefPower, out uint outMaxPower)) { result.PowerMin = (int)outMinPower; result.PowerMax = (int)outMaxPower; result.PowerDefault = (int)outDefPower; result.PowerCurr = (int)outCurrPower; } if (GetTempLimit(busId, out int outCurrTemp, out int outMinTemp, out int outDefTemp, out int outMaxTemp)) { result.TempLimitMin = outMinTemp; result.TempLimitMax = outMaxTemp; result.TempLimitDefault = outDefTemp; result.TempCurr = outCurrTemp; } if (GetCooler(busId, out uint minCooler, out uint currCooler, out uint maxCooler)) { result.FanSpeedCurr = (int)currCooler; result.FanSpeedMin = (int)minCooler; result.FanSpeedMax = (int)maxCooler; } #if DEBUG NTMinerConsole.DevWarn(() => $"GetClockRange {result.ToString()}"); #endif } catch (Exception e) { Logger.ErrorDebugLine(e); } return(result); }
public void RefreshGpuState(IGpu gpu) { if (gpu.Index == NTMinerRoot.GpuAllId) { return; } try { OverClockRange range = _gpuHelper.GetClockRange(gpu.GetOverClockId()); gpu.UpdateState(range); } catch (System.Exception e) { Logger.ErrorDebugLine(e); } VirtualRoot.Happened(new GpuStateChangedEvent(gpu)); }
public void OverClock( IGpu gpu, int coreClockMHz, int coreClockVoltage, int memoryClockMHz, int memoryClockVoltage, int powerLimit, int tempLimit, int fanSpeed) { if (coreClockVoltage < 0) { coreClockVoltage = 0; } if (memoryClockVoltage < 0) { memoryClockVoltage = 0; } bool isSetCoreClock = coreClockMHz == 0 || coreClockMHz != gpu.CoreClockDelta || coreClockVoltage != gpu.CoreVoltage; bool isSetMemoryClock = memoryClockMHz == 0 || memoryClockMHz != gpu.MemoryClockDelta || memoryClockVoltage != gpu.MemoryVoltage; bool isSetPowerLimit = powerLimit == 0 || powerLimit != gpu.PowerCapacity; bool isSetTempLimit = tempLimit == 0 || tempLimit != gpu.TempLimit; int busId = gpu.GetOverClockId(); if (isSetCoreClock) { SetCoreClock(busId, coreClockMHz, coreClockVoltage); } if (isSetMemoryClock) { SetMemoryClock(busId, memoryClockMHz, memoryClockVoltage); } if (isSetPowerLimit) { SetPowerLimit(busId, powerLimit); } if (isSetTempLimit) { SetTempLimit(busId, tempLimit); } // fanSpeed == -1表示开源自动温控 if (fanSpeed >= 0) { SetFanSpeed(gpu, fanSpeed); } }
public void SetFanSpeed(IGpu gpu, int fanSpeed) { bool isAutoMode = fanSpeed == 0; uint value = (uint)fanSpeed; int busId = gpu.GetOverClockId(); if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle)) { return; } #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; } } catch { } } #endregion #region RTX if (NvapiNativeMethods.NvFanCoolersSetControl == null) { return; } 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; } return; } return; } catch (Exception e) { Logger.ErrorDebugLine(e); return; } #endregion }