Пример #1
0
        public static void Manual(string gpuType, int powerlimit, int coreclock, int fan, int memoryclock)
        {
            for (int i = 0; i < mahm.Header.GpuEntryCount; i++)
            {
                try
                {
                    macm.GpuEntries[i].FanSpeedCur = Convert.ToUInt32(fan);
                }
                catch (Exception ex)
                {
                    macm.GpuEntries[i].FanFlagsCur = MACM_SHARED_MEMORY_GPU_ENTRY_FAN_FLAG.None;
                    macm.GpuEntries[i].FanSpeedCur = Convert.ToUInt32(fan);
                }

                macm.GpuEntries[i].PowerLimitCur = powerlimit;

                if (gpuType.Equals("nvidia"))
                {
                    macm.GpuEntries[i].CoreClockBoostCur   = coreclock * 1000;
                    macm.GpuEntries[i].MemoryClockBoostCur = memoryclock * 1000;
                }

                if (gpuType.Equals("amd"))
                {
                    macm.GpuEntries[i].CoreClockCur   = Convert.ToUInt32(coreclock * 1000);
                    macm.GpuEntries[i].MemoryClockCur = Convert.ToUInt32(memoryclock * 1000);
                }


                // APPLY AFTERBURNER CHANGES
                macm.CommitChanges();
                System.Threading.Thread.Sleep(2000);
                macm.ReloadAll();
            }
        }
Пример #2
0
        public static void SetFanSpeed(string arg)
        {
            try
            {
                if (arg.Equals("auto", StringComparison.OrdinalIgnoreCase))
                {
                    ControlMemory control = new ControlMemory();

                    var gpu = control.GpuEntries.First();
                    gpu.FanFlagsCur = MACM_SHARED_MEMORY_GPU_ENTRY_FAN_FLAG.AUTO;
                    Console.WriteLine("Setting Fan Speed to AUTO");
                    control.CommitChanges();
                }
                else if (uint.TryParse(arg, out uint resultParse))
                {
                    if (resultParse >= 0 && resultParse <= 100)
                    {
                        ControlMemory control = new ControlMemory();

                        var gpu = control.GpuEntries.First();
                        gpu.FanFlagsCur = MACM_SHARED_MEMORY_GPU_ENTRY_FAN_FLAG.None;
                        gpu.FanSpeedCur = resultParse;
                        Console.WriteLine($"Setting Fan Speed to {resultParse}");
                        control.CommitChanges();
                    }
                    else
                    {
                        DisplayError();
                    }
                }
                else
                {
                    DisplayError();
                }
            }
            catch (Exception)
            {
                Console.WriteLine($"Error while setting fan value.");
                throw;
            }
        }
        private void RestoreCard(CardPramsMessageModel card)
        {
            const int divider    = 1000;
            var       messageBus = _messageBusFactory.Create();

            try
            {
                var lmacm = new ControlMemory();
                lmacm.Connect();

                var flags = lmacm.GpuEntries[card.Id].Flags;

                var voltageBoost     = flags.HasFlag(MACM_SHARED_MEMORY_GPU_ENTRY_FLAG.CORE_VOLTAGE_BOOST);
                var coreclockBoost   = flags.HasFlag(MACM_SHARED_MEMORY_GPU_ENTRY_FLAG.CORE_CLOCK_BOOST);
                var memoryclockBoost = flags.HasFlag(MACM_SHARED_MEMORY_GPU_ENTRY_FLAG.MEMORY_CLOCK_BOOST);


                lmacm.GpuEntries[card.Id].ThermalLimitCur = (int)card.TempLimit;
                lmacm.GpuEntries[card.Id].PowerLimitCur   = (int)card.PowerLimit;
                lmacm.GpuEntries[card.Id].FanSpeedCur     = (uint)card.FanSpeed;

                if (voltageBoost)
                {
                    lmacm.GpuEntries[card.Id].CoreVoltageBoostCur = (int)card.Voltage;
                }
                else
                {
                    lmacm.GpuEntries[card.Id].CoreVoltageCur = (uint)card.Voltage;
                }

                if (coreclockBoost)
                {
                    lmacm.GpuEntries[card.Id].CoreClockBoostCur = (int)card.CoreClock * divider;
                }
                else
                {
                    lmacm.GpuEntries[card.Id].CoreClockCur = (uint)card.CoreClock * divider;
                }

                if (memoryclockBoost)
                {
                    lmacm.GpuEntries[card.Id].MemoryClockBoostCur = (int)card.MemoryClock * divider;
                }
                else
                {
                    lmacm.GpuEntries[card.Id].MemoryClockCur = (uint)card.MemoryClock * divider;
                }


                lmacm.CommitChanges();
                lmacm.Disconnect();

                if (_logger.IsWarnEnabled)
                {
                    _logger.Warn($"Restore card > {card}");
                }
                messageBus.Handle(new AutobernerWatchdogResetMessage {
                    Status = MessageStatus.Ok
                });
            }
            catch (Exception ex)
            {
                _logger.Error($"inner exception: {ex.InnerException?.Message ?? string.Empty} > exception: {ex.Message}", ex);
                messageBus.Handle(new AutobernerWatchdogResetMessage {
                    Status = MessageStatus.Error
                });
            }
        }
Пример #4
0
        public static void Manual(string gpuType, int powerlimit, int coreclock, int fan, int memoryclock)
        {
            for (int i = 0; i < mahm.Header.GpuEntryCount; i++)
            {
                if (!fan.Equals(9999))
                {
                    try
                    {
                        macm.GpuEntries[i].FanSpeedCur = Convert.ToUInt32(fan);
                    }
                    catch (Exception ex)
                    {
                        macm.GpuEntries[i].FanFlagsCur = MACM_SHARED_MEMORY_GPU_ENTRY_FAN_FLAG.None;
                        macm.GpuEntries[i].FanSpeedCur = Convert.ToUInt32(fan);
                    }
                }

                if (!powerlimit.Equals(9999))
                {
                    try {
                        macm.GpuEntries[i].PowerLimitCur = powerlimit;
                    }
                    catch (Exception powerIssue) { Console.WriteLine(powerIssue.ToString()); }
                }

                if (gpuType.Equals("nvidia"))
                {
                    if (!coreclock.Equals(9999))
                    {
                        try
                        {
                            macm.GpuEntries[i].CoreClockBoostCur = coreclock * 1000;
                        }
                        catch (Exception coreIssue) { Program.NewMessage(coreIssue.ToString(), ""); }
                    }

                    if (!memoryclock.Equals(9999))
                    {
                        try
                        {
                            macm.GpuEntries[i].MemoryClockBoostCur = memoryclock * 1000;
                        }
                        catch (Exception memoryIssue) { Console.WriteLine(memoryIssue.ToString()); }
                    }
                }

                if (gpuType.Equals("amd"))
                {
                    if (!coreclock.Equals(9999))
                    {
                        try
                        {
                            macm.GpuEntries[i].CoreClockCur = Convert.ToUInt32(coreclock * 1000);
                        }
                        catch (Exception coreIssue) { Program.NewMessage(coreIssue.ToString(), ""); }
                    }
                    if (!memoryclock.Equals(9999))
                    {
                        try
                        {
                            macm.GpuEntries[i].MemoryClockCur = Convert.ToUInt32(memoryclock * 1000);
                        }
                        catch (Exception memoryIssue) { Console.WriteLine(memoryIssue.ToString()); }
                    }
                }

                try
                {
                    // APPLY AFTERBURNER CHANGES
                    macm.CommitChanges();
                    System.Threading.Thread.Sleep(2000);
                    macm.ReloadAll();
                }
                catch (Exception applySettings)
                {
                    Program.NewMessage("AfterBurner => Install v4.5 version for ClockTune support", "ERROR");
                }
            }
        }
        private void RestoreCard(CardParam[] configCards, CardParam card)
        {
            const int divider    = 1000;
            var       messageBus = _messageBusFactory.Create();

            try
            {
                if (card == null)
                {
                    _logger.Error("card for restore is null!, ret <");
                    return;
                }

                var lmacm = new ControlMemory();
                lmacm.Connect();

                var configCardParam = configCards.FirstOrDefault(x => x.Id == card.Id);

                if (configCardParam == null)
                {
                    if (_logger.IsDebugEnabled)
                    {
                        _logger.Debug($"Try restore card > {card} - error > not found in config");
                    }
                    return;
                }

                var flags = lmacm.GpuEntries[card.Id].Flags;

                var voltageBoost     = flags.HasFlag(MACM_SHARED_MEMORY_GPU_ENTRY_FLAG.CORE_VOLTAGE_BOOST);
                var coreclockBoost   = flags.HasFlag(MACM_SHARED_MEMORY_GPU_ENTRY_FLAG.CORE_CLOCK_BOOST);
                var memoryclockBoost = flags.HasFlag(MACM_SHARED_MEMORY_GPU_ENTRY_FLAG.MEMORY_CLOCK_BOOST);


                lmacm.GpuEntries[card.Id].ThermalLimitCur = (int)configCardParam.TempLimit.Current;
                lmacm.GpuEntries[card.Id].PowerLimitCur   = (int)configCardParam.PowerLimit.Current;
                lmacm.GpuEntries[card.Id].FanSpeedCur     = (uint)configCardParam.FanSpeed.Current;

                if (voltageBoost)
                {
                    lmacm.GpuEntries[card.Id].CoreVoltageBoostCur = (int)configCardParam.Voltage.Current;
                }
                else
                {
                    lmacm.GpuEntries[card.Id].CoreVoltageCur = (uint)configCardParam.Voltage.Current;
                }

                if (coreclockBoost)
                {
                    lmacm.GpuEntries[card.Id].CoreClockBoostCur = (int)configCardParam.CoreClock.Current * divider;
                }
                else
                {
                    lmacm.GpuEntries[card.Id].CoreClockCur = (uint)configCardParam.CoreClock.Current * divider;
                }

                if (memoryclockBoost)
                {
                    lmacm.GpuEntries[card.Id].MemoryClockBoostCur = (int)configCardParam.MemoryClock.Current * divider;
                }
                else
                {
                    lmacm.GpuEntries[card.Id].MemoryClockCur = (uint)configCardParam.MemoryClock.Current * divider;
                }


                lmacm.CommitChanges();
                lmacm.Disconnect();

                if (_logger.IsWarnEnabled)
                {
                    _logger.Warn($"Restore card > {card}");
                }
                messageBus.Publish(new AutobernerWatchdogResetMessage {
                    Status = MessageStatus.Ok
                });
            }
            catch (Exception ex)
            {
                _logger.Error($"inner exception: {ex.InnerException.Message} > exception: {ex.Message}", ex);
                messageBus.Publish(new AutobernerWatchdogResetMessage {
                    Status = MessageStatus.Error
                });
            }
        }
Пример #6
0
        public static void ApplyOverclock(IOverclock OC)
        {
            Task.Run(() =>
            {
                while (!MSIconnected)
                {
                    Thread.Sleep(100);
                }

                Process.Start(MSIpath);

                tryApplyClock:

                CM = new ControlMemory();
                ControlMemory nConf;
                List <ControlMemoryGpuEntry> gpuEnries = new List <ControlMemoryGpuEntry>();

                do
                {
                    Thread.Sleep(50);
                    CM.ReloadAll();
                    nConf = CM;
                    if (nConf.GpuEntries.Length > 0)
                    {
                        var vals = ValidGPUS.ToArray();
                        for (int i = 0; i < vals.Length; i++)
                        {
                            if (vals[i])
                            {
                                gpuEnries.Add(nConf.GpuEntries[i]);
                            }
                        }
                    }
                }while (gpuEnries[0].PowerLimitMax == 0);

                for (int i = 0; i < gpuEnries.Count; i++)
                {
                    try
                    {
                        gpuEnries[i].PowerLimitCur = SetParam(i, 1, OC.PowLim,
                                                              gpuEnries[i].PowerLimitMax,
                                                              gpuEnries[i].PowerLimitMin,
                                                              gpuEnries[i].PowerLimitDef);
                    }
                    catch { }

                    if (gpuEnries[i].CoreClockBoostMax - gpuEnries[i].CoreClockBoostMin != 0)
                    {
                        try
                        {
                            gpuEnries[i].CoreClockBoostCur = SetParam(i, 1000, OC.CoreClock,
                                                                      gpuEnries[i].CoreClockBoostMax,
                                                                      gpuEnries[i].CoreClockBoostMin,
                                                                      gpuEnries[i].CoreClockBoostDef);
                        }
                        catch { }
                    }
                    else if (gpuEnries[i].CoreClockMax - gpuEnries[i].CoreClockMin != 0)
                    {
                        try
                        {
                            gpuEnries[i].CoreClockCur = SetParam(i, 1000, OC.CoreClock,
                                                                 gpuEnries[i].CoreClockMax,
                                                                 gpuEnries[i].CoreClockMin,
                                                                 gpuEnries[i].CoreClockDef);
                        }
                        catch { }
                    }

                    if (gpuEnries[i].MemoryClockBoostMax - gpuEnries[i].MemoryClockBoostMin != 0)
                    {
                        try
                        {
                            gpuEnries[i].MemoryClockBoostCur = SetParam(i, 1000, OC.MemoryClock,
                                                                        gpuEnries[i].MemoryClockBoostMax,
                                                                        gpuEnries[i].MemoryClockBoostMin,
                                                                        gpuEnries[i].MemoryClockBoostDef);
                        }
                        catch { }
                    }
                    else if (gpuEnries[i].MemoryClockMax - gpuEnries[i].MemoryClockMin != 0)
                    {
                        try
                        {
                            gpuEnries[i].MemoryClockCur = SetParam(i, 1000, OC.MemoryClock,
                                                                   gpuEnries[i].MemoryClockMax,
                                                                   gpuEnries[i].MemoryClockMin,
                                                                   gpuEnries[i].MemoryClockDef);
                        }
                        catch { }
                    }

                    try
                    {
                        if (OC.FanSpeed != null)
                        {
                            if (OC.FanSpeed.Length > i)
                            {
                                gpuEnries[i].FanFlagsCur = MACM_SHARED_MEMORY_GPU_ENTRY_FAN_FLAG.None;
                                if (OC.FanSpeed[i] > gpuEnries[i].FanSpeedMax)
                                {
                                    gpuEnries[i].FanSpeedCur = gpuEnries[i].FanSpeedMax;
                                }
                                else if (OC.FanSpeed[i] < gpuEnries[i].FanSpeedMin)
                                {
                                    gpuEnries[i].FanSpeedCur = gpuEnries[i].FanSpeedMin;
                                }
                                else
                                {
                                    gpuEnries[i].FanSpeedCur = Convert.ToUInt32(OC.FanSpeed[i]);
                                }
                            }
                            else
                            {
                                gpuEnries[i].FanFlagsCur = MACM_SHARED_MEMORY_GPU_ENTRY_FAN_FLAG.AUTO;
                            }
                        }
                        else
                        {
                            gpuEnries[i].FanFlagsCur = MACM_SHARED_MEMORY_GPU_ENTRY_FAN_FLAG.AUTO;
                        }
                    }
                    catch { }
                }

                while (true)
                {
                    try
                    {
                        CM = nConf;
                        CM.CommitChanges();

                        Thread.Sleep(3000);

                        if (MSICurrent != null)
                        {
                            var msi = MSICurrent.Value;

                            for (int i = 0; i < OC.PowLim.Length; i++)
                            {
                                if (OC.PowLim != null)
                                {
                                    if (msi.PowerLimits[i] != OC.PowLim[i])
                                    {
                                        goto tryApplyClock;
                                    }
                                }

                                if (OC.CoreClock != null)
                                {
                                    if (msi.CoreClocks[i] != OC.CoreClock[i])
                                    {
                                        goto tryApplyClock;
                                    }
                                }

                                if (OC.MemoryClock != null)
                                {
                                    if (msi.MemoryClocks[i] != OC.MemoryClock[i])
                                    {
                                        goto tryApplyClock;
                                    }
                                }
                            }
                        }
                        else
                        {
                            goto tryApplyClock;
                        }


                        Task.Run(() => OverclockApplied?.Invoke());
                        return;
                    }
                    catch { }
                    Thread.Sleep(50);
                }
            });
        }