From 9b5cd618868a10ef40c0da176a1293a6b38878b5 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 8 Sep 2011 13:04:39 +1000 Subject: [PATCH] Implement accepting a range of engine speeds as well to allow a lower limit to be specified on the command line. --- README | 15 +++++++++++---- adl.c | 11 +++++------ main.c | 36 ++++++++++++++++++++++++++---------- miner.h | 2 ++ 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/README b/README index ae4bfeae..fe801a8f 100644 --- a/README +++ b/README @@ -116,7 +116,7 @@ Options for both config file and command line: --enable-cpu|-C Enable CPU mining with GPU mining (default: no CPU mining if suitable GPUs exist) --failover-only Don't leak work to backup pools when primary pool is lagging --gpu-threads|-g Number of threads per GPU (1 - 10) (default: 2) ---gpu-engine Set the GPU engine (over)clock in Mhz - one value for all or separate by commas for per card. +--gpu-engine GPU engine (over)clock range in Mhz - one value, range and/or comma separated list (e.g. 850-900,900,750-850) --gpu-fan Set the GPU fan percentage - one value for all or separate by commas for per card. --gpu-memclock Set the GPU memory (over)clock in Mhz - one value for all or separate by commas for per card. --gpu-powertune Set the GPU powertune percentage - one value for all or separate by commas for per card. @@ -180,11 +180,11 @@ cgminer -o http://pool1:port -u pool1username -p pool1password -o http://pool2:p Add overclocking settings, GPU and fan control for all cards: -cgminer -o http://pool:port -u username -p password -I 9 --auto-fan --auto-gpu --gpu-engine 950 --gpu-memclock 300 +cgminer -o http://pool:port -u username -p password -I 9 --auto-fan --auto-gpu --gpu-engine 750-950 --gpu-memclock 300 Add overclocking settings, GPU and fan control with different engine settings for 4 cards: -cgminer -o http://pool:port -u username -p password -I 9 --auto-fan --auto-gpu --gpu-engine 950,945,930,960 --gpu-memclock 300 +cgminer -o http://pool:port -u username -p password -I 9 --auto-fan --auto-gpu --gpu-engine 750-950,945,700-930,960 --gpu-memclock 300 READ WARNINGS AND DOCUMENTATION BELOW ABOUT OVERCLOCKING @@ -358,6 +358,9 @@ temperature. By default this is set to 75 degrees C but can be changed with: --temp-target AUTO FAN: +i.e. +--auto-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 noise, and prolong the life of the fan. In auto-fan mode, the fan speed is @@ -369,10 +372,14 @@ is set to 85 degrees by default and can be changed with: --temp-overheat AUTO GPU: +e.g. +--auto-gpu --gpu-engine 750-950 +--auto-gpu --gpu-engine 750-950,945,700-930,960 + GPU control in auto gpu tries to maintain as high a clock speed as possible while not reaching overheat temperatures. As a lower clock speed limit, the auto-gpu mode checks the GPU card's "normal" clock speed and will not go -below this unless you have manually set a lower speed at some time. Also, +below this unless you have manually set a lower speed in the range. Also, unless a higher clock speed was specified at startup, it will not raise the clockspeed. If the temperature climbs, fanspeed is adjusted and optimised before GPU engine clockspeed is adjusted. If fan speed control is not available diff --git a/adl.c b/adl.c index 13ffb5a8..51be7df6 100644 --- a/adl.c +++ b/adl.c @@ -261,6 +261,9 @@ void init_adl(int nDevs) lpOdPerformanceLevels->aLevels[lev].iEngineClock = setengine; applog(LOG_INFO, "Setting GPU %d engine clock to %d", gpu, gpus[gpu].gpu_engine); ADL_Overdrive5_ODPerformanceLevels_Set(iAdapterIndex, lpOdPerformanceLevels); + ga->maxspeed = setengine; + if (gpus[gpu].min_engine) + ga->minspeed = gpus[gpu].min_engine * 100; } if (gpus[gpu].gpu_memclock) { int setmem = gpus[gpu].gpu_memclock * 100; @@ -289,11 +292,6 @@ void init_adl(int nDevs) ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock; ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc; - if (ga->iEngineClock < ga->minspeed) - ga->minspeed = ga->iEngineClock; - if (ga->iEngineClock > ga->maxspeed) - ga->maxspeed = ga->iEngineClock; - if (ADL_Overdrive5_FanSpeedInfo_Get(iAdapterIndex, 0, &ga->lpFanSpeedInfo) != ADL_OK) { applog(LOG_INFO, "Failed to ADL_Overdrive5_FanSpeedInfo_Get"); continue; @@ -1012,7 +1010,8 @@ updated: "Memory Clock: %d Mhz\nVddc: %.3f V\nActivity: %d%%\nPowertune: %d%%\n", temp, fanpercent, fanspeed, engineclock, memclock, vddc, activity, powertune); wlogprint("Fan autotune is %s\n", ga->autofan ? "enabled" : "disabled"); - wlogprint("GPU engine clock autotune is %s\n", ga->autoengine ? "enabled" : "disabled"); + wlogprint("GPU engine clock autotune is %s (%d-%d)\n", ga->autoengine ? "enabled" : "disabled", + ga->minspeed / 100, ga->maxspeed / 100); wlogprint("Change [A]utomatic [E]ngine [F]an [M]emory [V]oltage [P]owertune\n"); wlogprint("Or press any other key to continue\n"); input = getch(); diff --git a/main.c b/main.c index 2fa302c3..ddccb3cf 100644 --- a/main.c +++ b/main.c @@ -1117,29 +1117,45 @@ static char *set_schedtime(const char *arg, struct schedtime *st) } #ifdef HAVE_ADL +static void get_intrange(char *arg, int *val1, int *val2) +{ + if (sscanf(arg, "%d-%d", val1, val2) == 1) { + *val2 = *val1; + *val1 = 0; + } +} + static char *set_gpu_engine(char *arg) { - int i, val = 0, device = 0; + int i, val1 = 0, val2 = 0, device = 0; char *nextptr; nextptr = strtok(arg, ","); if (nextptr == NULL) return "Invalid parameters for set gpu engine"; - val = atoi(nextptr); - if (val <= 0 || val >= 9999) + get_intrange(nextptr, &val1, &val2); + if (val1 < 0 || val1 > 9999 || val2 <= 0 || val2 > 9999) return "Invalid value passed to set_gpu_engine"; - gpus[device++].gpu_engine = val; + gpus[device].min_engine = val1; + gpus[device].gpu_engine = val2; + device++; while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atoi(nextptr); - if (val <= 0 || val >= 9999) + get_intrange(nextptr, &val1, &val2); + if (val1 < 0 || val1 > 9999 || val2 <= 0 || val2 > 9999) return "Invalid value passed to set_gpu_engine"; + gpus[device].min_engine = val1; + gpus[device].gpu_engine = val2; + device++; + } - gpus[device++].gpu_engine = val; + if (device == 1) { + for (i = 1; i < 16; i++) { + gpus[i].min_engine = gpus[0].min_engine; + gpus[i].gpu_engine = gpus[0].gpu_engine; + } } - for (i = device; i < 16; i++) - gpus[i].gpu_engine = val; return NULL; } @@ -1318,7 +1334,7 @@ static struct opt_table opt_config_table[] = { #ifdef HAVE_ADL OPT_WITH_ARG("--gpu-engine", set_gpu_engine, NULL, NULL, - "Set the GPU engine (over)clock in Mhz - one value for all or separate by commas for per card."), + "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", set_gpu_fan, NULL, NULL, "Set the GPU fan percentage - one value for all or separate by commas for per card."), diff --git a/miner.h b/miner.h index 5d9e22f5..97d0d4e9 100644 --- a/miner.h +++ b/miner.h @@ -205,7 +205,9 @@ struct cgpu_info { bool has_adl; struct gpu_adl adl; int gpu_engine; + int min_engine; int gpu_fan; + int min_fan; int gpu_memclock; int gpu_powertune; float gpu_vddc;