Browse Source

Merge branch 'dynclock' into bfgminer

Luke Dashjr 13 years ago
parent
commit
37ec3667a4
7 changed files with 27 additions and 8 deletions
  1. 1 1
      README
  2. 0 1
      adl.c
  3. 0 1
      adl.h
  4. 14 2
      driver-modminer.c
  5. 7 2
      dynclock.c
  6. 4 1
      miner.c
  7. 1 0
      miner.h

+ 1 - 1
README

@@ -168,6 +168,7 @@ Options for both config file and command line:
 --submit-threads    Maximum number of share submission threads (default: 64)
 --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)
 --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
@@ -202,7 +203,6 @@ GPU only options:
 --ndevs|-n          Enumerate number of detected GPUs and exit
 --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-hysteresis <arg> Set how much the temperature can fluctuate outside limits when automanaging speeds (default: 3)
 --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

+ 0 - 1
adl.c

@@ -44,7 +44,6 @@
 bool adl_active;
 bool opt_reorder = false;
 
-int opt_hysteresis = 3;
 const int opt_targettemp = 75;
 const int opt_overheattemp = 85;
 static pthread_mutex_t adl_lock;

+ 0 - 1
adl.h

@@ -3,7 +3,6 @@
 #ifdef HAVE_ADL
 bool adl_active;
 bool opt_reorder;
-int opt_hysteresis;
 const int opt_targettemp;
 const int opt_overheattemp;
 void init_adl(int nDevs);

+ 14 - 2
driver-modminer.c

@@ -36,6 +36,7 @@ struct modminer_fpga_state {
 	char next_work_cmd[46];
 
 	struct dclk_data dclk;
+	uint8_t freqMaxMaxM;
 	// Number of nonces didn't meet pdiff 1, ever
 	int bad_share_counter;
 	// Number of nonces did meet pdiff 1, ever
@@ -434,6 +435,7 @@ modminer_fpga_init(struct thr_info *thr)
 			continue;
 		break;
 	}
+	state->freqMaxMaxM =
 	state->dclk.freqMaxM = state->dclk.freqM;
 	if (MODMINER_DEFAULT_CLOCK / 2 < state->dclk.freqM) {
 		if (!modminer_change_clock(thr, false, -(state->dclk.freqM * 2 - MODMINER_DEFAULT_CLOCK)))
@@ -508,7 +510,7 @@ static void modminer_get_temperature(struct cgpu_info *modminer, struct thr_info
 	if (2 == write(fd, cmd, 2) && read(fd, &temperature, 1) == 1)
 	{
 		state->temp = temperature;
-		if (temperature > modminer->cutofftemp - 2) {
+		if (temperature > modminer->targettemp + opt_hysteresis) {
 			{
 				time_t now = time(NULL);
 				if (state->last_cutoff_reduced != now) {
@@ -521,9 +523,18 @@ static void modminer_get_temperature(struct cgpu_info *modminer, struct thr_info
 						       oldFreq * 2, state->dclk.freqM * 2,
 						       temperature
 						);
+					state->dclk.freqMaxM = state->dclk.freqM;
 				}
 			}
 		}
+		else
+		if (state->dclk.freqMaxM < state->freqMaxMaxM && temperature < modminer->targettemp) {
+			if (temperature < modminer->targettemp - opt_hysteresis) {
+				state->dclk.freqMaxM = state->freqMaxMaxM;
+			} else {
+				++state->dclk.freqMaxM;
+			}
+		}
 	}
 }
 
@@ -563,7 +574,8 @@ get_modminer_api_extra_device_status(struct cgpu_info*modminer)
 		if (state->temp)
 			json_object_set(o, "Temperature", json_integer(state->temp));
 		json_object_set(o, "Frequency", json_real((double)state->dclk.freqM * 2 * 1000000.));
-		json_object_set(o, "Max Frequency", json_real((double)state->dclk.freqMaxM * 2 * 1000000.));
+		json_object_set(o, "Cool Max Frequency", json_real((double)state->dclk.freqMaxM * 2 * 1000000.));
+		json_object_set(o, "Max Frequency", json_real((double)state->freqMaxMaxM * 2 * 1000000.));
 		json_object_set(o, "Hardware Errors", json_integer(state->bad_share_counter));
 		json_object_set(o, "Valid Nonces", json_integer(state->good_share_counter));
 

+ 7 - 2
dynclock.c

@@ -29,16 +29,21 @@ void dclk_msg_freqchange(const char *repr, int oldFreq, int newFreq, const char
 bool dclk_updateFreq(struct dclk_data *data, dclk_change_clock_func_t changeclock, struct thr_info *thr)
 {
 	struct cgpu_info *cgpu = thr->cgpu;
+	uint8_t freqMDefault = data->freqMDefault;
 	int i, maxM, bestM;
 	double bestR, r;
 	bool rv = true;
 
+	if (freqMDefault > data->freqMaxM)
+		// This occurs when the device in question adjusts its MaxM down due to temperature or similar reasons
+		freqMDefault = data->freqMaxM;
+
 	for (i = 0; i < data->freqMaxM; i++)
 		if (data->maxErrorRate[i + 1] * i < data->maxErrorRate[i] * (i + 20))
 			data->maxErrorRate[i + 1] = data->maxErrorRate[i] * (1.0 + 20.0 / i);
 
 	maxM = 0;
-	while (maxM < data->freqMDefault && data->maxErrorRate[maxM + 1] < DCLK_MAXMAXERRORRATE)
+	while (maxM < freqMDefault && data->maxErrorRate[maxM + 1] < DCLK_MAXMAXERRORRATE)
 		maxM++;
 	while (maxM < data->freqMaxM && data->errorWeight[maxM] > 150 && data->maxErrorRate[maxM + 1] < DCLK_MAXMAXERRORRATE)
 		maxM++;
@@ -57,7 +62,7 @@ bool dclk_updateFreq(struct dclk_data *data, dclk_change_clock_func_t changecloc
 		rv = changeclock(thr, bestM);
 	}
 
-	maxM = data->freqMDefault;
+	maxM = freqMDefault;
 	while (maxM < data->freqMaxM && data->errorWeight[maxM + 1] > 100)
 		maxM++;
 	if ((bestM < (1.0 - DCLK_OVERHEATTHRESHOLD) * maxM) && bestM < maxM - 1) {

+ 4 - 1
miner.c

@@ -111,6 +111,7 @@ bool opt_quiet;
 bool opt_realquiet;
 bool opt_loginput;
 const int opt_cutofftemp = 95;
+int opt_hysteresis = 3;
 static int opt_retries = -1;
 int opt_fail_pause = 5;
 int opt_log_interval = 5;
@@ -1178,10 +1179,12 @@ static struct opt_table opt_config_table[] = {
 		     set_temp_cutoff, opt_show_intval, &opt_cutofftemp,
 		     "Temperature where a device will be automatically disabled, one value or comma separated list"),
 #endif
-#ifdef HAVE_ADL
+#if defined(HAVE_ADL) || defined(USE_MODMINER)
 	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"),

+ 1 - 0
miner.h

@@ -760,6 +760,7 @@ extern double total_diff_accepted, total_diff_rejected, total_diff_stale;
 extern unsigned int local_work;
 extern unsigned int total_go, total_ro;
 extern const int opt_cutofftemp;
+extern int opt_hysteresis;
 extern int opt_fail_pause;
 extern int opt_log_interval;
 extern unsigned long long global_hashrate;