Browse Source

Fix worksize per GPU

Improper use of strtok() on the original config string instead of a copy
resulted in the worksize being cut down to GPU0's worksize only after
first use.
djm34
ystarnaud 10 years ago committed by troky
parent
commit
b53cc151aa
  1. 30
      driver-opencl.c
  2. 2
      driver-opencl.h
  3. 4
      sgminer.c

30
driver-opencl.c

@ -91,32 +91,38 @@ char *set_vector(char *arg)
return NULL; return NULL;
} }
char *set_worksize(char *arg) char *set_worksize(const char *arg)
{ {
int i, val = 0, device = 0; int i, val = 0, device = 0;
char *tmpstr = strdup(arg);
char *nextptr; char *nextptr;
nextptr = strtok(arg, ","); if ((nextptr = strtok(tmpstr, ",")) == NULL) {
if (nextptr == NULL) free(tmpstr);
return "Invalid parameters for set work size"; 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) { do {
val = atoi(nextptr); val = atoi(nextptr);
if (val < 1 || val > 9999)
if (val < 1 || val > 9999) {
free(tmpstr);
return "Invalid value passed to set_worksize"; return "Invalid value passed to set_worksize";
}
applog(LOG_DEBUG, "GPU %d Worksize set to %u.", device, val);
gpus[device++].work_size = val; gpus[device++].work_size = val;
} } while ((nextptr = strtok(NULL, ",")) != NULL);
// if only 1 worksize was passed, assign the same worksize for all remaining GPUs
if (device == 1) { if (device == 1) {
for (i = device; i < MAX_GPUDEVICES; i++) for (i = device; i < total_devices; ++i) {
gpus[i].work_size = gpus[0].work_size; gpus[i].work_size = gpus[0].work_size;
applog(LOG_DEBUG, "GPU %d Worksize set to %u.", i, gpus[i].work_size);
}
} }
free(tmpstr);
return NULL; return NULL;
} }

2
driver-opencl.h

@ -20,7 +20,7 @@ extern char *set_intensity(const char *arg);
extern char *set_xintensity(const char *arg); extern char *set_xintensity(const char *arg);
extern char *set_rawintensity(const char *arg); extern char *set_rawintensity(const char *arg);
extern char *set_vector(char *arg); extern char *set_vector(char *arg);
extern char *set_worksize(char *arg); extern char *set_worksize(const char *arg);
extern char *set_shaders(char *arg); extern char *set_shaders(char *arg);
extern char *set_lookup_gap(char *arg); extern char *set_lookup_gap(char *arg);
extern char *set_thread_concurrency(const char *arg); extern char *set_thread_concurrency(const char *arg);

4
sgminer.c

@ -6015,7 +6015,7 @@ static void apply_initial_gpu_settings(struct pool *pool)
//worksize //worksize
if(!empty_string((opt = get_pool_setting(pool->worksize, default_profile.worksize)))) if(!empty_string((opt = get_pool_setting(pool->worksize, default_profile.worksize))))
set_worksize((char *)opt); set_worksize(opt);
//apply algorithm //apply algorithm
for (i = 0; i < nDevs; i++) for (i = 0; i < nDevs; i++)
@ -6415,7 +6415,7 @@ static void get_work_prepare_thread(struct thr_info *mythr, struct work *work)
if(opt_isset(pool_switch_options, SWITCHER_APPLY_WORKSIZE)) if(opt_isset(pool_switch_options, SWITCHER_APPLY_WORKSIZE))
{ {
if(!empty_string((opt = get_pool_setting(work->pool->worksize, default_profile.worksize)))) if(!empty_string((opt = get_pool_setting(work->pool->worksize, default_profile.worksize))))
set_worksize((char *)opt); set_worksize(opt);
} }
#ifdef HAVE_ADL #ifdef HAVE_ADL

Loading…
Cancel
Save