示例#1
0
        public bool SetTempLimit(int gpuIndex, int value)
        {
            if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
            {
                return(false);
            }
            ADLODNPowerLimitSetting info = new ADLODNPowerLimitSetting();

            try {
                var r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get(context, adapterIndex, ref info);
                if (r < AdlStatus.ADL_OK)
                {
                    Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get)} {r.ToString()}");
                    return(false);
                }
                bool isAutoModel = value == 0;
                info.iMode = isAutoModel ? AdlConst.ODNControlType_Auto : AdlConst.ODNControlType_Manual;
                info.iMaxOperatingTemperature = isAutoModel ? -1 : value;
                r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Set(context, adapterIndex, ref info);
                if (r < AdlStatus.ADL_OK)
                {
                    Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Set)} {r.ToString()}");
                    return(false);
                }
                return(true);
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
                return(false);
            }
        }
示例#2
0
 private int GetTemperature(int gpuIndex)
 {
     try {
         if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu))
         {
             return(0);
         }
         if (gpu.OverdriveVersion >= 7)
         {
             var r = AdlNativeMethods.ADL2_OverdriveN_Temperature_Get(_context, gpu.AdapterIndex, ADLODNTemperatureType.CORE, out int temperature);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_Temperature_Get)} {r.ToString()}");
                 return(0);
             }
             return((int)(0.001f * temperature));
         }
         else
         {
             ADLTemperature info = new ADLTemperature();
             var            r    = AdlNativeMethods.ADL_Overdrive5_Temperature_Get(gpu.AdapterIndex, 0, ref info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL_Overdrive5_Temperature_Get)} {r.ToString()}");
                 return(0);
             }
             return((int)(0.001f * info.Temperature));
         }
     }
     catch {
     }
     return(0);
 }
示例#3
0
 public void GetTempLimitAndPowerLimit(int gpuIndex, out int powerLimit, out int tempLimit)
 {
     powerLimit = 0;
     tempLimit  = 0;
     if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu))
     {
         return;
     }
     if (gpu.OverdriveVersion < 8)
     {
         ADLODNPowerLimitSetting info = new ADLODNPowerLimitSetting();
         try {
             var r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get(_context, gpu.AdapterIndex, out info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get)} {r.ToString()}");
             }
             else
             {
                 powerLimit = 100 + info.iTDPLimit;
                 tempLimit  = info.iMaxOperatingTemperature;
             }
         }
         catch {
         }
     }
     else
     {
         if (GetOD8CurrentSetting(gpu.AdapterIndex, out ADLOD8CurrentSetting odCurrentSetting))
         {
             powerLimit = 100 + odCurrentSetting.Od8SettingTable[(int)ADLOD8SettingId.OD8_POWER_PERCENTAGE];
             tempLimit  = odCurrentSetting.Od8SettingTable[(int)ADLOD8SettingId.OD8_FAN_CURVE_TEMPERATURE_5];
         }
     }
 }
示例#4
0
        public OverClockRange GetClockRange(int gpuIndex)
        {
            OverClockRange result = new OverClockRange(gpuIndex);

            try {
                if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
                {
                    return(result);
                }
                ADLODNCapabilitiesX2 info = new ADLODNCapabilitiesX2();
                var r = AdlNativeMethods.ADL2_OverdriveN_CapabilitiesX2_Get(context, adapterIndex, ref info);
                if (r < AdlStatus.ADL_OK)
                {
                    Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_CapabilitiesX2_Get)} {r}");
                    return(result);
                }
                result.PowerCurr = GetPowerLimit(gpuIndex);
                result.TempCurr  = GetTempLimit(gpuIndex);
                if (GetMemoryClock(gpuIndex, out int memoryClock, out int iVddc))
                {
                    result.MemoryClockDelta = memoryClock;
                    result.MemoryVoltage    = iVddc;
                }
                if (GetCoreClock(gpuIndex, out int coreClock, out iVddc))
                {
                    result.CoreClockDelta = coreClock;
                    result.CoreVoltage    = iVddc;
                }
                result.CoreClockMin     = info.sEngineClockRange.iMin * 10;
                result.CoreClockMax     = info.sEngineClockRange.iMax * 10;
                result.MemoryClockMin   = info.sMemoryClockRange.iMin * 10;
                result.MemoryClockMax   = info.sMemoryClockRange.iMax * 10;
                result.PowerMin         = info.power.iMin + 100;
                result.PowerMax         = info.power.iMax + 100;
                result.PowerDefault     = info.power.iDefault + 100;
                result.TempLimitMin     = info.powerTuneTemperature.iMin;
                result.TempLimitMax     = info.powerTuneTemperature.iMax;
                result.TempLimitDefault = info.powerTuneTemperature.iDefault;
                result.VoltMin          = info.svddcRange.iMin;
                result.VoltMax          = info.svddcRange.iMax;
                result.VoltDefault      = info.svddcRange.iDefault;
                if (info.fanSpeed.iMax == 0)
                {
                    result.FanSpeedMin = 0;
                }
                else
                {
                    result.FanSpeedMin = info.fanSpeed.iMin * 100 / info.fanSpeed.iMax;
                }
                result.FanSpeedMax     = 100;
                result.FanSpeedDefault = info.fanSpeed.iDefault;
#if DEBUG
                Write.DevWarn($"GetClockRange {result.ToString()}");
#endif
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
            }
            return(result);
        }
示例#5
0
        public bool SetPowerLimit(int gpuIndex, int value)
        {
            if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
            {
                return(false);
            }
            ADLODNPowerLimitSetting info = new ADLODNPowerLimitSetting();

            try {
                var r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get(context, adapterIndex, ref info);
                if (r < AdlStatus.ADL_OK)
                {
                    Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get)} {r.ToString()}");
                    return(false);
                }
#if DEBUG
                Write.DevWarn($"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get)} result={r.ToString()},iMode={info.iMode.ToString()},iTDPLimit={info.iTDPLimit.ToString()},iMaxOperatingTemperature={info.iMaxOperatingTemperature.ToString()}");
#endif
                info.iMode     = AdlConst.ODNControlType_Manual;
                info.iTDPLimit = value - 100;
                r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Set(context, adapterIndex, ref info);
                if (r < AdlStatus.ADL_OK)
                {
                    Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Set)} {r.ToString()}");
                    return(false);
                }
                return(true);
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
                return(false);
            }
        }
示例#6
0
 public bool GetMemoryClock(int gpuIndex, out int memoryClock, out int iVddc)
 {
     memoryClock = 0;
     iVddc       = 0;
     try {
         if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
         {
             return(false);
         }
         ADLODNPerformanceLevelsX2 info = ADLODNPerformanceLevelsX2.Create();
         var r = AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get(context, adapterIndex, ref info);
         if (r < AdlStatus.ADL_OK)
         {
             Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get)} {r.ToString()}");
             return(false);
         }
         int index = 0;
         for (int i = 0; i < info.aLevels.Length; i++)
         {
             if (info.aLevels[i].iEnabled != 0)
             {
                 index = i;
             }
             Write.DevWarn("GetMemoryClock " + info.aLevels[i].ToString());
         }
         memoryClock = info.aLevels[index].iClock * 10;
         iVddc       = info.aLevels[index].iVddc;
         return(true);
     }
     catch {
         return(false);
     }
 }
示例#7
0
 static AdlHelper()
 {
     try {
         int numberOfAdapters = 0;
         var adlStatus        = AdlNativeMethods.ADLMainControlCreate(out _context);
         if (adlStatus >= AdlStatus.ADL_OK)
         {
             adlStatus = AdlNativeMethods.ADL_Adapter_NumberOfAdapters_Get(ref numberOfAdapters);
             if (adlStatus < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL_Adapter_NumberOfAdapters_Get)} {adlStatus.ToString()}");
             }
         }
         if (numberOfAdapters > 0)
         {
             _adapterInfoes = new ADLAdapterInfo[numberOfAdapters];
             adlStatus      = AdlNativeMethods.ADLAdapterAdapterInfoGet(_adapterInfoes);
             if (adlStatus >= AdlStatus.ADL_OK && _adapterInfoes != null && _adapterInfoes.Length != 0)
             {
                 _adapterInfoes = _adapterInfoes.Where(adapterInfo => !string.IsNullOrEmpty(adapterInfo.UDID) && adapterInfo.VendorID == AdlConst.ATI_VENDOR_ID).ToArray();
                 _isHasATIGpu   = _adapterInfoes.Length > 0;
             }
         }
     }
     catch (Exception ex) {
         Logger.ErrorDebugLine(ex);
     }
 }
示例#8
0
 public void GetClockAndVolt(int gpuIndex, out int memoryClock, out int memoryiVddc, out int coreClock, out int coreiVddc)
 {
     memoryClock = 0;
     memoryiVddc = 0;
     coreClock   = 0;
     coreiVddc   = 0;
     try {
         if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu))
         {
             return;
         }
         if (gpu.OverdriveVersion < 8)
         {
             try {
                 ADLODNPerformanceLevelsX2 info = ADLODNPerformanceLevelsX2.Create();
                 var r = AdlNativeMethods.ADL2_OverdriveN_SystemClocksX2_Get(_context, gpu.AdapterIndex, ref info);
                 if (r < AdlStatus.ADL_OK)
                 {
                     NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_SystemClocksX2_Get)} {r.ToString()}");
                 }
                 var index = gpu.GpuLevels - 1;
                 coreClock = info.aLevels[index].iClock * 10;
                 coreiVddc = info.aLevels[index].iVddc;
             }
             catch {
             }
             try {
                 ADLODNPerformanceLevelsX2 info = ADLODNPerformanceLevelsX2.Create();
                 var r = AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get(_context, gpu.AdapterIndex, ref info);
                 if (r < AdlStatus.ADL_OK)
                 {
                     NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get)} {r.ToString()}");
                 }
                 int index = gpu.MemoryLevels - 1;
                 memoryClock = info.aLevels[index].iClock * 10;
                 memoryiVddc = info.aLevels[index].iVddc;
             }
             catch {
             }
         }
         else if (GetOD8CurrentSetting(gpu.AdapterIndex, out ADLOD8CurrentSetting odCurrentSetting))
         {
             coreClock   = odCurrentSetting.Od8SettingTable[(int)ADLOD8SettingId.OD8_GFXCLK_FMAX] * 1000;
             coreiVddc   = odCurrentSetting.Od8SettingTable[(int)ADLOD8SettingId.OD8_GFXCLK_VOLTAGE3];
             memoryClock = odCurrentSetting.Od8SettingTable[(int)ADLOD8SettingId.OD8_UCLK_FMAX] * 1000;
         }
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
     }
 }
示例#9
0
        public string GetDriverVersion()
        {
            ADLVersionsInfoX2 info = new ADLVersionsInfoX2();

            try {
                var r = AdlNativeMethods.ADL2_Graphics_VersionsX2_Get(context, ref info);
                if (r < AdlStatus.ADL_OK)
                {
                    Write.DevError($"{nameof(AdlNativeMethods.ADL2_Graphics_VersionsX2_Get)} {r}");
                }
                return(info.strCrimsonVersion);
            }
            catch {
                return("0.0");
            }
        }
示例#10
0
 private bool GetOD8CurrentSetting(int adapterIndex, out ADLOD8CurrentSetting odCurrentSetting)
 {
     odCurrentSetting = ADLOD8CurrentSetting.Create();
     try {
         var r = AdlNativeMethods.ADL2_Overdrive8_Current_Setting_Get(_context, adapterIndex, ref odCurrentSetting);
         if (r < AdlStatus.ADL_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_Overdrive8_Current_Setting_Get)} {r.ToString()}");
         }
         return(r == AdlStatus.ADL_OK);
     }
     catch (Exception ex) {
         Logger.ErrorDebugLine(ex);
         return(false);
     }
 }
示例#11
0
 public bool SetFanSpeed(int gpuIndex, int value, bool isAutoMode)
 {
     try {
         if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
         {
             return(false);
         }
         AdlStatus r;
         if (isAutoMode)
         {
             r = AdlNativeMethods.ADL2_Overdrive5_FanSpeedToDefault_Set(context, adapterIndex, 0);
             if (r != AdlStatus.ADL_OK)
             {
                 Write.DevError($"{nameof(AdlNativeMethods.ADL2_Overdrive5_FanSpeedToDefault_Set)} {r.ToString()}");
                 r = AdlNativeMethods.ADL2_Overdrive6_FanSpeed_Reset(context, adapterIndex);
                 if (r < AdlStatus.ADL_OK)
                 {
                     Write.DevError($"{nameof(AdlNativeMethods.ADL2_Overdrive6_FanSpeed_Reset)} {r.ToString()}");
                 }
             }
             return(true);
         }
         ADLFanSpeedValue info = new ADLFanSpeedValue {
             SpeedType = AdlConst.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT
         };
         r = AdlNativeMethods.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0, ref info);
         if (r < AdlStatus.ADL_OK)
         {
             Write.DevError($"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeed_Get)} {r.ToString()}");
             return(false);
         }
         info.FanSpeed = value;
         r             = AdlNativeMethods.ADL_Overdrive5_FanSpeed_Set(adapterIndex, 0, ref info);
         if (r < AdlStatus.ADL_OK)
         {
             Write.DevError($"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeed_Set)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(false);
     }
 }
示例#12
0
 private bool SetOD8Range(ADLOD8InitSetting odInitSetting, ADLOD8CurrentSetting odCurrentSetting, int adapterIndex, ADLOD8SettingId settingId, bool reset, int value)
 {
     try {
         ADLOD8SetSetting odSetSetting = ADLOD8SetSetting.Create();
         for (int i = (int)ADLOD8SettingId.OD8_GFXCLK_FREQ1; i <= (int)ADLOD8SettingId.OD8_UCLK_FMAX; i++)
         {
             odSetSetting.od8SettingTable[i].requested = 1;
             odSetSetting.od8SettingTable[i].value     = odCurrentSetting.Od8SettingTable[i];
         }
         for (int i = (int)ADLOD8SettingId.OD8_FAN_CURVE_TEMPERATURE_1; i <= (int)ADLOD8SettingId.OD8_FAN_CURVE_SPEED_5; i++)
         {
             odSetSetting.od8SettingTable[i].reset     = settingId <= ADLOD8SettingId.OD8_FAN_CURVE_SPEED_5 && settingId >= ADLOD8SettingId.OD8_FAN_CURVE_TEMPERATURE_1 ? 0 : 1;
             odSetSetting.od8SettingTable[i].requested = 1;
             odSetSetting.od8SettingTable[i].value     = odCurrentSetting.Od8SettingTable[i];
         }
         odSetSetting.od8SettingTable[(int)settingId].requested = 1;
         if (!reset)
         {
             odSetSetting.od8SettingTable[(int)settingId].value = value;
             if (ADLOD8SettingId.OD8_GFXCLK_FMAX == settingId)
             {
                 odSetSetting.od8SettingTable[(int)ADLOD8SettingId.OD8_GFXCLK_FREQ3].value = value;
             }
             else if (ADLOD8SettingId.OD8_GFXCLK_FMIN == settingId)
             {
                 odSetSetting.od8SettingTable[(int)ADLOD8SettingId.OD8_GFXCLK_FREQ1].value = value;
             }
         }
         else
         {
             odSetSetting.od8SettingTable[(int)settingId].reset = reset ? 1 : 0;
             odSetSetting.od8SettingTable[(int)settingId].value = odInitSetting.od8SettingTable[(int)settingId].defaultValue;
         }
         var r = AdlNativeMethods.ADL2_Overdrive8_Setting_Set(_context, adapterIndex, ref odSetSetting, ref odCurrentSetting);
         if (r != AdlStatus.ADL_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_Overdrive8_Setting_Set)} {r.ToString()}");
         }
         return(r == AdlStatus.ADL_OK);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(false);
     }
 }
示例#13
0
 public void GetPowerFanTemp(int gpuIndex, out uint power, out uint fanSpeed, out int temp)
 {
     power    = 0;
     fanSpeed = 0;
     temp     = 0;
     if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu))
     {
         return;
     }
     try {
         if (gpu.OverdriveVersion < 8)
         {
             temp     = GetTemperature(gpuIndex);
             power    = GetPowerUsage(gpuIndex);
             fanSpeed = GetFanSpeed(gpuIndex);
         }
         else
         {
             ADLPMLogDataOutput logDataOutput = ADLPMLogDataOutput.Create();
             var r = AdlNativeMethods.ADL2_New_QueryPMLogData_Get(_context, gpu.AdapterIndex, ref logDataOutput);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_New_QueryPMLogData_Get)} {r.ToString()}");
             }
             int i = (int)ADLSensorType.PMLOG_ASIC_POWER;
             if (i < logDataOutput.Sensors.Length && logDataOutput.Sensors[i].Supported != 0)
             {
                 power = (uint)logDataOutput.Sensors[i].Value;
             }
             i = (int)ADLSensorType.PMLOG_FAN_PERCENTAGE;
             if (i < logDataOutput.Sensors.Length && logDataOutput.Sensors[i].Supported != 0)
             {
                 fanSpeed = (uint)logDataOutput.Sensors[i].Value;
             }
             i = (int)ADLSensorType.PMLOG_TEMPERATURE_EDGE;
             if (i < logDataOutput.Sensors.Length && logDataOutput.Sensors[i].Supported != 0)
             {
                 temp = logDataOutput.Sensors[i].Value;
             }
         }
     }
     catch {
     }
 }
示例#14
0
 public Version GetDriverVersion()
 {
     try {
         ADLVersionsInfoX2 info = new ADLVersionsInfoX2();
         var r = AdlNativeMethods.ADL2_Graphics_VersionsX2_Get(_context, ref info);
         if (r < AdlStatus.ADL_OK)
         {
             NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_Graphics_VersionsX2_Get)} {r.ToString()}");
         }
         if (string.IsNullOrEmpty(info.strCrimsonVersion) || !Version.TryParse(info.strCrimsonVersion, out Version v))
         {
             return(new Version());
         }
         return(v);
     }
     catch {
         return(new Version());
     }
 }
示例#15
0
        private bool GetOD8InitSetting(int adapterIndex, out ADLOD8InitSetting odInitSetting)
        {
            odInitSetting = ADLOD8InitSetting.Create();
            try {
                var r = AdlNativeMethods.ADL2_Overdrive8_Init_Setting_Get(_context, adapterIndex, ref odInitSetting);
                if (r < AdlStatus.ADL_OK)
                {
                    NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_Overdrive8_Init_Setting_Get)} {r.ToString()}");
                }
#if DEBUG
                Logger.Debug($"od8initSettingList={VirtualRoot.JsonSerializer.Serialize(odInitSetting)}");
#endif
                return(r == AdlStatus.ADL_OK);
            }
            catch (Exception ex) {
                Logger.ErrorDebugLine(ex);
                return(false);
            }
        }
示例#16
0
 public ulong GetTotalMemory(int gpuIndex)
 {
     try {
         if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
         {
             return(0);
         }
         ADLMemoryInfo info = new ADLMemoryInfo();
         var           r    = AdlNativeMethods.ADL_Adapter_MemoryInfo_Get(adapterIndex, ref info);
         if (r < AdlStatus.ADL_OK)
         {
             Write.DevError($"{nameof(AdlNativeMethods.ADL_Adapter_MemoryInfo_Get)} {r.ToString()}");
             return(0);
         }
         return(info.MemorySize);
     }
     catch {
         return(0);
     }
 }
示例#17
0
 public int GetTemperature(int gpuIndex)
 {
     try {
         if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
         {
             return(0);
         }
         ADLTemperature info = new ADLTemperature();
         var            r    = AdlNativeMethods.ADL_Overdrive5_Temperature_Get(adapterIndex, 0, ref info);
         if (r < AdlStatus.ADL_OK)
         {
             Write.DevError($"{nameof(AdlNativeMethods.ADL_Overdrive5_Temperature_Get)} {r.ToString()}");
             return(0);
         }
         return((int)(0.001f * info.Temperature));
     }
     catch {
         return(0);
     }
 }
示例#18
0
        public int GetPowerLimit(int gpuIndex)
        {
            if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
            {
                return(0);
            }
            ADLODNPowerLimitSetting info = new ADLODNPowerLimitSetting();

            try {
                var r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get(context, adapterIndex, ref info);
                if (r < AdlStatus.ADL_OK)
                {
                    NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get)} {r.ToString()}");
                    return(0);
                }
                return(100 + info.iTDPLimit);
            }
            catch {
                return(0);
            }
        }
示例#19
0
        public uint GetPowerUsage(int gpuIndex)
        {
            if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
            {
                return(0);
            }
            int power = 0;

            try {
                var r = AdlNativeMethods.ADL2_Overdrive6_CurrentPower_Get(context, adapterIndex, 0, ref power);
                if (r < AdlStatus.ADL_OK)
                {
                    Write.DevError($"{nameof(AdlNativeMethods.ADL2_Overdrive6_CurrentPower_Get)} {r.ToString()}");
                    return(0);
                }
                return((uint)(power / 256.0));
            }
            catch {
            }
            return(0);
        }
示例#20
0
        public int GetTempLimit(int gpuIndex)
        {
            if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
            {
                return(0);
            }
            ADLODNPowerLimitSetting info = new ADLODNPowerLimitSetting();

            try {
                var r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get(context, adapterIndex, ref info);
                if (r < AdlStatus.ADL_OK)
                {
                    Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get)} {r.ToString()}");
                    return(0);
                }
                return(info.iMaxOperatingTemperature);
            }
            catch {
                return(0);
            }
        }
示例#21
0
 public bool SetTempLimit(int gpuIndex, int value)
 {
     if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu))
     {
         return(false);
     }
     try {
         bool isAutoModel = value == 0;
         if (gpu.OverdriveVersion < 8)
         {
             ADLODNPowerLimitSetting info = new ADLODNPowerLimitSetting();
             var r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get(_context, gpu.AdapterIndex, out info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get)} {r.ToString()}");
                 return(false);
             }
             info.iMode = isAutoModel ? AdlConst.ODNControlType_Auto : AdlConst.ODNControlType_Manual;
             info.iMaxOperatingTemperature = isAutoModel ? 0 : value;
             r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Set(_context, gpu.AdapterIndex, ref info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Set)} {r.ToString()}");
                 return(false);
             }
         }
         else
         {
             if (GetOD8CurrentSetting(gpu.AdapterIndex, out ADLOD8CurrentSetting odCurrentSetting))
             {
                 SetOD8Range(gpu.ADLOD8InitSetting, odCurrentSetting, gpu.AdapterIndex, ADLOD8SettingId.OD8_OPERATING_TEMP_MAX, isAutoModel, value);
             }
         }
         return(true);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(false);
     }
 }
示例#22
0
 public bool SetPowerLimit(int gpuIndex, int value)
 {
     if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu))
     {
         return(false);
     }
     try {
         if (gpu.OverdriveVersion < 8)
         {
             ADLODNPowerLimitSetting info = new ADLODNPowerLimitSetting();
             var r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get(_context, gpu.AdapterIndex, out info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get)} {r.ToString()}");
                 return(false);
             }
             info.iMode     = AdlConst.ODNControlType_Manual;
             info.iTDPLimit = value - 100;
             r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Set(_context, gpu.AdapterIndex, ref info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Set)} {r.ToString()}");
                 return(false);
             }
         }
         else
         {
             if (GetOD8CurrentSetting(gpu.AdapterIndex, out ADLOD8CurrentSetting odCurrentSetting))
             {
                 SetOD8Range(gpu.ADLOD8InitSetting, odCurrentSetting, gpu.AdapterIndex, ADLOD8SettingId.OD8_POWER_PERCENTAGE, value == 0, value - 100);
             }
         }
         return(true);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(false);
     }
 }
示例#23
0
 public uint GetFanSpeed(int gpuIndex)
 {
     try {
         if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
         {
             return(0);
         }
         ADLFanSpeedValue info = new ADLFanSpeedValue {
             SpeedType = AdlConst.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT
         };
         var r = AdlNativeMethods.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0, ref info);
         if (r < AdlStatus.ADL_OK)
         {
             Write.DevError($"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeed_Get)} {r.ToString()}");
             return(0);
         }
         return((uint)info.FanSpeed);
     }
     catch {
         return(0);
     }
 }
示例#24
0
 private uint GetPowerUsage(int gpuIndex)
 {
     if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu))
     {
         return(0);
     }
     try {
         int power = 0;
         if (gpu.OverdriveVersion >= 6)
         {
             var r = AdlNativeMethods.ADL2_Overdrive6_CurrentPower_Get(_context, gpu.AdapterIndex, ADLODNCurrentPowerType.TOTAL_POWER, out power);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_Overdrive6_CurrentPower_Get)} {r.ToString()}");
                 return(0);
             }
             return((uint)(power / 256.0));
         }
     }
     catch {
     }
     return(0);
 }
示例#25
0
        private bool Init()
        {
            try {
                if (_isHasATIGpu)
                {
                    foreach (var adapterInfo in _adapterInfoes)
                    {
                        NTMinerConsole.DevDebug(() => adapterInfo.ToString());
                        bool found = false;
                        foreach (ATIGPU gpu in _gpuNames)
                        {
                            if (gpu.BusNumber == adapterInfo.BusNumber && gpu.DeviceNumber == adapterInfo.DeviceNumber)
                            {
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            int adapterIndex     = adapterInfo.AdapterIndex;
                            int overdriveVersion = 0;
                            try {
                                if (AdlNativeMethods.ADL_Overdrive_Caps(adapterIndex, out _, out _, out overdriveVersion) != AdlStatus.ADL_OK)
                                {
                                    overdriveVersion = -1;
                                }
                            }
                            catch (Exception ex) {
                                Logger.ErrorDebugLine(ex);
                            }
                            ADLODNCapabilitiesX2 info = new ADLODNCapabilitiesX2();
                            try {
                                var r = AdlNativeMethods.ADL2_OverdriveN_CapabilitiesX2_Get(_context, adapterIndex, ref info);
                                if (r < AdlStatus.ADL_OK)
                                {
                                    NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_CapabilitiesX2_Get)} {r.ToString()}");
                                }
                            }
                            catch (Exception ex) {
                                Logger.ErrorDebugLine(ex);
                            }
                            int             maxLevels   = info.iMaximumNumberOfPerformanceLevels;
                            int             fanSpeedMin = 0;
                            int             fanSpeedMax = 0;
                            ADLFanSpeedInfo afsi        = new ADLFanSpeedInfo();
                            try {
                                var r = AdlNativeMethods.ADL_Overdrive5_FanSpeedInfo_Get(adapterIndex, 0, ref afsi);
                                if (r < AdlStatus.ADL_OK)
                                {
                                    NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeedInfo_Get)} {r.ToString()}");
                                }
                                else
                                {
                                    fanSpeedMax = afsi.MaxPercent;
                                    fanSpeedMin = afsi.MinPercent;
                                }
                            }
                            catch (Exception ex) {
                                Logger.ErrorDebugLine(ex);
                            }
                            ADLODNPerformanceLevelsX2 systemClockX2 = ADLODNPerformanceLevelsX2.Create();
                            systemClockX2.iNumberOfPerformanceLevels = maxLevels;
                            try {
                                var r = AdlNativeMethods.ADL2_OverdriveN_SystemClocksX2_Get(_context, adapterIndex, ref systemClockX2);
                                if (r < AdlStatus.ADL_OK)
                                {
                                    NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_SystemClocksX2_Get)} {r.ToString()}");
                                }
                            }
                            catch (Exception ex) {
                                Logger.ErrorDebugLine(ex);
                            }
                            int gpuLevel    = 0;
                            int memoryLevel = 0;
                            for (int j = 0; j < systemClockX2.aLevels.Length; j++)
                            {
                                if (systemClockX2.aLevels[j].iEnabled != 0)
                                {
                                    gpuLevel = j + 1;
                                }
                            }
                            ADLODNPerformanceLevelsX2 memoryClockX2 = ADLODNPerformanceLevelsX2.Create();
                            memoryClockX2.iNumberOfPerformanceLevels = maxLevels;
                            try {
                                var r = AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get(_context, adapterIndex, ref memoryClockX2);
                                if (r < AdlStatus.ADL_OK)
                                {
                                    NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get)} {r.ToString()}");
                                }
                            }
                            catch (Exception ex) {
                                Logger.ErrorDebugLine(ex);
                            }
                            for (int j = 0; j < memoryClockX2.aLevels.Length; j++)
                            {
                                if (memoryClockX2.aLevels[j].iEnabled != 0)
                                {
                                    memoryLevel = j + 1;
                                }
                            }
                            int  powerMin                   = info.power.iMin + 100;
                            int  powerMax                   = info.power.iMax + 100;
                            int  powerDefault               = info.power.iDefault + 100;
                            int  voltMin                    = info.svddcRange.iMin;     // 0
                            int  voltMax                    = info.svddcRange.iMax;     // 0
                            int  voltDefault                = info.svddcRange.iDefault; // 0
                            int  tempLimitMin               = info.powerTuneTemperature.iMin;
                            int  tempLimitMax               = info.powerTuneTemperature.iMax;
                            int  tempLimitDefault           = info.powerTuneTemperature.iDefault;
                            int  coreClockMin               = info.sEngineClockRange.iMin * 10;
                            int  coreClockMax               = info.sEngineClockRange.iMax * 10;
                            int  memoryClockMin             = info.sMemoryClockRange.iMin * 10;
                            int  memoryClockMax             = info.sMemoryClockRange.iMax * 10;
                            bool apiSupported               = gpuLevel > 0 && memoryLevel > 0;
                            ADLOD8InitSetting odInitSetting = ADLOD8InitSetting.Create();
                            if (!apiSupported)
                            {
                                try {
                                    if (overdriveVersion == 8)
                                    {
                                        if (GetOD8InitSetting(adapterIndex, out odInitSetting))
                                        {
                                            apiSupported = true;
                                            gpuLevel     = 3;
                                            memoryLevel  = 0;
                                            maxLevels    = 3;

                                            powerMin         = 0;
                                            powerMax         = 0;
                                            powerDefault     = 0;
                                            voltMin          = 0;
                                            voltMax          = 0;
                                            voltDefault      = 0;
                                            tempLimitMin     = 0;
                                            tempLimitMax     = 0;
                                            tempLimitDefault = 0;
                                            coreClockMin     = 0;
                                            coreClockMax     = 0;
                                            memoryClockMin   = 0;
                                            memoryClockMax   = 0;
                                            if ((odInitSetting.overdrive8Capabilities & (int)ADLOD8FeatureControl.ADL_OD8_GFXCLK_LIMITS) == (int)ADLOD8FeatureControl.ADL_OD8_GFXCLK_LIMITS ||
                                                (odInitSetting.overdrive8Capabilities & (int)ADLOD8FeatureControl.ADL_OD8_GFXCLK_CURVE) == (int)ADLOD8FeatureControl.ADL_OD8_GFXCLK_CURVE)
                                            {
                                                coreClockMin   = odInitSetting.od8SettingTable[(int)ADLOD8SettingId.OD8_GFXCLK_FMAX].minValue * 1000;
                                                coreClockMax   = odInitSetting.od8SettingTable[(int)ADLOD8SettingId.OD8_GFXCLK_FMAX].maxValue * 1000;
                                                voltMin        = odInitSetting.od8SettingTable[(int)ADLOD8SettingId.OD8_GFXCLK_VOLTAGE3].minValue;
                                                voltMax        = odInitSetting.od8SettingTable[(int)ADLOD8SettingId.OD8_GFXCLK_VOLTAGE3].maxValue;
                                                powerMin       = 100 + odInitSetting.od8SettingTable[(int)ADLOD8SettingId.OD8_POWER_PERCENTAGE].minValue;
                                                powerMax       = 100 + odInitSetting.od8SettingTable[(int)ADLOD8SettingId.OD8_POWER_PERCENTAGE].maxValue;
                                                memoryClockMin = odInitSetting.od8SettingTable[(int)ADLOD8SettingId.OD8_UCLK_FMAX].minValue * 1000;
                                                memoryClockMax = odInitSetting.od8SettingTable[(int)ADLOD8SettingId.OD8_UCLK_FMAX].maxValue * 1000;
                                            }
#if DEBUG
                                            Logger.Debug(odInitSetting.ToString());
#endif
                                        }
                                    }
                                }
                                catch (Exception ex) {
                                    Logger.ErrorDebugLine(ex);
                                }
                            }
                            if (fanSpeedMax <= 0)
                            {
                                fanSpeedMax = 100;
                            }
                            if (powerMax <= 0)
                            {
                                powerMax = 100;
                            }
                            _gpuNames.Add(new ATIGPU {
                                AdapterName       = adapterInfo.AdapterName.Trim(),
                                AdapterIndex      = adapterIndex,
                                BusNumber         = adapterInfo.BusNumber,
                                DeviceNumber      = adapterInfo.DeviceNumber,
                                OverdriveVersion  = overdriveVersion,
                                MaxLevels         = maxLevels,
                                ApiSupported      = apiSupported,
                                GpuLevels         = gpuLevel,
                                MemoryLevels      = memoryLevel,
                                CoreClockMin      = coreClockMin,
                                CoreClockMax      = coreClockMax,
                                MemoryClockMin    = memoryClockMin,
                                MemoryClockMax    = memoryClockMax,
                                PowerMin          = powerMin,
                                PowerMax          = powerMax,
                                PowerDefault      = powerDefault,
                                TempLimitMin      = tempLimitMin,
                                TempLimitMax      = tempLimitMax,
                                TempLimitDefault  = tempLimitDefault,
                                VoltMin           = voltMin,
                                VoltMax           = voltMax,
                                VoltDefault       = voltDefault,
                                FanSpeedMax       = fanSpeedMax,
                                FanSpeedMin       = fanSpeedMin,
                                ADLOD8InitSetting = odInitSetting
                            });
                        }
                    }
                }
                _gpuNames = _gpuNames.OrderBy(a => a.BusNumber).ToList();
                NTMinerConsole.DevDebug(() => string.Join(",", _gpuNames.Select(a => a.AdapterIndex)));
            }
            catch (Exception ex) {
                Logger.ErrorDebugLine(ex);
                return(false);
            }

            return(true);
        }
示例#26
0
 public bool SetMemoryClock(int gpuIndex, int value, int voltage)
 {
     if (value < 0)
     {
         value = 0;
     }
     if (voltage < 0)
     {
         voltage = 0;
     }
     try {
         if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu))
         {
             return(false);
         }
         bool isReset = value == 0 && voltage == 0;
         if (gpu.OverdriveVersion < 8)
         {
             ADLODNPerformanceLevelsX2 info = ADLODNPerformanceLevelsX2.Create();
             var r = AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get(_context, gpu.AdapterIndex, ref info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get)} {r.ToString()}");
                 return(false);
             }
             info.iMode = AdlConst.ODNControlType_Default;
             r          = AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Set(_context, gpu.AdapterIndex, ref info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Set)} {r.ToString()}");
                 return(false);
             }
             if (isReset)
             {
                 return(true);
             }
             r = AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get(_context, gpu.AdapterIndex, ref info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get)} {r.ToString()}");
                 return(false);
             }
             info.iMode = AdlConst.ODNControlType_Manual;
             int index = 0;
             for (int i = 0; i < info.aLevels.Length; i++)
             {
                 if (info.aLevels[i].iEnabled != 0)
                 {
                     index = i;
                 }
             }
             NTMinerConsole.DevDebug(() => $"{nameof(SetMemoryClock)} PState {index.ToString()} value={value.ToString()} voltage={voltage.ToString()}");
             if (value != 0)
             {
                 info.aLevels[index].iClock = value * 100;
             }
             if (voltage != 0)
             {
                 info.aLevels[index].iVddc = voltage;
             }
             r = AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Set(_context, gpu.AdapterIndex, ref info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Set)} {r.ToString()}");
                 return(false);
             }
         }
         else
         {
             if (GetOD8CurrentSetting(gpu.AdapterIndex, out ADLOD8CurrentSetting odCurrentSetting))
             {
                 SetOD8Range(gpu.ADLOD8InitSetting, odCurrentSetting, gpu.AdapterIndex, ADLOD8SettingId.OD8_UCLK_FMAX, isReset, value * 100);
             }
         }
         return(true);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(false);
     }
 }
示例#27
0
 public bool SetFanSpeed(int gpuIndex, int value, bool isAutoMode)
 {
     try {
         if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu))
         {
             return(false);
         }
         if (gpu.OverdriveVersion < 8)
         {
             AdlStatus r;
             if (isAutoMode)
             {
                 try {
                     r = AdlNativeMethods.ADL2_Overdrive5_FanSpeedToDefault_Set(_context, gpu.AdapterIndex, 0);
                     if (r != AdlStatus.ADL_OK)
                     {
                         NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_Overdrive5_FanSpeedToDefault_Set)} {r.ToString()}");
                     }
                 }
                 catch (Exception e) {
                     r = AdlStatus.ADL_ERR;
                     Logger.ErrorDebugLine(e);
                 }
                 if (r != AdlStatus.ADL_OK)
                 {
                     try {
                         r = AdlNativeMethods.ADL_Overdrive5_FanSpeedToDefault_Set(gpu.AdapterIndex, 0);
                         if (r != AdlStatus.ADL_OK)
                         {
                             NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeedToDefault_Set)} {r.ToString()}");
                         }
                     }
                     catch (Exception e) {
                         Logger.ErrorDebugLine(e);
                     }
                 }
                 if (r != AdlStatus.ADL_OK)
                 {
                     try {
                         r = AdlNativeMethods.ADL2_Overdrive6_FanSpeed_Reset(_context, gpu.AdapterIndex);
                         if (r != AdlStatus.ADL_OK)
                         {
                             NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_Overdrive6_FanSpeed_Reset)} {r.ToString()}");
                         }
                     }
                     catch (Exception e) {
                         Logger.ErrorDebugLine(e);
                     }
                 }
                 return(true);
             }
             ADLFanSpeedValue info = new ADLFanSpeedValue {
                 SpeedType = AdlConst.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT,
                 Flags     = AdlConst.ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED
             };
             r = AdlNativeMethods.ADL_Overdrive5_FanSpeed_Get(gpu.AdapterIndex, 0, ref info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeed_Get)} {r.ToString()}");
                 return(false);
             }
             info.FanSpeed = value;
             r             = AdlNativeMethods.ADL_Overdrive5_FanSpeed_Set(gpu.AdapterIndex, 0, ref info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeed_Set)} {r.ToString()}");
                 return(false);
             }
         }
         else
         {
             if (GetOD8CurrentSetting(gpu.AdapterIndex, out ADLOD8CurrentSetting odCurrentSetting))
             {
                 SetOD8Range(gpu.ADLOD8InitSetting, odCurrentSetting, gpu.AdapterIndex, ADLOD8SettingId.OD8_FAN_MIN_SPEED, isAutoMode, value);
                 SetOD8Range(gpu.ADLOD8InitSetting, odCurrentSetting, gpu.AdapterIndex, ADLOD8SettingId.OD8_FAN_ACOUSTIC_LIMIT, isAutoMode, value);
             }
         }
         return(true);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(false);
     }
 }
示例#28
0
        public bool Init()
        {
            try {
                var r = AdlNativeMethods.ADL_Main_Control_Create(1);
                if (r < AdlStatus.ADL_OK)
                {
                    Write.DevError($"ADL_Main_Control_Create {r.ToString()}");
                }
                if (r >= AdlStatus.ADL_OK)
                {
                    int numberOfAdapters = 0;
                    r = AdlNativeMethods.ADL_Adapter_NumberOfAdapters_Get(ref numberOfAdapters);
                    if (r < AdlStatus.ADL_OK)
                    {
                        Write.DevError($"{nameof(AdlNativeMethods.ADL_Adapter_NumberOfAdapters_Get)} {r.ToString()}");
                    }
                    if (numberOfAdapters > 0)
                    {
                        ADLAdapterInfo[] adapterInfo = new ADLAdapterInfo[numberOfAdapters];
                        if (AdlNativeMethods.ADL_Adapter_AdapterInfo_Get(adapterInfo) >= AdlStatus.ADL_OK)
                        {
                            for (int i = 0; i < numberOfAdapters; i++)
                            {
#if DEBUG
                                Write.DevDebug(adapterInfo[i].ToString());
#endif
                                if (!string.IsNullOrEmpty(adapterInfo[i].UDID) && adapterInfo[i].VendorID == AdlConst.ATI_VENDOR_ID)
                                {
                                    bool found = false;
                                    foreach (ATIGPU gpu in _gpuNames)
                                    {
                                        if (gpu.BusNumber == adapterInfo[i].BusNumber && gpu.DeviceNumber == adapterInfo[i].DeviceNumber)
                                        {
                                            found = true;
                                            break;
                                        }
                                    }
                                    if (!found)
                                    {
                                        _gpuNames.Add(new ATIGPU {
                                            AdapterName  = adapterInfo[i].AdapterName.Trim(),
                                            AdapterIndex = adapterInfo[i].AdapterIndex,
                                            BusNumber    = adapterInfo[i].BusNumber,
                                            DeviceNumber = adapterInfo[i].DeviceNumber
                                        });
                                    }
                                }
                            }
                        }
                    }
                    r = AdlNativeMethods.ADL2_Main_Control_Create(AdlNativeMethods.Main_Memory_Alloc, 1, ref context);
                    if (r < AdlStatus.ADL_OK)
                    {
                        Write.DevError($"{nameof(AdlNativeMethods.ADL2_Main_Control_Create)} {r.ToString()}");
                    }
                }
                _gpuNames = _gpuNames.OrderBy(a => a.BusNumber).ToList();
#if DEBUG
                Write.DevDebug(string.Join(",", _gpuNames.Select(a => a.AdapterIndex)));
#endif
            }
            catch {
                return(false);
            }

            return(true);
        }
示例#29
0
 public bool SetMemoryClock(int gpuIndex, int value, int voltage)
 {
     if (value < 0)
     {
         value = 0;
     }
     if (voltage < 0)
     {
         voltage = 0;
     }
     try {
         if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex))
         {
             return(false);
         }
         ADLODNPerformanceLevelsX2 info = ADLODNPerformanceLevelsX2.Create();
         var r = AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get(context, adapterIndex, ref info);
         if (r < AdlStatus.ADL_OK)
         {
             Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get)} {r.ToString()}");
             return(false);
         }
         info.iMode = AdlConst.ODNControlType_Default;
         r          = AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Set(context, adapterIndex, ref info);
         if (r < AdlStatus.ADL_OK)
         {
             Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Set)} {r.ToString()}");
             return(false);
         }
         bool isReset = value == 0 && voltage == 0;
         if (isReset)
         {
             return(true);
         }
         r = AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get(context, adapterIndex, ref info);
         if (r < AdlStatus.ADL_OK)
         {
             Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get)} {r.ToString()}");
             return(false);
         }
         info.iMode = AdlConst.ODNControlType_Manual;
         int index = 0;
         for (int i = 0; i < info.aLevels.Length; i++)
         {
             if (info.aLevels[i].iEnabled != 0)
             {
                 index = i;
             }
         }
         Write.DevDebug($"SetMemoryClock PState {index.ToString()} value={value.ToString()} voltage={voltage.ToString()}");
         if (value != 0)
         {
             info.aLevels[index].iClock = value * 100;
         }
         if (voltage != 0)
         {
             info.aLevels[index].iVddc = voltage;
         }
         r = AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Set(context, adapterIndex, ref info);
         if (r < AdlStatus.ADL_OK)
         {
             Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Set)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(false);
     }
 }