Browse Source

Allow device drivers and users to properly change target temperatures for non-GPUs

Luke Dashjr 13 years ago
parent
commit
226a3ead40
3 changed files with 76 additions and 62 deletions
  1. 1 1
      README
  2. 1 33
      driver-opencl.c
  3. 74 28
      miner.c

+ 1 - 1
README

@@ -169,6 +169,7 @@ Options for both config file and command line:
 --syslog            Use system log for output messages (default: standard error)
 --temp-cutoff <arg> Temperature where a device will be automatically disabled, one value or comma separated list (default: 95)
 --temp-hysteresis <arg> Set how much the temperature can fluctuate outside limits when automanaging speeds (default: 3)
+--temp-target <arg> Target temperature when automatically managing fan and clock speeds (default: 75)
 --text-only|-T      Disable ncurses formatted screen output
 --url|-o <arg>      URL for bitcoin JSON-RPC server
 --user|-u <arg>     Username for bitcoin JSON-RPC server
@@ -204,7 +205,6 @@ GPU only options:
 --no-adl            Disable the ATI display library used for monitoring and setting GPU parameters
 --no-restart        Do not attempt to restart GPUs that hang
 --temp-overheat <arg> Overheat temperature when automatically managing fan and GPU speeds (default: 85)
---temp-target <arg> Target temperature when automatically managing fan and GPU speeds (default: 75)
 --vectors|-v <arg>  Override detected optimal vector (1, 2 or 4) - one value or comma separated list
 --worksize|-w <arg> Override detected optimal worksize - one value or comma separated list
 

+ 1 - 33
driver-opencl.c

@@ -729,40 +729,8 @@ char *set_temp_overheat(char *arg)
 
 	return NULL;
 }
-
-char *set_temp_target(char *arg)
-{
-	int i, val = 0, device = 0, *tt;
-	char *nextptr;
-
-	nextptr = strtok(arg, ",");
-	if (nextptr == NULL)
-		return "Invalid parameters for set temp target";
-	val = atoi(nextptr);
-	if (val < 0 || val > 200)
-		return "Invalid value passed to set temp target";
-
-	tt = &gpus[device++].targettemp;
-	*tt = val;
-
-	while ((nextptr = strtok(NULL, ",")) != NULL) {
-		val = atoi(nextptr);
-		if (val < 0 || val > 200)
-			return "Invalid value passed to set temp target";
-
-		tt = &gpus[device++].targettemp;
-		*tt = val;
-	}
-	if (device == 1) {
-		for (i = device; i < MAX_GPUDEVICES; i++) {
-			tt = &gpus[i].targettemp;
-			*tt = val;
-		}
-	}
-
-	return NULL;
-}
 #endif
+
 #ifdef HAVE_OPENCL
 char *set_intensity(char *arg)
 {

+ 74 - 28
miner.c

@@ -784,7 +784,8 @@ static char* set_sharelog(char *arg)
 	return NULL;
 }
 
-static char *temp_cutoff_str = NULL;
+static char *temp_cutoff_str = "";
+static char *temp_target_str = "";
 
 char *set_temp_cutoff(char *arg)
 {
@@ -800,35 +801,80 @@ char *set_temp_cutoff(char *arg)
 	return NULL;
 }
 
-static void load_temp_cutoffs()
+char *set_temp_target(char *arg)
 {
-	int i, val = 0, device = 0;
-	char *nextptr;
+	int val;
 
-	if (temp_cutoff_str) {
-		for (device = 0, nextptr = strtok(temp_cutoff_str, ","); nextptr; ++device, nextptr = strtok(NULL, ",")) {
-			if (device >= total_devices)
-				quit(1, "Too many values passed to set temp cutoff");
-			val = atoi(nextptr);
-			if (val < 0 || val > 200)
-				quit(1, "Invalid value passed to set temp cutoff");
+	if (!(arg && arg[0]))
+		return "Invalid parameters for set temp target";
+	val = atoi(arg);
+	if (val < 0 || val > 200)
+		return "Invalid value passed to set temp target";
+	temp_target_str = arg;
 
-			devices[device]->cutofftemp = val;
-		}
-	} else {
-		for (i = device; i < total_devices; ++i) {
-			if (!devices[i]->cutofftemp)
-				devices[i]->cutofftemp = opt_cutofftemp;
-		}
-		return;
+	return NULL;
+}
+
+// For a single element string, this always returns the number (for all calls)
+// For multi-element strings, it returns each element as a number in order, and 0 when there are no more
+static int temp_strtok(char *base, char **n)
+{
+	char *i = *n;
+	char *p = strchr(i, ',');
+	if (p) {
+		p[0] = '\0';
+		*n = &p[1];
 	}
-	if (device <= 1) {
-		for (i = device; i < total_devices; ++i)
-			devices[i]->cutofftemp = val;
+	else
+	if (base != i)
+		*n = strchr(i, '\0');
+	return atoi(i);
+}
+
+static void load_temp_config()
+{
+	int i, val = 0, target_off;
+	char *cutoff_n, *target_n;
+	struct cgpu_info *cgpu;
+
+	cutoff_n = temp_cutoff_str;
+	target_n = temp_target_str;
+
+	for (i = 0; i < total_devices; ++i) {
+		cgpu = devices[i];
+		
+		// cutoff default may be specified by driver during probe; otherwise, opt_cutofftemp (const)
+		if (!cgpu->cutofftemp)
+			cgpu->cutofftemp = opt_cutofftemp;
+		
+		// target default may be specified by driver, and is moved with offset; otherwise, offset minus 6
+		if (cgpu->targettemp)
+			target_off = cgpu->targettemp - cgpu->cutofftemp;
+		else
+			target_off = -6;
+		
+		val = temp_strtok(temp_cutoff_str, &cutoff_n);
+		if (val < 0 || val > 200)
+			quit(1, "Invalid value passed to set temp cutoff");
+		if (val)
+			cgpu->cutofftemp = val;
+		
+		val = temp_strtok(temp_target_str, &target_n);
+		if (val < 0 || val > 200)
+			quit(1, "Invalid value passed to set temp target");
+		if (val)
+			cgpu->targettemp = val;
+		else
+			cgpu->targettemp = cgpu->cutofftemp + target_off;
+		
+		applog(LOG_DEBUG, "%s %u: Set temperature config: target=%d cutoff=%d",
+		       cgpu->api->name, cgpu->device_id,
+		       cgpu->targettemp, cgpu->cutofftemp);
 	}
-	for (i = 0; i < total_devices; ++i)
-		if (!devices[i]->targettemp)
-			devices[i]->targettemp = devices[i]->cutofftemp - 6;
+	if (cutoff_n != temp_cutoff_str && cutoff_n[0])
+		quit(1, "Too many values passed to set temp cutoff");
+	if (target_n != temp_target_str && target_n[0])
+		quit(1, "Too many values passed to set temp target");
 }
 
 static char *set_api_allow(const char *arg)
@@ -1183,14 +1229,14 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITH_ARG("--temp-hysteresis",
 		     set_int_1_to_10, opt_show_intval, &opt_hysteresis,
 		     "Set how much the temperature can fluctuate outside limits when automanaging speeds"),
-#endif
 #ifdef HAVE_ADL
 	OPT_WITH_ARG("--temp-overheat",
 		     set_temp_overheat, opt_show_intval, &opt_overheattemp,
 		     "Overheat temperature when automatically managing fan and GPU speeds, one value or comma separated list"),
+#endif
 	OPT_WITH_ARG("--temp-target",
 		     set_temp_target, opt_show_intval, &opt_targettemp,
-		     "Target temperature when automatically managing fan and GPU speeds, one value or comma separated list"),
+		     "Target temperature when automatically managing fan and clock speeds, one value or comma separated list"),
 #endif
 	OPT_WITHOUT_ARG("--text-only|-T",
 			opt_set_invbool, &use_curses,
@@ -6636,7 +6682,7 @@ int main(int argc, char *argv[])
 	if (!total_devices)
 		quit(1, "All devices disabled, cannot mine!");
 
-	load_temp_cutoffs();
+	load_temp_config();
 
 	for (i = 0; i < total_devices; ++i)
 		devices[i]->cgminer_stats.getwork_wait_min.tv_sec = MIN_SEC_UNSET;