Commit 9a6c082ad159935375915994372e8cc1944c2da2

Con Kolivas 2012-07-24T20:27:37

Make the thread concurrency and lookup gap options hidden on the command line and autotune parameters with a newly parsed --shaders option.

diff --git a/cgminer.c b/cgminer.c
index efe7894..6e9dd89 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -857,7 +857,7 @@ static struct opt_table opt_config_table[] = {
 #ifdef USE_SCRYPT
 	OPT_WITH_ARG("--lookup-gap",
 		     set_lookup_gap, NULL, NULL,
-		     "Set GPU lookup gap for scrypt mining, comma separated"),
+		     opt_hidden),
 #endif
 	OPT_WITH_ARG("--intensity|-I",
 		     set_intensity, NULL, NULL,
@@ -965,6 +965,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITHOUT_ARG("--scrypt",
 			opt_set_bool, &opt_scrypt,
 			"Use the scrypt algorithm for mining (litecoin only)"),
+	OPT_WITH_ARG("--shaders",
+		     set_shaders, NULL, NULL,
+		     "GPU shaders per card for tuning scrypt, comma separated"),
 #endif
 	OPT_WITH_ARG("--sharelog",
 		     set_sharelog, NULL, NULL,
@@ -1007,7 +1010,7 @@ static struct opt_table opt_config_table[] = {
 #ifdef USE_SCRYPT
 	OPT_WITH_ARG("--thread-concurrency",
 		     set_thread_concurrency, NULL, NULL,
-		     "Set GPU thread concurrency for scrypt mining, comma separated"),
+		     opt_hidden),
 #endif
 	OPT_WITH_ARG("--url|-o",
 		     set_url, NULL, NULL,
diff --git a/driver-opencl.c b/driver-opencl.c
index 7b3f8b7..eafdd5d 100644
--- a/driver-opencl.c
+++ b/driver-opencl.c
@@ -128,6 +128,31 @@ char *set_worksize(char *arg)
 }
 
 #ifdef USE_SCRYPT
+char *set_shaders(char *arg)
+{
+	int i, val = 0, device = 0;
+	char *nextptr;
+
+	nextptr = strtok(arg, ",");
+	if (nextptr == NULL)
+		return "Invalid parameters for set lookup gap";
+	val = atoi(nextptr);
+
+	gpus[device++].shaders = val;
+
+	while ((nextptr = strtok(NULL, ",")) != NULL) {
+		val = atoi(nextptr);
+
+		gpus[device++].shaders = val;
+	}
+	if (device == 1) {
+		for (i = device; i < MAX_GPUDEVICES; i++)
+			gpus[i].shaders = gpus[0].shaders;
+	}
+
+	return NULL;
+}
+
 char *set_lookup_gap(char *arg)
 {
 	int i, val = 0, device = 0;
diff --git a/driver-opencl.h b/driver-opencl.h
index f09571b..c1d6182 100644
--- a/driver-opencl.h
+++ b/driver-opencl.h
@@ -19,6 +19,7 @@ extern char *set_intensity(char *arg);
 extern char *set_vector(char *arg);
 extern char *set_worksize(char *arg);
 #ifdef USE_SCRYPT
+extern char *set_shaders(char *arg);
 extern char *set_lookup_gap(char *arg);
 extern char *set_thread_concurrency(char *arg);
 #endif
diff --git a/miner.h b/miner.h
index 291574c..68c6e15 100644
--- a/miner.h
+++ b/miner.h
@@ -365,6 +365,7 @@ struct cgpu_info {
 #ifdef USE_SCRYPT
 	int lookup_gap;
 	int thread_concurrency;
+	int shaders;
 #endif
 	struct timeval tv_gpustart;;
 	struct timeval tv_gpuend;
diff --git a/ocl.c b/ocl.c
index b09291b..f726444 100644
--- a/ocl.c
+++ b/ocl.c
@@ -478,6 +478,9 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
 		}
 		if (!gpus[gpu].thread_concurrency) {
 			gpus[gpu].thread_concurrency = gpus[gpu].max_alloc / 32768 / gpus[gpu].lookup_gap;
+			if (gpus[gpu].shaders && gpus[gpu].thread_concurrency > gpus[gpu].shaders)
+				gpus[gpu].thread_concurrency -= gpus[gpu].thread_concurrency % gpus[gpu].shaders;
+				
 			applog(LOG_DEBUG, "GPU %d: selecting thread concurrency of %u",gpu,  gpus[gpu].thread_concurrency);
 		}
 	}