Browse Source

Replace temp-cutoff and temp-target parameters with set-device options

Luke Dashjr 12 years ago
parent
commit
0c55400812
5 changed files with 47 additions and 163 deletions
  1. 0 2
      README
  2. 5 8
      README.GPU
  3. 22 0
      deviceapi.c
  4. 19 151
      miner.c
  5. 1 2
      miner.h

+ 0 - 2
README

@@ -274,9 +274,7 @@ Options for both config file and command line:
 --stratum-port <arg> Port number to listen on for stratum miners (-1 means disabled) (default: -1)
 --stratum-port <arg> Port number to listen on for stratum miners (-1 means disabled) (default: -1)
 --submit-threads    Minimum number of concurrent share submissions (default: 64)
 --submit-threads    Minimum number of concurrent share submissions (default: 64)
 --syslog            Use system log for output messages (default: standard error)
 --syslog            Use system log for output messages (default: standard error)
---temp-cutoff <arg> Maximum temperature devices will be allowed to reach before being disabled, one value or comma separated list
 --temp-hysteresis <arg> Set how much the temperature can fluctuate outside limits when automanaging speeds (default: 3)
 --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
 --text-only|-T      Disable ncurses formatted screen output
 --text-only|-T      Disable ncurses formatted screen output
 --unicode           Use Unicode characters in TUI
 --unicode           Use Unicode characters in TUI
 --url|-o <arg>      URL for bitcoin JSON-RPC server
 --url|-o <arg>      URL for bitcoin JSON-RPC server

+ 5 - 8
README.GPU

@@ -131,14 +131,13 @@ AUTO MODES:
 There are two "auto" modes in BFGMiner, --auto-fan and --auto-gpu. These can be
 There are two "auto" modes in BFGMiner, --auto-fan and --auto-gpu. These can be
 used independently of each other and are complementary. Both auto modes are
 used independently of each other and are complementary. Both auto modes are
 designed to safely change settings while trying to maintain a target
 designed to safely change settings while trying to maintain a target
-temperature. By default this is set to 75 degrees C but can be changed with:
+temperature. By default this is set to 75 degrees C but can be changed with the
+--set-device option. For example:
 
 
---temp-target
-e.g.
---temp-target 80
+--set-device OCL:temp-target=80
 Sets all cards' target temperature to 80 degrees.
 Sets all cards' target temperature to 80 degrees.
 
 
---temp-target 75,85
+--set-device OCL0:temp-target=75 --set-device OCL1:temp-target=85
 Sets card 0 target temperature to 75, and card 1 to 85 degrees.
 Sets card 0 target temperature to 75, and card 1 to 85 degrees.
 
 
 AUTO FAN:
 AUTO FAN:
@@ -185,9 +184,7 @@ cutoff limit (95 degrees by default), BFGMiner will completely disable the GPU
 from mining and it will not be re-enabled unless manually done so. The cutoff
 from mining and it will not be re-enabled unless manually done so. The cutoff
 temperature can be changed with:
 temperature can be changed with:
 
 
---temp-cutoff
-e.g.
---temp-cutoff 95,105
+--set-device OCL0:temp-cutoff=95 --set-device OCL1:temp-cutoff=105
 Sets card 0 cutoff temperature to 95 and card 1 to 105.
 Sets card 0 cutoff temperature to 95 and card 1 to 105.
 
 
 --gpu-memdiff -125
 --gpu-memdiff -125

+ 22 - 0
deviceapi.c

@@ -882,6 +882,22 @@ nohelp:
 	return replybuf;
 	return replybuf;
 }
 }
 
 
+const char *proc_set_device_temp_cutoff(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
+{
+	int target_diff = proc->cutofftemp - proc->targettemp;
+	proc->cutofftemp = atoi(newvalue);
+	if (!proc->targettemp_user)
+		proc->targettemp = proc->cutofftemp - target_diff;
+	return NULL;
+}
+
+const char *proc_set_device_temp_target(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
+{
+	proc->targettemp = atoi(newvalue);
+	proc->targettemp_user = true;
+	return NULL;
+}
+
 static inline
 static inline
 void _set_auto_sdr(enum bfg_set_device_replytype * const out_success, const char * const rv, const char * const optname)
 void _set_auto_sdr(enum bfg_set_device_replytype * const out_success, const char * const rv, const char * const optname)
 {
 {
@@ -914,6 +930,12 @@ const char *_proc_set_device(struct cgpu_info * const proc, const char * const o
 			return rv;
 			return rv;
 		}
 		}
 	
 	
+	if (!strcasecmp(optname, "temp-cutoff"))
+		return proc_set_device_temp_cutoff(proc, optname, newvalue, replybuf, out_success);
+	else
+	if (!strcasecmp(optname, "temp-target"))
+		return proc_set_device_temp_target(proc, optname, newvalue, replybuf, out_success);
+	else
 	if (!strcasecmp(optname, "help"))
 	if (!strcasecmp(optname, "help"))
 		return proc_set_device_help(proc, optname, newvalue, replybuf, out_success);
 		return proc_set_device_help(proc, optname, newvalue, replybuf, out_success);
 	
 	

+ 19 - 151
miner.c

@@ -1634,107 +1634,32 @@ static char *set_sharelog(char *arg)
 	return _bfgopt_set_file(arg, &sharelog_file, "a", "share log");
 	return _bfgopt_set_file(arg, &sharelog_file, "a", "share log");
 }
 }
 
 
-static char *temp_cutoff_str = "";
-static char *temp_target_str = "";
-
 char *set_temp_cutoff(char *arg)
 char *set_temp_cutoff(char *arg)
 {
 {
-	int val;
-
-	if (!(arg && arg[0]))
-		return "Invalid parameters for set temp cutoff";
-	val = atoi(arg);
-	if (val < 0 || val > 200)
-		return "Invalid value passed to set temp cutoff";
-	temp_cutoff_str = arg;
-
+	if (strchr(arg, ','))
+		return "temp-cutoff no longer supports comma-delimited syntax, use --set-device for better control";
+	applog(LOG_WARNING, "temp-cutoff is deprecated! Use --set-device for better control");
+	
+	char buf[0x100];
+	snprintf(buf, sizeof(buf), "all:temp-cutoff=%s", arg);
+	applog(LOG_DEBUG, "%s: Using --set-device %s", __func__, buf);
+	string_elist_add(buf, &opt_set_device_list);
+	
 	return NULL;
 	return NULL;
 }
 }
 
 
 char *set_temp_target(char *arg)
 char *set_temp_target(char *arg)
 {
 {
-	int val;
-
-	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;
-
-	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];
-	}
-	else
-	if (base != i)
-		*n = strchr(i, '\0');
-	return atoi(i);
-}
-
-static void load_temp_config_cgpu(struct cgpu_info *cgpu, char **cutoff_np, char **target_np)
-{
-	int target_off, val;
-	
-	// 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;
-	
-	cgpu->cutofftemp_default = cgpu->cutofftemp;
-	
-	val = temp_strtok(temp_cutoff_str, cutoff_np);
-	if (val < 0 || val > 200)
-		quit(1, "Invalid value passed to set temp cutoff");
-	if (val)
-		cgpu->cutofftemp = val;
-	
-	cgpu->targettemp_default = cgpu->cutofftemp + target_off;
+	if (strchr(arg, ','))
+		return "temp-target no longer supports comma-delimited syntax, use --set-device for better control";
+	applog(LOG_WARNING, "temp-target is deprecated! Use --set-device for better control");
 	
 	
-	val = temp_strtok(temp_target_str, target_np);
-	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;
+	char buf[0x100];
+	snprintf(buf, sizeof(buf), "all:temp-target=%s", arg);
+	applog(LOG_DEBUG, "%s: Using --set-device %s", __func__, buf);
+	string_elist_add(buf, &opt_set_device_list);
 	
 	
-	applog(LOG_DEBUG, "%"PRIprepr": Set temperature config: target=%d cutoff=%d",
-	       cgpu->proc_repr,
-	       cgpu->targettemp, cgpu->cutofftemp);
-}
-
-static void load_temp_config()
-{
-	int i;
-	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 = get_devices(i);
-		load_temp_config_cgpu(cgpu, &cutoff_n, &target_n);
-	}
-	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");
+	return NULL;
 }
 }
 
 
 static char *set_api_allow(const char *arg)
 static char *set_api_allow(const char *arg)
@@ -2292,7 +2217,7 @@ static struct opt_table opt_config_table[] = {
 #endif
 #endif
 	OPT_WITH_ARG("--temp-cutoff",
 	OPT_WITH_ARG("--temp-cutoff",
 		     set_temp_cutoff, NULL, &opt_cutofftemp,
 		     set_temp_cutoff, NULL, &opt_cutofftemp,
-		     "Maximum temperature devices will be allowed to reach before being disabled, one value or comma separated list"),
+		     opt_hidden),
 	OPT_WITH_ARG("--temp-hysteresis",
 	OPT_WITH_ARG("--temp-hysteresis",
 		     set_int_1_to_10, opt_show_intval, &opt_hysteresis,
 		     set_int_1_to_10, opt_show_intval, &opt_hysteresis,
 		     "Set how much the temperature can fluctuate outside limits when automanaging speeds"),
 		     "Set how much the temperature can fluctuate outside limits when automanaging speeds"),
@@ -2303,7 +2228,7 @@ static struct opt_table opt_config_table[] = {
 #endif
 #endif
 	OPT_WITH_ARG("--temp-target",
 	OPT_WITH_ARG("--temp-target",
 		     set_temp_target, NULL, NULL,
 		     set_temp_target, NULL, NULL,
-		     "Target temperature when automatically managing fan and clock speeds, one value or comma separated list"),
+		     opt_hidden),
 	OPT_WITHOUT_ARG("--text-only|-T",
 	OPT_WITHOUT_ARG("--text-only|-T",
 			opt_set_invbool, &use_curses,
 			opt_set_invbool, &use_curses,
 #ifdef HAVE_CURSES
 #ifdef HAVE_CURSES
@@ -6413,57 +6338,6 @@ char *json_escape(const char *str)
 	return buf;
 	return buf;
 }
 }
 
 
-void _write_config_temps(FILE *fcfg, const char *configname, size_t settingoffset, size_t defoffset)
-{
-	int i, commas;
-	int *setp, allset;
-	uint8_t *defp;
-	
-	for (i = 0; ; ++i)
-	{
-		if (i == total_devices)
-			// All defaults
-			return;
-		setp = ((void*)devices[i]) + settingoffset;
-		defp = ((void*)devices[i]) + defoffset;
-		allset = *setp;
-		if (*setp != *defp)
-			break;
-	}
-	
-	fprintf(fcfg, ",\n\"%s\" : \"", configname);
-	
-	for (i = 1; ; ++i)
-	{
-		if (i == total_devices)
-		{
-			// All the same
-			fprintf(fcfg, "%d\"", allset);
-			return;
-		}
-		setp = ((void*)devices[i]) + settingoffset;
-		if (allset != *setp)
-			break;
-	}
-	
-	commas = 0;
-	for (i = 0; i < total_devices; ++i)
-	{
-		setp = ((void*)devices[i]) + settingoffset;
-		defp = ((void*)devices[i]) + defoffset;
-		if (*setp != *defp)
-		{
-			for ( ; commas; --commas)
-				fputs(",", fcfg);
-			fprintf(fcfg, "%d", *setp);
-		}
-		++commas;
-	}
-	fputs("\"", fcfg);
-}
-#define write_config_temps(fcfg, configname, settingname)  \
-	_write_config_temps(fcfg, configname, offsetof(struct cgpu_info, settingname), offsetof(struct cgpu_info, settingname ## _default))
-
 static
 static
 void _write_config_string_elist(FILE *fcfg, const char *configname, struct string_elist * const elist)
 void _write_config_string_elist(FILE *fcfg, const char *configname, struct string_elist * const elist)
 {
 {
@@ -6510,8 +6384,6 @@ void write_config(FILE *fcfg)
 	}
 	}
 	fputs("\n]\n", fcfg);
 	fputs("\n]\n", fcfg);
 
 
-	write_config_temps(fcfg, "temp-cutoff", cutofftemp);
-	write_config_temps(fcfg, "temp-target", targettemp);
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
 	if (nDevs) {
 	if (nDevs) {
 		/* Write GPU device values */
 		/* Write GPU device values */
@@ -10970,7 +10842,6 @@ int create_new_cgpus(void (*addfunc)(void*), void *arg)
 	struct cgpu_info *cgpu;
 	struct cgpu_info *cgpu;
 	struct thr_info *thr;
 	struct thr_info *thr;
 	void *p;
 	void *p;
-	char *dummy = "\0";
 	
 	
 	mutex_lock(&mutex);
 	mutex_lock(&mutex);
 	devcount = total_devices;
 	devcount = total_devices;
@@ -11024,7 +10895,6 @@ int create_new_cgpus(void (*addfunc)(void*), void *arg)
 	{
 	{
 		cgpu = devices_new[i];
 		cgpu = devices_new[i];
 		
 		
-		load_temp_config_cgpu(cgpu, &dummy, &dummy);
 		allocate_cgpu(cgpu, &k);
 		allocate_cgpu(cgpu, &k);
 	}
 	}
 	for (i = 0; i < total_devices_new; ++i)
 	for (i = 0; i < total_devices_new; ++i)
@@ -11445,8 +11315,6 @@ int main(int argc, char *argv[])
 			applog(LOG_WARNING, "Waiting for devices");
 			applog(LOG_WARNING, "Waiting for devices");
 	}
 	}
 
 
-	load_temp_config();
-
 #ifdef HAVE_CURSES
 #ifdef HAVE_CURSES
 	switch_logsize();
 	switch_logsize();
 #endif
 #endif

+ 1 - 2
miner.h

@@ -539,9 +539,8 @@ struct cgpu_info {
 
 
 	float temp;
 	float temp;
 	int cutofftemp;
 	int cutofftemp;
-	uint8_t cutofftemp_default;
 	int targettemp;
 	int targettemp;
-	uint8_t targettemp_default;
+	bool targettemp_user;
 
 
 #ifdef HAVE_ADL
 #ifdef HAVE_ADL
 	bool has_adl;
 	bool has_adl;