Esempio n. 1
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);
            }
        }
Esempio n. 2
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);
            }
        }
Esempio n. 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];
         }
     }
 }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
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);
     }
 }
Esempio n. 7
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);
     }
 }