Skip to content
This repository has been archived by the owner on Jan 9, 2021. It is now read-only.

Commit

Permalink
Fix worksize per GPU
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ystarnaud authored and troky committed Nov 16, 2014
1 parent ba9818a commit b53cc15
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
30 changes: 18 additions & 12 deletions driver-opencl.c
Expand Up @@ -91,32 +91,38 @@ char *set_vector(char *arg)
return NULL;
}

char *set_worksize(char *arg)
char *set_worksize(const char *arg)
{
int i, val = 0, device = 0;
char *tmpstr = strdup(arg);
char *nextptr;

nextptr = strtok(arg, ",");
if (nextptr == NULL)
if ((nextptr = strtok(tmpstr, ",")) == NULL) {
free(tmpstr);
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);
if (val < 1 || val > 9999)

if (val < 1 || val > 9999) {
free(tmpstr);
return "Invalid value passed to set_worksize";
}

applog(LOG_DEBUG, "GPU %d Worksize set to %u.", device, 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) {
for (i = device; i < MAX_GPUDEVICES; i++)
for (i = device; i < total_devices; ++i) {
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;
}

Expand Down
2 changes: 1 addition & 1 deletion driver-opencl.h
Expand Up @@ -20,7 +20,7 @@ extern char *set_intensity(const char *arg);
extern char *set_xintensity(const char *arg);
extern char *set_rawintensity(const 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_lookup_gap(char *arg);
extern char *set_thread_concurrency(const char *arg);
Expand Down
4 changes: 2 additions & 2 deletions sgminer.c
Expand Up @@ -6015,7 +6015,7 @@ static void apply_initial_gpu_settings(struct pool *pool)

//worksize
if(!empty_string((opt = get_pool_setting(pool->worksize, default_profile.worksize))))
set_worksize((char *)opt);
set_worksize(opt);

//apply algorithm
for (i = 0; i < nDevs; i++)
Expand Down Expand Up @@ -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(!empty_string((opt = get_pool_setting(work->pool->worksize, default_profile.worksize))))
set_worksize((char *)opt);
set_worksize(opt);
}

#ifdef HAVE_ADL
Expand Down

0 comments on commit b53cc15

Please sign in to comment.