From 31123de410c994fcb311709c30574da06da438a9 Mon Sep 17 00:00:00 2001 From: Martin Danielsen Date: Thu, 9 Jan 2014 22:01:08 +0100 Subject: [PATCH] -g or --gpu-threads now support comma separated values, yaaay! It is exactly what it says, now you can finally put that Frankenrig configuration in one file. The parameter follows the same design as gpu-engine and gpu-memclock. --- cgminer.c | 6 +++++- driver-opencl.c | 34 ++++++++++++++++++++++++++++++++++ driver-opencl.h | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/cgminer.c b/cgminer.c index 28be4b70..df39b97e 100644 --- a/cgminer.c +++ b/cgminer.c @@ -1029,10 +1029,14 @@ 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"), +#ifndef HAVE_ADL OPT_WITH_ARG("--gpu-threads|-g", set_int_1_to_10, opt_show_intval, &opt_g_threads, "Number of threads per GPU (1 - 10)"), -#ifdef HAVE_ADL +#else + OPT_WITH_ARG("--gpu-threads|-g", + set_gpu_threads, NULL, NULL, + "Number of threads per GPU - one value or comma separated list (e.g. 1,2,1)"), OPT_WITH_ARG("--gpu-engine", set_gpu_engine, NULL, NULL, "GPU engine (over)clock range in Mhz - one value, range and/or comma separated list (e.g. 850-900,900,750-850)"), diff --git a/driver-opencl.c b/driver-opencl.c index a0ccbaa1..1854d110 100644 --- a/driver-opencl.c +++ b/driver-opencl.c @@ -266,6 +266,35 @@ char *set_gpu_map(char *arg) return NULL; } +char *set_gpu_threads(char *arg) +{ + int i, val = 1, 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; @@ -1007,7 +1036,12 @@ static void opencl_detect(bool hotplug) cgpu->deven = DEV_ENABLED; cgpu->drv = &opencl_drv; cgpu->device_id = i; +#ifndef HAVE_ADL cgpu->threads = opt_g_threads; +#else + if (cgpu->threads < 1) + cgpu->threads = 1; +#endif cgpu->virtual_gpu = i; add_cgpu(cgpu); } diff --git a/driver-opencl.h b/driver-opencl.h index 330828b6..2120135f 100644 --- a/driver-opencl.h +++ b/driver-opencl.h @@ -7,6 +7,7 @@ extern void print_ndevs(int *ndevs); extern void *reinit_gpu(void *userdata); extern char *set_gpu_map(char *arg); +extern char *set_gpu_threads(char *arg); extern char *set_gpu_engine(char *arg); extern char *set_gpu_fan(char *arg); extern char *set_gpu_memclock(char *arg);