Browse Source

Merge branch '201402_opencl_cleanup' into bfgminer

Luke Dashjr 12 years ago
parent
commit
698839d40c
6 changed files with 82 additions and 26 deletions
  1. 0 3
      README
  2. 1 3
      api.c
  3. 0 1
      driver-cpu.c
  4. 78 13
      driver-opencl.c
  5. 3 5
      miner.c
  6. 0 1
      miner.h

+ 0 - 3
README

@@ -297,9 +297,6 @@ See example.conf for an example configuration.
 
 
 GPU only options:
 GPU only options:
 
 
---auto-fan          Automatically adjust all GPU fan speeds to maintain a target temperature
---auto-gpu          Automatically adjust all GPU engine clock speeds to maintain a target temperature
---gpu-dyninterval <arg> Set the refresh interval in ms for GPUs using dynamic intensity (default: 7)
 --gpu-map <arg>     Map OpenCL to ADL device order manually, paired CSV (e.g. 1:0,2:1 maps OpenCL 1 to ADL 0, 2 to 1)
 --gpu-map <arg>     Map OpenCL to ADL device order manually, paired CSV (e.g. 1:0,2:1 maps OpenCL 1 to ADL 0, 2 to 1)
 --gpu-platform <arg> Select OpenCL platform ID to use for GPU mining
 --gpu-platform <arg> Select OpenCL platform ID to use for GPU mining
 --gpu-reorder       Attempt to reorder GPU devices according to PCI Bus ID
 --gpu-reorder       Attempt to reorder GPU devices according to PCI Bus ID

+ 1 - 3
api.c

@@ -1421,8 +1421,6 @@ int find_index_by_cgpu(struct cgpu_info *cgpu)
 			break;
 			break;
 		if (devices[i]->device != devices[i] && !per_proc)
 		if (devices[i]->device != devices[i] && !per_proc)
 			continue;
 			continue;
-		if (cgpu->devtype == devices[i]->devtype)
-			++n;
 	}
 	}
 	rd_unlock(&devices_lock);
 	rd_unlock(&devices_lock);
 	return n;
 	return n;
@@ -1521,7 +1519,7 @@ void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson,
 			break;
 			break;
 	}
 	}
 
 
-	root = api_add_int(root, (char*)cgpu->devtype, &n, true);
+	root = api_add_int(root, "PGA", &n, true);
 	root = api_add_device_identifier(root, cgpu);
 	root = api_add_device_identifier(root, cgpu);
 	root = api_add_string(root, "Enabled", bool2str(enabled), false);
 	root = api_add_string(root, "Enabled", bool2str(enabled), false);
 	root = api_add_string(root, "Status", status2str(status), false);
 	root = api_add_string(root, "Status", status2str(status), false);

+ 0 - 1
driver-cpu.c

@@ -764,7 +764,6 @@ static int cpu_autodetect()
 
 
 		cgpu = &cpus[i];
 		cgpu = &cpus[i];
 		cgpu->drv = &cpu_drv;
 		cgpu->drv = &cpu_drv;
-		cgpu->devtype = "CPU";
 		cgpu->deven = DEV_ENABLED;
 		cgpu->deven = DEV_ENABLED;
 		cgpu->threads = 1;
 		cgpu->threads = 1;
 		cgpu->kname = algo_names[opt_algo];
 		cgpu->kname = algo_names[opt_algo];

+ 78 - 13
driver-opencl.c

@@ -454,11 +454,15 @@ bool _set_gpu_engine(struct cgpu_info * const cgpu, const char * const _val)
 {
 {
 	int val1, val2;
 	int val1, val2;
 	get_intrange(_val, &val1, &val2);
 	get_intrange(_val, &val1, &val2);
-	if (val1 < 0 || val1 > 9999 || val2 < 0 || val2 > 9999)
+	if (val1 < 0 || val1 > 9999 || val2 < 0 || val2 > 9999 || val2 < val1)
 		return false;
 		return false;
+	
 	struct opencl_device_data * const data = cgpu->device_data;
 	struct opencl_device_data * const data = cgpu->device_data;
+	struct gpu_adl * const ga = &data->adl;
+	
 	data->min_engine = val1;
 	data->min_engine = val1;
 	data->gpu_engine = val2;
 	data->gpu_engine = val2;
+	ga->autoengine = (val1 != val2);
 	return true;
 	return true;
 }
 }
 _SET_INTERFACE(gpu_engine)
 _SET_INTERFACE(gpu_engine)
@@ -469,8 +473,38 @@ const char *set_gpu_engine(char *arg)
 static
 static
 const char *opencl_set_gpu_engine(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
 const char *opencl_set_gpu_engine(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
 {
 {
-	if (set_engineclock(proc->device_id, atoi(newvalue)))
-		return "Failed to set gpu_engine";
+	struct opencl_device_data * const data = proc->device_data;
+	struct gpu_adl * const ga = &data->adl;
+	
+	int val1, val2;
+	get_intrange(newvalue, &val1, &val2);
+	if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100 || val2 < val1)
+		return "Invalid value for clock";
+	
+	if (val1 == val2)
+	{
+		if (set_engineclock(proc->device_id, val1))
+			return "Failed to set gpu_engine";
+		ga->autoengine = false;
+	}
+	else
+	{
+		// Ensure current clock is within range
+		if (ga->lastengine < val1)
+		{
+			if (set_engineclock(proc->device_id, val1))
+				return "Failed to set gpu_engine";
+		}
+		else
+		if (ga->lastengine > val2)
+			if (set_engineclock(proc->device_id, val2))
+				return "Failed to set gpu_engine";
+		
+		data->min_engine = val1;
+		data->gpu_engine = val2;
+		ga->autoengine = true;
+	}
+	
 	return NULL;
 	return NULL;
 }
 }
 
 
@@ -479,11 +513,15 @@ bool _set_gpu_fan(struct cgpu_info * const cgpu, const char * const _val)
 {
 {
 	int val1, val2;
 	int val1, val2;
 	get_intrange(_val, &val1, &val2);
 	get_intrange(_val, &val1, &val2);
-	if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100)
+	if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100 || val2 < val1)
 		return false;
 		return false;
+	
 	struct opencl_device_data * const data = cgpu->device_data;
 	struct opencl_device_data * const data = cgpu->device_data;
+	struct gpu_adl * const ga = &data->adl;
+	
 	data->min_fan = val1;
 	data->min_fan = val1;
 	data->gpu_fan = val2;
 	data->gpu_fan = val2;
+	ga->autofan = (val1 != val2);
 	return true;
 	return true;
 }
 }
 _SET_INTERFACE(gpu_fan)
 _SET_INTERFACE(gpu_fan)
@@ -494,8 +532,38 @@ const char *set_gpu_fan(char *arg)
 static
 static
 const char *opencl_set_gpu_fan(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
 const char *opencl_set_gpu_fan(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
 {
 {
-	if (set_fanspeed(proc->device_id, atoi(newvalue)))
-		return "Failed to set gpu_fan";
+	struct opencl_device_data * const data = proc->device_data;
+	struct gpu_adl * const ga = &data->adl;
+	
+	int val1, val2;
+	get_intrange(newvalue, &val1, &val2);
+	if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100 || val2 < val1)
+		return "Invalid value for fan";
+	
+	if (val1 == val2)
+	{
+		if (set_fanspeed(proc->device_id, val1))
+			return "Failed to set gpu_fan";
+		ga->autofan = false;
+	}
+	else
+	{
+		// Ensure current fan is within range
+		if (ga->targetfan < val1)
+		{
+			if (set_fanspeed(proc->device_id, val1))
+				return "Failed to set gpu_fan";
+		}
+		else
+		if (ga->targetfan > val2)
+			if (set_fanspeed(proc->device_id, val2))
+				return "Failed to set gpu_fan";
+		
+		data->min_fan = val1;
+		data->gpu_fan = val2;
+		ga->autofan = true;
+	}
+	
 	return NULL;
 	return NULL;
 }
 }
 
 
@@ -672,7 +740,6 @@ void pause_dynamic_threads(int gpu)
 		thr = cgpu->thr[i];
 		thr = cgpu->thr[i];
 		if (!thr->pause && data->dynamic) {
 		if (!thr->pause && data->dynamic) {
 			applog(LOG_WARNING, "Disabling extra threads due to dynamic mode.");
 			applog(LOG_WARNING, "Disabling extra threads due to dynamic mode.");
-			applog(LOG_WARNING, "Tune dynamic intensity with --gpu-dyninterval");
 		}
 		}
 
 
 		thr->pause = data->dynamic;
 		thr->pause = data->dynamic;
@@ -1282,7 +1349,6 @@ static int opencl_autodetect()
 		cgpu = &gpus[i];
 		cgpu = &gpus[i];
 		struct opencl_device_data * const data = cgpu->device_data;
 		struct opencl_device_data * const data = cgpu->device_data;
 		
 		
-		cgpu->devtype = "GPU";
 		cgpu->deven = DEV_ENABLED;
 		cgpu->deven = DEV_ENABLED;
 		cgpu->drv = &opencl_api;
 		cgpu->drv = &opencl_api;
 		cgpu->device_id = i;
 		cgpu->device_id = i;
@@ -1330,9 +1396,8 @@ static void reinit_opencl_device(struct cgpu_info *gpu)
 	tq_push(control_thr[gpur_thr_id].q, gpu);
 	tq_push(control_thr[gpur_thr_id].q, gpu);
 }
 }
 
 
-// FIXME: Legacy (called by TUI) for side effects
 static
 static
-bool override_opencl_statline_temp(char *buf, size_t bufsz, struct cgpu_info *gpu, __maybe_unused bool per_processor)
+bool opencl_get_stats(struct cgpu_info * const gpu)
 {
 {
 	__maybe_unused struct opencl_device_data * const data = gpu->device_data;
 	__maybe_unused struct opencl_device_data * const data = gpu->device_data;
 #ifdef HAVE_SENSORS
 #ifdef HAVE_SENSORS
@@ -1353,7 +1418,7 @@ bool override_opencl_statline_temp(char *buf, size_t bufsz, struct cgpu_info *gp
 				continue;
 				continue;
 			
 			
 			gpu->temp = val;
 			gpu->temp = val;
-			return false;
+			return true;
 		}
 		}
 	}
 	}
 #endif
 #endif
@@ -1364,7 +1429,7 @@ bool override_opencl_statline_temp(char *buf, size_t bufsz, struct cgpu_info *gp
 		gpu_fanspeed(gpuid);
 		gpu_fanspeed(gpuid);
 	}
 	}
 #endif
 #endif
-	return false;
+	return true;
 }
 }
 
 
 static
 static
@@ -1766,7 +1831,7 @@ struct device_drv opencl_api = {
 	.drv_detect = opencl_detect,
 	.drv_detect = opencl_detect,
 	.reinit_device = reinit_opencl_device,
 	.reinit_device = reinit_opencl_device,
 	.watchdog = opencl_watchdog,
 	.watchdog = opencl_watchdog,
-	.override_statline_temp2 = override_opencl_statline_temp,
+	.get_stats = opencl_get_stats,
 #ifdef HAVE_CURSES
 #ifdef HAVE_CURSES
 	.proc_wlogprint_status = opencl_wlogprint_status,
 	.proc_wlogprint_status = opencl_wlogprint_status,
 	.proc_tui_wlogprint_choices = opencl_tui_wlogprint_choices,
 	.proc_tui_wlogprint_choices = opencl_tui_wlogprint_choices,

+ 3 - 5
miner.c

@@ -1944,10 +1944,10 @@ static struct opt_table opt_config_table[] = {
 #ifdef HAVE_ADL
 #ifdef HAVE_ADL
 	OPT_WITHOUT_ARG("--auto-fan",
 	OPT_WITHOUT_ARG("--auto-fan",
 			opt_set_bool, &opt_autofan,
 			opt_set_bool, &opt_autofan,
-			"Automatically adjust all GPU fan speeds to maintain a target temperature"),
+			opt_hidden),
 	OPT_WITHOUT_ARG("--auto-gpu",
 	OPT_WITHOUT_ARG("--auto-gpu",
 			opt_set_bool, &opt_autoengine,
 			opt_set_bool, &opt_autoengine,
-			"Automatically adjust all GPU engine clock speeds to maintain a target temperature"),
+			opt_hidden),
 #endif
 #endif
 	OPT_WITHOUT_ARG("--balance",
 	OPT_WITHOUT_ARG("--balance",
 		     set_balance, &pool_strategy,
 		     set_balance, &pool_strategy,
@@ -2048,7 +2048,7 @@ static struct opt_table opt_config_table[] = {
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
 	OPT_WITH_ARG("--gpu-dyninterval",
 	OPT_WITH_ARG("--gpu-dyninterval",
 		     set_int_1_to_65535, opt_show_intval, &opt_dynamic_interval,
 		     set_int_1_to_65535, opt_show_intval, &opt_dynamic_interval,
-		     "Set the refresh interval in ms for GPUs using dynamic intensity"),
+		     opt_hidden),
 	OPT_WITH_ARG("--gpu-platform",
 	OPT_WITH_ARG("--gpu-platform",
 		     set_int_0_to_9999, opt_show_intval, &opt_platform_id,
 		     set_int_0_to_9999, opt_show_intval, &opt_platform_id,
 		     "Select OpenCL platform ID to use for GPU mining"),
 		     "Select OpenCL platform ID to use for GPU mining"),
@@ -10552,8 +10552,6 @@ void allocate_cgpu(struct cgpu_info *cgpu, unsigned int *kp)
 	int j;
 	int j;
 	
 	
 	struct device_drv *api = cgpu->drv;
 	struct device_drv *api = cgpu->drv;
-	if (!cgpu->devtype)
-		cgpu->devtype = "PGA";
 	cgpu->cgminer_stats.getwork_wait_min.tv_sec = MIN_SEC_UNSET;
 	cgpu->cgminer_stats.getwork_wait_min.tv_sec = MIN_SEC_UNSET;
 	
 	
 	int threadobj = cgpu->threads;
 	int threadobj = cgpu->threads;

+ 0 - 1
miner.h

@@ -444,7 +444,6 @@ struct cgpu_info {
 	int device_line_id;
 	int device_line_id;
 	struct device_drv *drv;
 	struct device_drv *drv;
 	const struct bfg_set_device_definition *set_device_funcs;
 	const struct bfg_set_device_definition *set_device_funcs;
-	const char *devtype;
 	int device_id;
 	int device_id;
 	char *dev_repr;
 	char *dev_repr;
 	char *dev_repr_ns;
 	char *dev_repr_ns;