From 26c59fbf0f399950d843faba5a9a0fb5dc345df6 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 22 Feb 2012 16:59:28 +1100 Subject: [PATCH] Allow the worksize to be set per-device. --- cgminer.c | 6 ++---- device-gpu.c | 30 ++++++++++++++++++++++++++++++ device-gpu.h | 1 + ocl.c | 9 ++++----- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/cgminer.c b/cgminer.c index d0c1e2e2..b5965a0f 100644 --- a/cgminer.c +++ b/cgminer.c @@ -91,8 +91,6 @@ static int opt_fail_pause = 5; static int fail_pause = 5; int opt_log_interval = 5; static int opt_queue = 1; -int opt_vectors; -int opt_worksize; int opt_scantime = 60; int opt_expiry = 120; int opt_bench_algo = -1; @@ -839,8 +837,8 @@ static struct opt_table opt_config_table[] = { "Log verbose output to stderr as well as status output"), #ifdef HAVE_OPENCL OPT_WITH_ARG("--worksize|-w", - set_int_0_to_9999, opt_show_intval, &opt_worksize, - "Override detected optimal worksize"), + set_worksize, NULL, NULL, + "Override detected optimal worksize - one value or comma separated list"), #endif OPT_WITH_ARG("--userpass|-O", set_userpass, NULL, NULL, diff --git a/device-gpu.c b/device-gpu.c index 1c2ad64a..a60e80e8 100644 --- a/device-gpu.c +++ b/device-gpu.c @@ -93,6 +93,36 @@ char *set_vector(char *arg) return NULL; } + +char *set_worksize(char *arg) +{ + int i, val = 0, device = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set work size"; + val = atoi(nextptr); + if (val < 1 || val > 9999) + return "Invalid value passed to set_worksize"; + + gpus[device++].work_size = val; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atoi(nextptr); + if (val < 1 || val > 9999) + return "Invalid value passed to set_worksize"; + + gpus[device++].work_size = val; + } + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) + gpus[i].work_size = gpus[0].work_size; + } + + return NULL; +} + #endif #ifdef HAVE_ADL diff --git a/device-gpu.h b/device-gpu.h index 12af985e..2c8d1e32 100644 --- a/device-gpu.h +++ b/device-gpu.h @@ -16,6 +16,7 @@ extern char *set_temp_overheat(char *arg); extern char *set_temp_target(char *arg); extern char *set_intensity(char *arg); extern char *set_vector(char *arg); +extern char *set_worksize(char *arg); void manage_gpu(void); extern void pause_dynamic_threads(int gpu); diff --git a/ocl.c b/ocl.c index 5869ce4d..54a09d3f 100644 --- a/ocl.c +++ b/ocl.c @@ -33,7 +33,6 @@ #include "findnonce.h" #include "ocl.h" -extern int opt_worksize; int opt_platform_id; char *file_contents(const char *filename, int *length) @@ -349,12 +348,12 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize) else clState->vwidth = preferred_vwidth; - if (opt_worksize && opt_worksize <= (int)clState->max_work_size) - clState->work_size = opt_worksize; + if (gpus[gpu].work_size && gpus[gpu].work_size <= clState->max_work_size) + clState->wsize = gpus[gpu].work_size; else if (strstr(name, "Tahiti")) - clState->work_size = 64; + clState->wsize = 64; else - clState->work_size = (clState->max_work_size <= 256 ? clState->max_work_size : 256) / clState->vwidth; + clState->wsize = (clState->max_work_size <= 256 ? clState->max_work_size : 256) / clState->vwidth; /* Create binary filename based on parameters passed to opencl * compiler to ensure we only load a binary that matches what would