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); } }
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); } }
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); } }
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); } }