Browse Source

Move targettemp from ADL to cgpu_info, so all devices can readily use it

Luke Dashjr 13 years ago
parent
commit
155958b170
4 changed files with 23 additions and 20 deletions
  1. 15 15
      adl.c
  2. 3 3
      driver-opencl.c
  3. 4 1
      miner.c
  4. 1 1
      miner.h

+ 15 - 15
adl.c

@@ -490,8 +490,8 @@ void init_adl(int nDevs)
 		}
 
 		/* Set some default temperatures for autotune when enabled */
-		if (!ga->targettemp)
-			ga->targettemp = opt_targettemp;
+		if (!gpus[gpu].targettemp)
+			gpus[gpu].targettemp = opt_targettemp;
 		if (!ga->overtemp)
 			ga->overtemp = opt_overheattemp;
 		if (!gpus[gpu].cutofftemp)
@@ -1054,15 +1054,15 @@ static bool fan_autotune(int gpu, int temp, int fanpercent, int lasttemp, bool *
 		cgpu->device_last_not_well = time(NULL);
 		cgpu->device_not_well_reason = REASON_DEV_OVER_HEAT;
 		cgpu->dev_over_heat_count++;
-	} else if (temp > ga->targettemp && fanpercent < top && tdiff >= 0) {
+	} else if (temp > gpus[gpu].targettemp && fanpercent < top && tdiff >= 0) {
 		applog(LOG_DEBUG, "Temperature over target, increasing fanspeed");
-		if (temp > ga->targettemp + opt_hysteresis)
+		if (temp > gpus[gpu].targettemp + opt_hysteresis)
 			newpercent = ga->targetfan + 10;
 		else
 			newpercent = ga->targetfan + 5;
 		if (newpercent > top)
 			newpercent = top;
-	} else if (fanpercent > bot && temp < ga->targettemp - opt_hysteresis) {
+	} else if (fanpercent > bot && temp < gpus[gpu].targettemp - opt_hysteresis) {
 		/* Detect large swings of 5 degrees or more and change fan by
 		 * a proportion more */
 		if (tdiff <= 0) {
@@ -1076,10 +1076,10 @@ static bool fan_autotune(int gpu, int temp, int fanpercent, int lasttemp, bool *
 
 		/* We're in the optimal range, make minor adjustments if the
 		 * temp is still drifting */
-		if (fanpercent > bot && tdiff < 0 && lasttemp < ga->targettemp) {
+		if (fanpercent > bot && tdiff < 0 && lasttemp < gpus[gpu].targettemp) {
 			applog(LOG_DEBUG, "Temperature dropping while in target range, decreasing fanspeed");
 			newpercent = ga->targetfan + tdiff;
-		} else if (fanpercent < top && tdiff > 0 && temp > ga->targettemp - opt_hysteresis) {
+		} else if (fanpercent < top && tdiff > 0 && temp > gpus[gpu].targettemp - opt_hysteresis) {
 			applog(LOG_DEBUG, "Temperature rising while in target range, increasing fanspeed");
 			newpercent = ga->targetfan + tdiff;
 		}
@@ -1168,17 +1168,17 @@ void gpu_autotune(int gpu, enum dev_enable *denable)
 			cgpu->device_last_not_well = time(NULL);
 			cgpu->device_not_well_reason = REASON_DEV_OVER_HEAT;
 			cgpu->dev_over_heat_count++;
-		} else if (temp > ga->targettemp + opt_hysteresis && engine > ga->minspeed && fan_optimal) {
+		} else if (temp > gpus[gpu].targettemp + opt_hysteresis && engine > ga->minspeed && fan_optimal) {
 			applog(LOG_DEBUG, "Temperature %d degrees over target, decreasing clock speed", opt_hysteresis);
 			newengine = engine - ga->lpOdParameters.sEngineClock.iStep;
 			/* Only try to tune engine speed up if this GPU is not disabled */
-		} else if (temp < ga->targettemp && engine < ga->maxspeed && fan_window && *denable == DEV_ENABLED) {
+		} else if (temp < gpus[gpu].targettemp && engine < ga->maxspeed && fan_window && *denable == DEV_ENABLED) {
 			applog(LOG_DEBUG, "Temperature below target, increasing clock speed");
-			if (temp < ga->targettemp - opt_hysteresis)
+			if (temp < gpus[gpu].targettemp - opt_hysteresis)
 				newengine = ga->maxspeed;
 			else
 				newengine = engine + ga->lpOdParameters.sEngineClock.iStep;
-		} else if (temp < ga->targettemp && *denable == DEV_RECOVER && opt_restart) {
+		} else if (temp < gpus[gpu].targettemp && *denable == DEV_RECOVER && opt_restart) {
 			applog(LOG_NOTICE, "Device recovered to temperature below target, re-enabling");
 			*denable = DEV_ENABLED;
 		}
@@ -1232,7 +1232,7 @@ void change_autosettings(int gpu)
 	char input;
 	int val;
 
-	wlogprint("Target temperature: %d\n", ga->targettemp);
+	wlogprint("Target temperature: %d\n", gpus[gpu].targettemp);
 	wlogprint("Overheat temperature: %d\n", ga->overtemp);
 	wlogprint("Cutoff temperature: %d\n", gpus[gpu].cutofftemp);
 	wlogprint("Toggle [F]an auto [G]PU auto\nChange [T]arget [O]verheat [C]utoff\n");
@@ -1257,11 +1257,11 @@ void change_autosettings(int gpu)
 		if (val < 0 || val > 200)
 			wlogprint("Invalid temperature");
 		else
-			ga->targettemp = val;
+			gpus[gpu].targettemp = val;
 	} else if (!strncasecmp(&input, "o", 1)) {
-		wlogprint("Enter overheat temperature for this GPU in C (%d+)", ga->targettemp);
+		wlogprint("Enter overheat temperature for this GPU in C (%d+)", gpus[gpu].targettemp);
 		val = curses_int("");
-		if (val <= ga->targettemp || val > 200)
+		if (val <= gpus[gpu].targettemp || val > 200)
 			wlogprint("Invalid temperature");
 		else
 			ga->overtemp = val;

+ 3 - 3
driver-opencl.c

@@ -742,7 +742,7 @@ char *set_temp_target(char *arg)
 	if (val < 0 || val > 200)
 		return "Invalid value passed to set temp target";
 
-	tt = &gpus[device++].adl.targettemp;
+	tt = &gpus[device++].targettemp;
 	*tt = val;
 
 	while ((nextptr = strtok(NULL, ",")) != NULL) {
@@ -750,12 +750,12 @@ char *set_temp_target(char *arg)
 		if (val < 0 || val > 200)
 			return "Invalid value passed to set temp target";
 
-		tt = &gpus[device++].adl.targettemp;
+		tt = &gpus[device++].targettemp;
 		*tt = val;
 	}
 	if (device == 1) {
 		for (i = device; i < MAX_GPUDEVICES; i++) {
-			tt = &gpus[i].adl.targettemp;
+			tt = &gpus[i].targettemp;
 			*tt = val;
 		}
 	}

+ 4 - 1
miner.c

@@ -825,6 +825,9 @@ static void load_temp_cutoffs()
 		for (i = device; i < total_devices; ++i)
 			devices[i]->cutofftemp = val;
 	}
+	for (i = 0; i < total_devices; ++i)
+		if (!devices[i]->targettemp)
+			devices[i]->targettemp = devices[i]->cutofftemp - 6;
 }
 
 static char *set_api_allow(const char *arg)
@@ -4008,7 +4011,7 @@ void write_config(FILE *fcfg)
 			fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].adl.overtemp);
 		fputs("\",\n\"temp-target\" : \"", fcfg);
 		for(i = 0; i < nDevs; i++)
-			fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].adl.targettemp);
+			fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].targettemp);
 #endif
 		fputs("\"", fcfg);
 	}

+ 1 - 1
miner.h

@@ -248,7 +248,6 @@ struct gpu_adl {
 	int lastengine;
 	int lasttemp;
 	int targetfan;
-	int targettemp;
 	int overtemp;
 	int minspeed;
 	int maxspeed;
@@ -433,6 +432,7 @@ struct cgpu_info {
 
 	float temp;
 	int cutofftemp;
+	int targettemp;
 
 #ifdef HAVE_ADL
 	bool has_adl;