Beispiel #1
0
 private void RefreshGpuState(IGpu gpu)
 {
     if (gpu.Index == NTMinerRoot.GpuAllId)
     {
         return;
     }
     gpu.PowerCapacity    = _adlHelper.GetPowerLimitByIndex(gpu.Index);
     gpu.TempLimit        = _adlHelper.GetTempLimitByIndex(gpu.Index);
     gpu.MemoryClockDelta = _adlHelper.GetMemoryClockByIndex(gpu.Index);
     gpu.CoreClockDelta   = _adlHelper.GetSystemClockByIndex(gpu.Index);
     _adlHelper.GetClockRangeByIndex(
         gpu.Index,
         out int coreClockDeltaMin, out int coreClockDeltaMax,
         out int memoryClockDeltaMin, out int memoryClockDeltaMax,
         out int powerMin, out int powerMax, out int powerDefault,
         out int tempLimitMin, out int tempLimitMax, out int tempLimitDefault,
         out int fanSpeedMin, out int fanSpeedMax, out int fanSpeedDefault);
     gpu.CoreClockDeltaMin   = coreClockDeltaMin;
     gpu.CoreClockDeltaMax   = coreClockDeltaMax;
     gpu.MemoryClockDeltaMin = memoryClockDeltaMin;
     gpu.MemoryClockDeltaMax = memoryClockDeltaMax;
     gpu.PowerMin            = powerMin;
     gpu.PowerMax            = powerMax;
     gpu.PowerDefault        = powerDefault;
     gpu.TempLimitMin        = tempLimitMin;
     gpu.TempLimitMax        = tempLimitMax;
     gpu.TempLimitDefault    = tempLimitDefault;
     gpu.CoolMin             = fanSpeedMin;
     gpu.CoolMax             = fanSpeedMax;
     VirtualRoot.Happened(new GpuStateChangedEvent(gpu));
 }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
 public GpuViewModel(IGpu data)
 {
     _index               = data.Index;
     _name                = data.Name;
     _totalMemory         = data.TotalMemory;
     _temperature         = data.Temperature;
     _fanSpeed            = data.FanSpeed;
     _powerUsage          = data.PowerUsage;
     _state               = data.State;
     _coreClockDelta      = data.CoreClockDelta;
     _memoryClockDelta    = data.MemoryClockDelta;
     _coreClockDeltaMin   = data.CoreClockDeltaMin;
     _coreClockDeltaMax   = data.CoreClockDeltaMax;
     _memoryClockDeltaMin = data.MemoryClockDeltaMin;
     _memoryClockDeltaMax = data.MemoryClockDeltaMax;
     _cool                = data.Cool;
     _coolMin             = data.CoolMin;
     _coolMax             = data.CoolMax;
     _powerCapacity       = data.PowerCapacity;
     _powerMin            = data.PowerMin;
     _powerMax            = data.PowerMax;
     _tempLimit           = data.TempLimit;
     _tempLimitDefault    = data.TempLimitDefault;
     _tempLimitMax        = data.TempLimitMax;
     _tempLimitMin        = data.TempLimitMin;
 }
Beispiel #4
0
        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);
            }
        }
Beispiel #5
0
 public GpuSpeed(IGpu gpu, Speed mainCoinSpeed, Speed dualCoinSpeed)
 {
     this.Gpu       = gpu;
     _mainCoinSpeed = mainCoinSpeed;
     _dualCoinSpeed = dualCoinSpeed;
     FoundShareOn   = DateTime.MinValue;
 }
Beispiel #6
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 #7
0
 public GpuViewModel(IGpu data)
 {
     _gpuType             = data.GpuType;
     _index               = data.Index;
     _busId               = data.BusId;
     _name                = data.Name;
     _totalMemory         = data.TotalMemory;
     _temperature         = data.Temperature;
     _fanSpeed            = data.FanSpeed;
     _powerUsage          = data.PowerUsage;
     _coreClockDelta      = data.CoreClockDelta;
     _memoryClockDelta    = data.MemoryClockDelta;
     _coreClockDeltaMin   = data.CoreClockDeltaMin;
     _coreClockDeltaMax   = data.CoreClockDeltaMax;
     _memoryClockDeltaMin = data.MemoryClockDeltaMin;
     _memoryClockDeltaMax = data.MemoryClockDeltaMax;
     _cool                = data.Cool;
     _coolMin             = data.CoolMin;
     _coolMax             = data.CoolMax;
     _powerCapacity       = data.PowerCapacity;
     _powerMin            = data.PowerMin;
     _powerMax            = data.PowerMax;
     _powerDefault        = data.PowerDefault;
     _tempLimit           = data.TempLimit;
     _tempLimitDefault    = data.TempLimitDefault;
     _tempLimitMax        = data.TempLimitMax;
     _tempLimitMin        = data.TempLimitMin;
     _coreVoltage         = data.CoreVoltage;
     _memoryVoltage       = data.MemoryVoltage;
     _voltMin             = data.VoltMin;
     _voltMax             = data.VoltMax;
     _voltDefault         = data.VoltDefault;
 }
Beispiel #8
0
        public bool TryGetGpu(int index, out IGpu gpu)
        {
            bool r = _gpus.TryGetValue(index, out Gpu g);

            gpu = g;
            return(r);
        }
Beispiel #9
0
        public bool TryGetGpu(int index, out IGpu gpu)
        {
            var r = _gpus.TryGetValue(index, out Gpu temp);

            gpu = temp;
            return(r);
        }
Beispiel #10
0
        public static void UpdateState(this IGpu gpu, OverClockRange range)
        {
            gpu.CoreClockDeltaMin = range.CoreClockMin;
            gpu.CoreClockDeltaMax = range.CoreClockMax;
            gpu.CoreClockDelta    = range.CoreClockDelta;
            gpu.CoreVoltage       = range.CoreVoltage;

            gpu.MemoryClockDeltaMin      = range.MemoryClockMin;
            gpu.MemoryClockDeltaMax      = range.MemoryClockMax;
            gpu.MemoryClockDelta         = range.MemoryClockDelta;
            gpu.MemoryVoltage            = range.MemoryVoltage;
            gpu.CurrentMemoryTimingLevel = range.CurrentMemoryTimingLevel;

            gpu.TempLimitMin     = range.TempLimitMin;
            gpu.TempLimitMax     = range.TempLimitMax;
            gpu.TempLimit        = range.TempCurr;
            gpu.TempLimitDefault = range.TempLimitDefault;

            gpu.PowerMin      = range.PowerMin;
            gpu.PowerMax      = range.PowerMax;
            gpu.PowerCapacity = range.PowerCurr;
            gpu.PowerDefault  = range.PowerDefault;

            gpu.CoolMin = range.FanSpeedMin;
            gpu.CoolMax = range.FanSpeedMax;

            gpu.VoltMin = range.VoltMin;
            gpu.VoltMax = range.VoltMax;
            NTMinerContext.Instance.GpuSet.LoadGpuState(gpu.Index);
        }
Beispiel #11
0
 public AsrockH87(ICpu cpu, IRam ram, IFan cpuFan, ISolidStateDrive solidStateDrive, IGpu gpu, IBios bios)
 {
     Cpu             = cpu;
     Ram             = ram;
     CpuFan          = cpuFan;
     SolidStateDrive = solidStateDrive;
     Gpu             = gpu;
     Bios            = bios;
 }
Beispiel #12
0
        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);
        }
Beispiel #13
0
 public Console(ICpu cpu, IMmu mmu, IGpu gpu, ITimer timer, IController controller)
 {
     Cpu = cpu;
     Mmu = mmu;
     Gpu = gpu;
     Timer = timer;
     Controller = controller;
     _emitFrames = true;
     _breakpoints = new HashSet<uint>();
 }
Beispiel #14
0
 public Console(ICpu cpu, IMmu mmu, IGpu gpu, ITimer timer, IController controller)
 {
     Cpu          = cpu;
     Mmu          = mmu;
     Gpu          = gpu;
     Timer        = timer;
     Controller   = controller;
     _emitFrames  = true;
     _breakpoints = new HashSet <uint>();
 }
Beispiel #15
0
 public static int GetOverClockId(this IGpu gpu)
 {
     if (NTMinerRoot.Instance.GpuSet.GpuType != GpuType.NVIDIA)
     {
         return(gpu.Index);
     }
     if (int.TryParse(gpu.BusId, out int busId))
     {
         return(busId);
     }
     throw new FormatException("BusId的格式必须是数字");
 }
Beispiel #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameBoyMemoryMappedIo" /> class.
 /// </summary>
 /// <param name="hardwareRegisters">The hardware registers.</param>
 /// <param name="interruptRegister">The interrupt register.</param>
 /// <param name="gpu">The gpu.</param>
 /// <param name="renderer">The renderer.</param>
 /// <param name="memoryBankController">The memory bank controller.</param>
 public GameBoyMemoryMappedIo(IHardwareRegisters hardwareRegisters,
                              IInterruptEnableRegister interruptRegister,
                              IGpu gpu,
                              IRenderer renderer,
                              IMemoryBankController memoryBankController)
 {
     HardwareRegisters  = hardwareRegisters;
     _interruptRegister = interruptRegister;
     Gpu      = gpu;
     Renderer = renderer;
     _memoryBankController = memoryBankController;
 }
Beispiel #17
0
 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));
 }
Beispiel #18
0
 public void RefreshGpuState(IGpu gpu)
 {
     if (gpu.Index == NTMinerContext.GpuAllId)
     {
         return;
     }
     try {
         OverClockRange range = _gpuHelper.GetClockRange(gpu);
         gpu.UpdateState(range);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
     }
     VirtualRoot.RaiseEvent(new GpuStateChangedEvent(Guid.Empty, gpu));
 }
Beispiel #19
0
        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);
            }
        }
Beispiel #20
0
 public GpuViewModel(IGpu data)
 {
     _overClock           = data.OverClock;
     _index               = data.Index;
     _name                = data.Name;
     _temperature         = data.Temperature;
     _fanSpeed            = data.FanSpeed;
     _powerUsage          = data.PowerUsage;
     _coreClockDelta      = data.CoreClockDelta;
     _memoryClockDelta    = data.MemoryClockDelta;
     _coreClockDeltaMin   = data.CoreClockDeltaMin;
     _coreClockDeltaMax   = data.CoreClockDeltaMax;
     _memoryClockDeltaMin = data.MemoryClockDeltaMin;
     _memoryClockDeltaMax = data.MemoryClockDeltaMax;
     _cool                = data.Cool;
     _coolMin             = data.CoolMin;
     _coolMax             = data.CoolMax;
     _power               = data.Power;
     _powerMin            = data.PowerMin;
     _powerMax            = data.PowerMax;
 }
Beispiel #21
0
 internal void Correct(IGpu gpu)
 {
     if (gpu.GpuType == GpuType.AMD)
     {
         // A卡的超频不会为负
         if (this.CoreClockMHz < 0)
         {
             this.CoreClockMHz = 0;
         }
         if (this.MemoryClockMHz < 0)
         {
             this.MemoryClockMHz = 0;
         }
     }
     if (this.CoreClockVoltage < 0)
     {
         this.CoreClockVoltage = 0;
     }
     if (this.MemoryClockVoltage < 0)
     {
         this.MemoryClockVoltage = 0;
     }
 }
Beispiel #22
0
 public void SetGPU(IGpu gpu)
 {
 }
Beispiel #23
0
        private void RefreshGpuState(IGpu gpu)
        {
            const string coreClockDeltaMinMaxPattern   = @"c\[0\]\.freqDelta     = (-?\d+) kHz \[(-?\d+) .. (\d+)\]";
            const string memoryClockDeltaMinMaxPattern = @"c\[1\]\.freqDelta     = (-?\d+) kHz \[(-?\d+) .. (\d+)\]";
            const string coolSpeedMinMaxPattern        = @"cooler\[0\]\.speed   = (\d+) % \[(-?\d+) .. (\d+)\]";
            const string powerMinPattern          = @"policy\[0\]\.pwrLimitMin     = (\d+\.?\d*) %";
            const string powerMaxPattern          = @"policy\[0\]\.pwrLimitMax     = (\d+\.?\d*) %";
            const string powerDefaultPattern      = @"policy\[0\]\.pwrLimitDefault = (\d+\.?\d*) %";
            const string powerLimitCurrentPattern = @"policy\[0\]\.pwrLimitCurrent = (\d+\.?\d*) %";
            const string tempLimitMinPattern      = @"policy\[0\]\.tempLimitMin     = (\d+\.?\d*)C";
            const string tempLimitMaxPattern      = @"policy\[0\]\.tempLimitMax     = (\d+\.?\d*)C";
            const string tempLimitDefaultPattern  = @"policy\[0\]\.tempLimitDefault = (\d+\.?\d*)C";
            const string tempLimitPattern         = @"policy\[0\]\.tempLimitCurrent = (\d+\.?\d*)C";

            if (gpu.Index == NTMinerRoot.GpuAllId)
            {
                return;
            }
            int exitCode = -1;

            Windows.Cmd.RunClose(SpecialPath.NTMinerOverClockFileFullName, $"gpu:{gpu.Index} ps20e", ref exitCode, out string output);
            int    coreClockDeltaMin   = 0;
            int    coreClockDeltaMax   = 0;
            int    memoryClockDeltaMin = 0;
            int    memoryClockDeltaMax = 0;
            int    cool             = 0;
            int    coolMin          = 0;
            int    coolMax          = 0;
            double powerMin         = 50;
            double powerMax         = 100;
            double powerDefault     = 100;
            double powerCapacity    = 0;
            double tempLimitMin     = 0;
            double tempLimitMax     = 0;
            double tempLimitDefault = 0;
            double tempLimit        = 0;

            if (exitCode == 0)
            {
                Match match = Regex.Match(output, coreClockDeltaMinMaxPattern, RegexOptions.Compiled);
                if (match.Success)
                {
                    int.TryParse(match.Groups[1].Value, out int coreClockDelta);
                    gpu.CoreClockDelta = coreClockDelta;
                    int.TryParse(match.Groups[2].Value, out coreClockDeltaMin);
                    int.TryParse(match.Groups[3].Value, out coreClockDeltaMax);
                }
                match = Regex.Match(output, memoryClockDeltaMinMaxPattern, RegexOptions.Compiled);
                if (match.Success)
                {
                    int.TryParse(match.Groups[1].Value, out int memoryClockDelta);
                    gpu.MemoryClockDelta = memoryClockDelta;
                    int.TryParse(match.Groups[2].Value, out memoryClockDeltaMin);
                    int.TryParse(match.Groups[3].Value, out memoryClockDeltaMax);
                }
                gpu.CoreClockDeltaMin   = coreClockDeltaMin;
                gpu.CoreClockDeltaMax   = coreClockDeltaMax;
                gpu.MemoryClockDeltaMin = memoryClockDeltaMin;
                gpu.MemoryClockDeltaMax = memoryClockDeltaMax;
            }
            Windows.Cmd.RunClose(SpecialPath.NTMinerOverClockFileFullName, $"gpu:{gpu.Index} coolers", ref exitCode, out output);
            if (exitCode == 0)
            {
                Match match = Regex.Match(output, coolSpeedMinMaxPattern, RegexOptions.Compiled);
                if (match.Success)
                {
                    int.TryParse(match.Groups[1].Value, out cool);
                    int.TryParse(match.Groups[2].Value, out coolMin);
                    int.TryParse(match.Groups[3].Value, out coolMax);
                }
                gpu.Cool    = cool;
                gpu.CoolMin = coolMin;
                gpu.CoolMax = coolMax;
            }
            Windows.Cmd.RunClose(SpecialPath.NTMinerOverClockFileFullName, $"gpu:{gpu.Index} pwrinfo", ref exitCode, out output);
            if (exitCode == 0)
            {
                Match match = Regex.Match(output, powerMinPattern, RegexOptions.Compiled);
                if (match.Success)
                {
                    double.TryParse(match.Groups[1].Value, out powerMin);
                }
                match = Regex.Match(output, powerMaxPattern, RegexOptions.Compiled);
                if (match.Success)
                {
                    double.TryParse(match.Groups[1].Value, out powerMax);
                }
                match = Regex.Match(output, powerLimitCurrentPattern, RegexOptions.Compiled);
                if (match.Success)
                {
                    double.TryParse(match.Groups[1].Value, out powerCapacity);
                }
                match = Regex.Match(output, powerDefaultPattern, RegexOptions.Compiled);
                if (match.Success)
                {
                    double.TryParse(match.Groups[1].Value, out powerDefault);
                }
                gpu.PowerMin      = powerMin;
                gpu.PowerMax      = powerMax;
                gpu.PowerDefault  = powerDefault;
                gpu.PowerCapacity = (int)powerCapacity;
            }
            Windows.Cmd.RunClose(SpecialPath.NTMinerOverClockFileFullName, $"gpu:{gpu.Index} therminfo", ref exitCode, out output);
            if (exitCode == 0)
            {
                Match match = Regex.Match(output, tempLimitMinPattern, RegexOptions.Compiled);
                if (match.Success)
                {
                    double.TryParse(match.Groups[1].Value, out tempLimitMin);
                }
                match = Regex.Match(output, tempLimitMaxPattern, RegexOptions.Compiled);
                if (match.Success)
                {
                    double.TryParse(match.Groups[1].Value, out tempLimitMax);
                }
                match = Regex.Match(output, tempLimitDefaultPattern, RegexOptions.Compiled);
                if (match.Success)
                {
                    double.TryParse(match.Groups[1].Value, out tempLimitDefault);
                }
                match = Regex.Match(output, tempLimitPattern, RegexOptions.Compiled);
                if (match.Success)
                {
                    double.TryParse(match.Groups[1].Value, out tempLimit);
                }
                gpu.TempLimitMin     = (int)Math.Ceiling(tempLimitMin);
                gpu.TempLimitMax     = (int)Math.Floor(tempLimitMax);
                gpu.TempLimitDefault = (int)tempLimitDefault;
                gpu.TempLimit        = (int)tempLimit;
            }
            VirtualRoot.Happened(new GpuStateChangedEvent(gpu));
        }
Beispiel #24
0
 public GpuSpeed(IGpu gpu, Speed mainCoinSpeed, Speed dualCoinSpeed)
 {
     this.Gpu       = gpu;
     _mainCoinSpeed = mainCoinSpeed;
     _dualCoinSpeed = dualCoinSpeed;
 }
Beispiel #25
0
 public bool TryGetGpu(int index, out IGpu gpu)
 {
     gpu = null;
     return(false);
 }
Beispiel #26
0
 public GpuViewModel(IGpu gpu)
 {
     _gpu = gpu;
 }
 public static List <IGpuSpeed> GetGpuSpeedHistory(this IGpu gpu)
 {
     return(NTMinerRoot.Current.GpusSpeed.GetGpuSpeedHistory(gpu.Index));
 }
Beispiel #28
0
 public bool TryGetGpu(int index, out IGpu gpu)
 {
     return(_gpus.TryGetValue(index, out gpu));
 }
Beispiel #29
0
        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
        }
Beispiel #30
0
 public void Init(INTMinerRoot root)
 {
     if (_isInited)
     {
         return;
     }
     _isInited = true;
     VirtualRoot.AddEventPath <GpuStateChangedEvent>("当显卡温度变更时守卫温度防线", LogEnum.None,
                                                     action: message => {
         IGpu gpu = message.Target;
         if (gpu.Index == NTMinerRoot.GpuAllId || root.MinerProfile.CoinId == Guid.Empty)
         {
             return;
         }
         IGpuProfile gpuProfile;
         if (NTMinerRoot.Instance.GpuProfileSet.IsOverClockGpuAll(root.MinerProfile.CoinId))
         {
             gpuProfile = NTMinerRoot.Instance.GpuProfileSet.GetGpuProfile(root.MinerProfile.CoinId, NTMinerRoot.GpuAllId);
         }
         else
         {
             gpuProfile = NTMinerRoot.Instance.GpuProfileSet.GetGpuProfile(root.MinerProfile.CoinId, gpu.Index);
         }
         if (!gpuProfile.IsAutoFanSpeed)
         {
             return;
         }
         // 显卡温度抵达防御温度的时间
         if (!_fightedOnDic.TryGetValue(gpu.Index, out DateTime fightedOn))
         {
             fightedOn = DateTime.Now;
             _fightedOnDic.Add(gpu.Index, fightedOn);
         }
         if (gpu.FanSpeed == 100 && gpu.Temperature > _guardTemp)
         {
             Write.DevDebug($"GPU{gpu.Index.ToString()} 温度{gpu.Temperature.ToString()}大于防线温度{_guardTemp.ToString()},但风扇转速已达100%");
         }
         else if (gpu.Temperature < _guardTemp)
         {
             if (!_preTempDic.ContainsKey(gpu.Index))
             {
                 _preTempDic.Add(gpu.Index, 0);
             }
             // 如果当前温度比上次的温度大
             if (gpu.Temperature > _preTempDic[gpu.Index])
             {
                 fightedOn = DateTime.Now;
                 _fightedOnDic[gpu.Index] = fightedOn;
             }
             _preTempDic[gpu.Index] = gpu.Temperature;
             // 如果距离抵达防御温度的时间已经很久了则降速风扇
             if (fightedOn.AddSeconds(_fanSpeedDownSeconds) < DateTime.Now)
             {
                 int cool = (int)(gpu.FanSpeed - _fanSpeedDownStep);
                 // 如果温度低于50度则直接将风扇设为驱动默认的最小转速
                 if (gpu.Temperature < 50)
                 {
                     cool = gpu.CoolMin;
                 }
                 if (cool >= gpu.CoolMin)
                 {
                     _fightedOnDic[gpu.Index] = DateTime.Now;
                     root.GpuSet.OverClock.SetFanSpeed(gpu.Index, cool);
                     Write.DevDebug($"GPU{gpu.Index.ToString()} 风扇转速由{gpu.FanSpeed.ToString()}%调低至{cool.ToString()}%");
                 }
             }
         }
         else if (gpu.Temperature > _guardTemp)
         {
             uint cool;
             uint len;
             // 防线突破可能是由于小量降低风扇转速造成的
             if (fightedOn.AddSeconds(_fanSpeedDownSeconds) < DateTime.Now)
             {
                 _fightedOnDic[gpu.Index] = DateTime.Now;
                 len = 100 - gpu.FanSpeed;
             }
             else
             {
                 len = _fanSpeedDownStep;
             }
             cool = gpu.FanSpeed + (uint)Math.Ceiling(len / 2.0);
             if (cool > 100)
             {
                 cool = 100;
             }
             if (cool <= 100)
             {
                 root.GpuSet.OverClock.SetFanSpeed(gpu.Index, (int)cool);
                 Write.DevDebug($"GPU{gpu.Index.ToString()} 风扇转速由{gpu.FanSpeed.ToString()}%调高至{cool.ToString()}%");
             }
         }
     }, location: this.GetType());
 }
Beispiel #31
0
 public GpuSpeed(IGpu gpu)
 {
     this.Gpu = gpu;
 }