Skip to content

Instantly share code, notes, and snippets.

@Elbandi
Created January 17, 2014 01:30
Show Gist options
  • Save Elbandi/8466924 to your computer and use it in GitHub Desktop.
Save Elbandi/8466924 to your computer and use it in GitHub Desktop.
diff --git a/cgminer.c b/cgminer.c
index b5199ff..63fa3b0 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1174,9 +1174,12 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--gpu-platform",
set_int_0_to_9999, opt_show_intval, &opt_platform_id,
"Select OpenCL platform ID to use for GPU mining"),
- OPT_WITH_ARG("--gpu-threads|-g",
+ OPT_WITH_ARG("--gpu-default-threads|-g",
set_int_1_to_10, opt_show_intval, &opt_g_threads,
"Number of threads per GPU (1 - 10)"),
+ OPT_WITH_ARG("--gpu-threads",
+ set_gpu_threads, NULL, NULL,
+ "Number of threads per GPU (1 - 10)"),
#ifdef HAVE_ADL
OPT_WITH_ARG("--gpu-engine",
set_gpu_engine, NULL, NULL,
diff --git a/driver-opencl.c b/driver-opencl.c
index d7b663a..3dca6b1 100644
--- a/driver-opencl.c
+++ b/driver-opencl.c
@@ -278,6 +278,35 @@ char *set_gpu_map(char *arg)
return NULL;
}
+char *set_gpu_threads(char *arg)
+{
+ int i, val = 0, device = 0;
+ char *nextptr;
+
+ nextptr = strtok(arg, ",");
+ if (nextptr == NULL)
+ return "Invalid parameters for set gpu threads";
+ val = atoi(nextptr);
+ if (val < 1 || val > 10)
+ return "Invalid value passed to set_gpu_threads";
+
+ gpus[device++].threads = val;
+
+ while ((nextptr = strtok(NULL, ",")) != NULL) {
+ val = atoi(nextptr);
+ if (val < 1 || val > 10)
+ return "Invalid value passed to set_gpu_threads";
+
+ gpus[device++].threads = val;
+ }
+ if (device == 1) {
+ for (i = device; i < MAX_GPUDEVICES; i++)
+ gpus[i].threads = gpus[0].threads;
+ }
+
+ return NULL;
+}
+
char *set_gpu_engine(char *arg)
{
int i, val1 = 0, val2 = 0, device = 0;
@@ -1261,7 +1290,9 @@ static void opencl_detect(bool hotplug)
cgpu->deven = DEV_ENABLED;
cgpu->drv = &opencl_drv;
cgpu->device_id = i;
- cgpu->threads = opt_g_threads;
+ if (cgpu->threads == 0) {
+ cgpu->threads = opt_g_threads;
+ }
cgpu->virtual_gpu = i;
add_cgpu(cgpu);
}
diff --git a/driver-opencl.h b/driver-opencl.h
index 1cb8807..878fc3c 100644
--- a/driver-opencl.h
+++ b/driver-opencl.h
@@ -8,6 +8,7 @@ extern void print_ndevs(int *ndevs);
extern void *reinit_gpu(void *userdata);
extern char *set_gpu_map(char *arg);
extern char *set_gpu_engine(char *arg);
+extern char *set_gpu_threads(char *arg);
extern char *set_gpu_fan(char *arg);
extern char *set_gpu_memclock(char *arg);
extern char *set_gpu_memdiff(char *arg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment