Commit e9f886d80522c6125ea9e9cd43d5ae980f434032

Con Kolivas 2011-09-04T09:43:53

Allow target, overheat and hysteresis temperatures to be set from command line.

diff --git a/adl.c b/adl.c
index f0737a5..ab47901 100644
--- a/adl.c
+++ b/adl.c
@@ -20,6 +20,10 @@ bool adl_active;
 
 #include "adl_functions.h"
 
+int opt_hysteresis = 5;
+int opt_targettemp = 75;
+int opt_overheattemp = 85;
+
 // Memory allocation function
 static void * __stdcall ADL_Main_Memory_Alloc(int iSize)
 {
@@ -232,8 +236,8 @@ void init_adl(int nDevs)
 		ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->DefFanSpeedValue);
 
 		/* Set some default temperatures for autotune when enabled */
-		ga->targettemp = 75;
-		ga->overtemp = 85;
+		ga->targettemp = opt_targettemp;
+		ga->overtemp = opt_overheattemp;
 		if (opt_autofan)
 			ga->autofan = true;
 		if (opt_autoengine)
@@ -328,7 +332,7 @@ int gpu_fanspeed(int gpu)
 	return ga->lpFanSpeedValue.iFanSpeed;
 }
 
-static int gpu_fanpercent(int gpu)
+int gpu_fanpercent(int gpu)
 {
 	struct gpu_adl *ga;
 
@@ -581,15 +585,15 @@ void gpu_autotune(int gpu)
 	ga = &gpus[gpu].adl;
 	if (temp && fanpercent >= 0 && ga->autofan) {
 		if (temp > ga->overtemp && fanpercent < 100) {
-			applog(LOG_WARNING, "Overhead detected, increasing fan to 100%");
+			applog(LOG_WARNING, "Overheat detected, increasing fan to 100%");
 			newpercent = 100;
 		} else if (temp > ga->targettemp && fanpercent < 85) {
 			if (opt_debug)
 				applog(LOG_DEBUG, "Temperature over target, increasing fanspeed");
 			newpercent = fanpercent + 5;
-		} else if (fanpercent && temp < ga->targettemp - 5) {
+		} else if (fanpercent && temp < ga->targettemp - opt_hysteresis) {
 			if (opt_debug)
-				applog(LOG_DEBUG, "Temperature 5 degrees below target, decreasing fanspeed");
+				applog(LOG_DEBUG, "Temperature %d degrees below target, decreasing fanspeed", opt_hysteresis);
 			newpercent = fanpercent - 1;
 		}
 
@@ -608,9 +612,9 @@ void gpu_autotune(int gpu)
 		if (temp > ga->overtemp && engine > ga->minspeed) {
 			applog(LOG_WARNING, "Overheat detected, decreasing GPU clock speed");
 			newengine = ga->minspeed;
-		} else if (temp > ga->targettemp + 5 && engine > ga->minspeed && fan_optimal) {
+		} else if (temp > ga->targettemp + opt_hysteresis && engine > ga->minspeed && fan_optimal) {
 			if (opt_debug)
-				applog(LOG_DEBUG, "Temperature over target, decreasing clock speed");
+				applog(LOG_DEBUG, "Temperature %d degrees over target, decreasing clock speed", opt_hysteresis);
 			newengine = engine - ga->lpOdParameters.sEngineClock.iStep;
 		} else if (temp < ga->targettemp && engine < ga->maxspeed) {
 			if (opt_debug)
diff --git a/adl.h b/adl.h
index 1e2540b..1254b46 100644
--- a/adl.h
+++ b/adl.h
@@ -2,6 +2,9 @@
 #define __ADL_H__
 bool adl_active;
 #ifdef HAVE_ADL
+int opt_hysteresis;
+int opt_targettemp;
+int opt_overheattemp;
 void init_adl(int nDevs);
 float gpu_temp(int gpu);
 int gpu_engineclock(int gpu);
@@ -9,6 +12,7 @@ int gpu_memclock(int gpu);
 float gpu_vddc(int gpu);
 int gpu_activity(int gpu);
 int gpu_fanspeed(int gpu);
+int gpu_fanpercent(int gpu);
 void change_gpusettings(int gpu);
 void gpu_autotune(int gpu);
 void clear_adl(int nDevs);
diff --git a/main.c b/main.c
index bf385e9..9d6b9de 100644
--- a/main.c
+++ b/main.c
@@ -967,6 +967,11 @@ static char *set_int_0_to_10(const char *arg, int *i)
 	return set_int_range(arg, i, 0, 10);
 }
 
+static char *set_int_0_to_100(const char *arg, int *i)
+{
+	return set_int_range(arg, i, 0, 100);
+}
+
 static char *set_int_1_to_10(const char *arg, int *i)
 {
 	return set_int_range(arg, i, 1, 10);
@@ -1246,7 +1251,17 @@ static struct opt_table opt_config_table[] = {
 			opt_set_bool, &use_syslog,
 			"Use system log for output messages (default: standard error)"),
 #endif
-
+#ifdef HAVE_ADL
+	OPT_WITH_ARG("--temp-hysteresis",
+		     set_int_0_to_10, opt_show_intval, &opt_hysteresis,
+		     "Set how much the temperature can fluctuate outside limits when automanaging speeds"),
+	OPT_WITH_ARG("--temp-overheat",
+		     set_int_0_to_100, opt_show_intval, &opt_overheattemp,
+		     "Set the overheat temperature when automatically managing fan and GPU speeds"),
+	OPT_WITH_ARG("--temp-target",
+		     set_int_0_to_100, opt_show_intval, &opt_targettemp,
+		     "Set the target temperature when automatically managing fan and GPU speeds"),
+#endif
 	OPT_WITHOUT_ARG("--text-only|-T",
 			opt_set_invbool, &use_curses,
 			"Disable ncurses formatted screen output"),
@@ -2764,8 +2779,8 @@ retry:
 			cgpu->efficiency, cgpu->utility);
 #ifdef HAVE_ADL
 		if (gpus[gpu].has_adl)
-			wlog("Temp: %.1f °C\nFan Speed: %d RPM\nEngine Clock: %d MHz\nMemory Clock: %d Mhz\nVddc: %.3f V\nActivity: %d%%\n",
-			     gpu_temp(gpu), gpu_fanspeed(gpu), gpu_engineclock(gpu), gpu_memclock(gpu), gpu_vddc(gpu), gpu_activity(gpu));
+			wlog("Temp: %.1f °C\nFan Speed: %d%% (%d RPM)\nEngine Clock: %d MHz\nMemory Clock: %d Mhz\nVddc: %.3f V\nActivity: %d%%\n",
+			     gpu_temp(gpu), gpu_fanpercent(gpu), gpu_fanspeed(gpu), gpu_engineclock(gpu), gpu_memclock(gpu), gpu_vddc(gpu), gpu_activity(gpu));
 #endif
 		wlog("Last initialised: %s\n", cgpu->init);
 		for (i = 0; i < mining_threads; i++) {