Browse Source

Allow per-device fan ranges to be set and use them in auto-fan mode.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
b50041c880
  1. 7
      README
  2. 29
      adl.c
  3. 29
      main.c

7
README

@ -117,7 +117,7 @@ Options for both config file and command line:
--failover-only Don't leak work to backup pools when primary pool is lagging --failover-only Don't leak work to backup pools when primary pool is lagging
--gpu-threads|-g <arg> Number of threads per GPU (1 - 10) (default: 2) --gpu-threads|-g <arg> Number of threads per GPU (1 - 10) (default: 2)
--gpu-engine <arg> GPU engine (over)clock range in Mhz - one value, range and/or comma separated list (e.g. 850-900,900,750-850) --gpu-engine <arg> GPU engine (over)clock range in Mhz - one value, range and/or comma separated list (e.g. 850-900,900,750-850)
--gpu-fan <arg> Set the GPU fan percentage - one value for all or separate by commas for per card. --gpu-fan <arg> GPU fan percentage range - one value, range and/or comma separated list (e.g. 25-85,85,65)
--gpu-memclock <arg> Set the GPU memory (over)clock in Mhz - one value for all or separate by commas for per card. --gpu-memclock <arg> Set the GPU memory (over)clock in Mhz - one value for all or separate by commas for per card.
--gpu-powertune <arg> Set the GPU powertune percentage - one value for all or separate by commas for per card. --gpu-powertune <arg> Set the GPU powertune percentage - one value for all or separate by commas for per card.
--gpu-vddc <arg> Set the GPU voltage in Volts - one value for all or separate by commas for per card. --gpu-vddc <arg> Set the GPU voltage in Volts - one value for all or separate by commas for per card.
@ -358,8 +358,9 @@ temperature. By default this is set to 75 degrees C but can be changed with:
--temp-target --temp-target
AUTO FAN: AUTO FAN:
i.e. e.g.
--auto-fan --auto-fan (implies 85% upper limit)
--gpu-fan 25-85,65 --auto-fan
Fan control in auto fan works off the theory that the minimum possible fan Fan control in auto fan works off the theory that the minimum possible fan
required to maintain an optimal temperature will use less power, make less required to maintain an optimal temperature will use less power, make less

29
adl.c

@ -264,6 +264,7 @@ void init_adl(int nDevs)
ga->maxspeed = setengine; ga->maxspeed = setengine;
if (gpus[gpu].min_engine) if (gpus[gpu].min_engine)
ga->minspeed = gpus[gpu].min_engine * 100; ga->minspeed = gpus[gpu].min_engine * 100;
ga->managed = true;
} }
if (gpus[gpu].gpu_memclock) { if (gpus[gpu].gpu_memclock) {
int setmem = gpus[gpu].gpu_memclock * 100; int setmem = gpus[gpu].gpu_memclock * 100;
@ -275,6 +276,7 @@ void init_adl(int nDevs)
lpOdPerformanceLevels->aLevels[lev].iMemoryClock = setmem; lpOdPerformanceLevels->aLevels[lev].iMemoryClock = setmem;
applog(LOG_INFO, "Setting GPU %d memory clock to %d", gpu, gpus[gpu].gpu_memclock); applog(LOG_INFO, "Setting GPU %d memory clock to %d", gpu, gpus[gpu].gpu_memclock);
ADL_Overdrive5_ODPerformanceLevels_Set(iAdapterIndex, lpOdPerformanceLevels); ADL_Overdrive5_ODPerformanceLevels_Set(iAdapterIndex, lpOdPerformanceLevels);
ga->managed = true;
} }
if (gpus[gpu].gpu_vddc) { if (gpus[gpu].gpu_vddc) {
int setv = gpus[gpu].gpu_vddc * 1000; int setv = gpus[gpu].gpu_vddc * 1000;
@ -286,16 +288,15 @@ void init_adl(int nDevs)
lpOdPerformanceLevels->aLevels[lev].iVddc = setv; lpOdPerformanceLevels->aLevels[lev].iVddc = setv;
applog(LOG_INFO, "Setting GPU %d voltage to %.3f", gpu, gpus[gpu].gpu_vddc); applog(LOG_INFO, "Setting GPU %d voltage to %.3f", gpu, gpus[gpu].gpu_vddc);
ADL_Overdrive5_ODPerformanceLevels_Set(iAdapterIndex, lpOdPerformanceLevels); ADL_Overdrive5_ODPerformanceLevels_Set(iAdapterIndex, lpOdPerformanceLevels);
ga->managed = true;
} }
ADL_Overdrive5_ODPerformanceLevels_Get(iAdapterIndex, 0, lpOdPerformanceLevels); ADL_Overdrive5_ODPerformanceLevels_Get(iAdapterIndex, 0, lpOdPerformanceLevels);
ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock; ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock;
ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock; ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock;
ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc; ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc;
if (ADL_Overdrive5_FanSpeedInfo_Get(iAdapterIndex, 0, &ga->lpFanSpeedInfo) != ADL_OK) { if (ADL_Overdrive5_FanSpeedInfo_Get(iAdapterIndex, 0, &ga->lpFanSpeedInfo) != ADL_OK)
applog(LOG_INFO, "Failed to ADL_Overdrive5_FanSpeedInfo_Get"); applog(LOG_INFO, "Failed to ADL_Overdrive5_FanSpeedInfo_Get");
continue;
}
/* Save the fanspeed values as defaults in case we reset later */ /* Save the fanspeed values as defaults in case we reset later */
ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->DefFanSpeedValue); ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->DefFanSpeedValue);
@ -306,7 +307,9 @@ void init_adl(int nDevs)
ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT; ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
applog(LOG_INFO, "Setting GPU %d fan speed to %d%%", gpu, gpus[gpu].gpu_fan); applog(LOG_INFO, "Setting GPU %d fan speed to %d%%", gpu, gpus[gpu].gpu_fan);
ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue); ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue);
} ga->managed = true;
} else
gpus[gpu].gpu_fan = 85; /* Set a nominal upper limit of 85% */
/* Not fatal if powercontrol get fails */ /* Not fatal if powercontrol get fails */
if (ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy) != ADL_OK) if (ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy) != ADL_OK)
@ -315,13 +318,8 @@ void init_adl(int nDevs)
if (gpus[gpu].gpu_powertune) { if (gpus[gpu].gpu_powertune) {
ADL_Overdrive5_PowerControl_Set(ga->iAdapterIndex, gpus[gpu].gpu_powertune); ADL_Overdrive5_PowerControl_Set(ga->iAdapterIndex, gpus[gpu].gpu_powertune);
ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy); ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy);
}
/* Flag if the values of this GPU were ever modified to tell us
* we need to reset the values upon exiting */
if (gpus[gpu].gpu_engine || gpus[gpu].gpu_memclock || gpus[gpu].gpu_vddc ||
gpus[gpu].gpu_fan || gpus[gpu].gpu_powertune)
ga->managed = true; ga->managed = true;
}
/* Set some default temperatures for autotune when enabled */ /* Set some default temperatures for autotune when enabled */
ga->targettemp = opt_targettemp; ga->targettemp = opt_targettemp;
@ -856,19 +854,22 @@ void gpu_autotune(int gpu, bool *enable)
newengine = engine = gpu_engineclock(gpu) * 100; newengine = engine = gpu_engineclock(gpu) * 100;
if (temp && fanpercent >= 0 && ga->autofan) { if (temp && fanpercent >= 0 && ga->autofan) {
int top = gpus[gpu].gpu_fan;
int bot = gpus[gpu].min_fan;
if (temp > ga->overtemp && fanpercent < 100) { if (temp > ga->overtemp && fanpercent < 100) {
applog(LOG_WARNING, "Overheat detected, increasing fan to 100%"); applog(LOG_WARNING, "Overheat detected, increasing fan to 100%");
newpercent = 100; newpercent = 100;
} else if (temp > ga->targettemp && fanpercent < 85) { } else if (temp > ga->targettemp && fanpercent < top) {
if (opt_debug) if (opt_debug)
applog(LOG_DEBUG, "Temperature over target, increasing fanspeed"); applog(LOG_DEBUG, "Temperature over target, increasing fanspeed");
if (temp > ga->targettemp + opt_hysteresis) if (temp > ga->targettemp + opt_hysteresis)
newpercent = fanpercent + 10; newpercent = fanpercent + 10;
else else
newpercent = fanpercent + 5; newpercent = fanpercent + 5;
if (newpercent > 85) if (newpercent > top)
newpercent = 85; newpercent = top;
} else if (fanpercent && temp < ga->targettemp - opt_hysteresis) { } else if (fanpercent > bot && temp < ga->targettemp - opt_hysteresis) {
if (opt_debug) if (opt_debug)
applog(LOG_DEBUG, "Temperature %d degrees below target, decreasing fanspeed", opt_hysteresis); applog(LOG_DEBUG, "Temperature %d degrees below target, decreasing fanspeed", opt_hysteresis);
newpercent = fanpercent - 1; newpercent = fanpercent - 1;

29
main.c

@ -1162,27 +1162,36 @@ static char *set_gpu_engine(char *arg)
static char *set_gpu_fan(char *arg) static char *set_gpu_fan(char *arg)
{ {
int i, val = 0, device = 0; int i, val1 = 0, val2 = 0, device = 0;
char *nextptr; char *nextptr;
nextptr = strtok(arg, ","); nextptr = strtok(arg, ",");
if (nextptr == NULL) if (nextptr == NULL)
return "Invalid parameters for set gpu fan"; return "Invalid parameters for set gpu fan";
val = atoi(nextptr); get_intrange(nextptr, &val1, &val2);
if (val < 0 || val > 100) if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100)
return "Invalid value passed to set_gpu_fan"; return "Invalid value passed to set_gpu_fan";
gpus[device++].gpu_fan = val; gpus[device].min_fan = val1;
gpus[device].gpu_fan = val2;
device++;
while ((nextptr = strtok(NULL, ",")) != NULL) { while ((nextptr = strtok(NULL, ",")) != NULL) {
val = atoi(nextptr); get_intrange(nextptr, &val1, &val2);
if (val < 0 || val > 100) if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100)
return "Invalid value passed to set_gpu_fan"; return "Invalid value passed to set_gpu_fan";
gpus[device++].gpu_fan = val; gpus[device].min_fan = val1;
gpus[device].gpu_fan = val2;
device++;
}
if (device == 1) {
for (i = 1; i < 16; i++) {
gpus[i].min_fan = gpus[0].min_fan;
gpus[i].gpu_fan = gpus[0].gpu_fan;
}
} }
for (i = device; i < 16; i++)
gpus[i].gpu_fan = val;
return NULL; return NULL;
} }
@ -1337,7 +1346,7 @@ static struct opt_table opt_config_table[] = {
"GPU engine (over)clock range in Mhz - one value, range and/or comma separated list (e.g. 850-900,900,750-850)"), "GPU engine (over)clock range in Mhz - one value, range and/or comma separated list (e.g. 850-900,900,750-850)"),
OPT_WITH_ARG("--gpu-fan", OPT_WITH_ARG("--gpu-fan",
set_gpu_fan, NULL, NULL, set_gpu_fan, NULL, NULL,
"Set the GPU fan percentage - one value for all or separate by commas for per card."), "GPU fan percentage range - one value, range and/or comma separated list (e.g. 0-85,85,65)"),
OPT_WITH_ARG("--gpu-memclock", OPT_WITH_ARG("--gpu-memclock",
set_gpu_memclock, NULL, NULL, set_gpu_memclock, NULL, NULL,
"Set the GPU memory (over)clock in Mhz - one value for all or separate by commas for per card."), "Set the GPU memory (over)clock in Mhz - one value for all or separate by commas for per card."),

Loading…
Cancel
Save