From 842fbcce3579d37d15cba78fb80fd6750e226e93 Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Wed, 16 Apr 2014 18:22:58 +0300 Subject: [PATCH] config: move option-setting functions from driver-opencl.c to configuration.c NOTE: No "static" added, declarations not put in configuration.h --- configuration.c | 617 ++++++++++++++++++++++++++++++++++++++++++++++++ driver-opencl.c | 616 ----------------------------------------------- 2 files changed, 617 insertions(+), 616 deletions(-) diff --git a/configuration.c b/configuration.c index af44c4fe..7efd4b77 100644 --- a/configuration.c +++ b/configuration.c @@ -885,6 +885,623 @@ char *display_devs(int *ndevs) exit(*ndevs); } +char *set_vector(char *arg) +{ + int i, val = 0, device = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set vector"; + val = atoi(nextptr); + if (val != 1 && val != 2 && val != 4) + return "Invalid value passed to set_vector"; + + gpus[device++].vwidth = val; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atoi(nextptr); + if (val != 1 && val != 2 && val != 4) + return "Invalid value passed to set_vector"; + + gpus[device++].vwidth = val; + } + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) + gpus[i].vwidth = gpus[0].vwidth; + } + + 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; +} + +char *set_shaders(char *arg) +{ + int i, val = 0, device = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set lookup gap"; + val = atoi(nextptr); + + gpus[device++].shaders = val; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atoi(nextptr); + + gpus[device++].shaders = val; + } + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) + gpus[i].shaders = gpus[0].shaders; + } + + return NULL; +} + +char *set_lookup_gap(char *arg) +{ + int i, val = 0, device = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set lookup gap"; + val = atoi(nextptr); + + gpus[device++].opt_lg = val; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atoi(nextptr); + + gpus[device++].opt_lg = val; + } + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) + gpus[i].opt_lg = gpus[0].opt_lg; + } + + return NULL; +} + +char *set_thread_concurrency(char *arg) +{ + int i, val = 0, device = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set thread concurrency"; + val = atoi(nextptr); + + gpus[device++].opt_tc = val; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atoi(nextptr); + + gpus[device++].opt_tc = val; + } + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) + gpus[i].opt_tc = gpus[0].opt_tc; + } + + return NULL; +} + +char *set_kernel(char *arg) +{ + char *nextptr; + int i, device = 0; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set kernel"; + + if (gpus[device].kernelname != NULL) + free(gpus[device].kernelname); + gpus[device].kernelname = strdup(nextptr); + device++; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + if (gpus[device].kernelname != NULL) + free(gpus[device].kernelname); + gpus[device].kernelname = strdup(nextptr); + device++; + } + + /* If only one kernel name provided, use same for all GPUs. */ + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) { + if (gpus[i].kernelname != NULL) + free(gpus[i].kernelname); + gpus[i].kernelname = strdup(gpus[0].kernelname); + } + } + + return NULL; +} + +#ifdef HAVE_ADL +/* This function allows us to map an adl device to an opencl device for when + * simple enumeration has failed to match them. */ +char *set_gpu_map(char *arg) +{ + int val1 = 0, val2 = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set gpu map"; + if (sscanf(arg, "%d:%d", &val1, &val2) != 2) + return "Invalid description for map pair"; + if (val1 < 0 || val1 > MAX_GPUDEVICES || val2 < 0 || val2 > MAX_GPUDEVICES) + return "Invalid value passed to set_gpu_map"; + + gpus[val1].virtual_adl = val2; + gpus[val1].mapped = true; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + if (sscanf(nextptr, "%d:%d", &val1, &val2) != 2) + return "Invalid description for map pair"; + if (val1 < 0 || val1 > MAX_GPUDEVICES || val2 < 0 || val2 > MAX_GPUDEVICES) + return "Invalid value passed to set_gpu_map"; + gpus[val1].virtual_adl = val2; + gpus[val1].mapped = true; + } + + 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; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set gpu engine"; + get_intrange(nextptr, &val1, &val2); + if (val1 < 0 || val1 > 9999 || val2 < 0 || val2 > 9999) + return "Invalid value passed to set_gpu_engine"; + + gpus[device].min_engine = val1; + gpus[device].gpu_engine = val2; + device++; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + get_intrange(nextptr, &val1, &val2); + if (val1 < 0 || val1 > 9999 || val2 < 0 || val2 > 9999) + return "Invalid value passed to set_gpu_engine"; + gpus[device].min_engine = val1; + gpus[device].gpu_engine = val2; + device++; + } + + if (device == 1) { + for (i = 1; i < MAX_GPUDEVICES; i++) { + gpus[i].min_engine = gpus[0].min_engine; + gpus[i].gpu_engine = gpus[0].gpu_engine; + } + } + + return NULL; +} + +char *set_gpu_fan(char *arg) +{ + int i, val1 = 0, val2 = 0, device = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set gpu fan"; + get_intrange(nextptr, &val1, &val2); + if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100) + return "Invalid value passed to set_gpu_fan"; + + gpus[device].min_fan = val1; + gpus[device].gpu_fan = val2; + device++; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + get_intrange(nextptr, &val1, &val2); + if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100) + return "Invalid value passed to set_gpu_fan"; + + gpus[device].min_fan = val1; + gpus[device].gpu_fan = val2; + device++; + } + + if (device == 1) { + for (i = 1; i < MAX_GPUDEVICES; i++) { + gpus[i].min_fan = gpus[0].min_fan; + gpus[i].gpu_fan = gpus[0].gpu_fan; + } + } + + return NULL; +} + +char *set_gpu_memclock(char *arg) +{ + int i, val = 0, device = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set gpu memclock"; + val = atoi(nextptr); + if (val < 0 || val >= 9999) + return "Invalid value passed to set_gpu_memclock"; + + gpus[device++].gpu_memclock = val; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atoi(nextptr); + if (val < 0 || val >= 9999) + return "Invalid value passed to set_gpu_memclock"; + + gpus[device++].gpu_memclock = val; + } + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) + gpus[i].gpu_memclock = gpus[0].gpu_memclock; + } + + return NULL; +} + +char *set_gpu_memdiff(char *arg) +{ + int i, val = 0, device = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set gpu memdiff"; + val = atoi(nextptr); + if (val < -9999 || val > 9999) + return "Invalid value passed to set_gpu_memdiff"; + + gpus[device++].gpu_memdiff = val; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atoi(nextptr); + if (val < -9999 || val > 9999) + return "Invalid value passed to set_gpu_memdiff"; + + gpus[device++].gpu_memdiff = val; + } + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) + gpus[i].gpu_memdiff = gpus[0].gpu_memdiff; + } + + return NULL; +} + +char *set_gpu_powertune(char *arg) +{ + int i, val = 0, device = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set gpu powertune"; + val = atoi(nextptr); + if (val < -99 || val > 99) + return "Invalid value passed to set_gpu_powertune"; + + gpus[device++].gpu_powertune = val; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atoi(nextptr); + if (val < -99 || val > 99) + return "Invalid value passed to set_gpu_powertune"; + + gpus[device++].gpu_powertune = val; + } + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) + gpus[i].gpu_powertune = gpus[0].gpu_powertune; + } + + return NULL; +} + +char *set_gpu_vddc(char *arg) +{ + int i, device = 0; + float val = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set gpu vddc"; + val = atof(nextptr); + if (val < 0 || val >= 9999) + return "Invalid value passed to set_gpu_vddc"; + + gpus[device++].gpu_vddc = val; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atof(nextptr); + if (val < 0 || val >= 9999) + return "Invalid value passed to set_gpu_vddc"; + + gpus[device++].gpu_vddc = val; + } + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) + gpus[i].gpu_vddc = gpus[0].gpu_vddc; + } + + return NULL; +} + +char *set_temp_overheat(char *arg) +{ + int i, val = 0, device = 0, *to; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set temp overheat"; + val = atoi(nextptr); + if (val < 0 || val > 200) + return "Invalid value passed to set temp overheat"; + + to = &gpus[device++].adl.overtemp; + *to = val; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atoi(nextptr); + if (val < 0 || val > 200) + return "Invalid value passed to set temp overheat"; + + to = &gpus[device++].adl.overtemp; + *to = val; + } + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) { + to = &gpus[i].adl.overtemp; + *to = val; + } + } + + return NULL; +} + +char *set_temp_target(char *arg) +{ + int i, val = 0, device = 0, *tt; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set temp target"; + val = atoi(nextptr); + if (val < 0 || val > 200) + return "Invalid value passed to set temp target"; + + tt = &gpus[device++].adl.targettemp; + *tt = val; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atoi(nextptr); + if (val < 0 || val > 200) + return "Invalid value passed to set temp target"; + + tt = &gpus[device++].adl.targettemp; + *tt = val; + } + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) { + tt = &gpus[i].adl.targettemp; + *tt = val; + } + } + + return NULL; +} +#endif + +char *set_intensity(char *arg) +{ + int i, device = 0, *tt; + char *nextptr, val = 0; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for set intensity"; + if (!strncasecmp(nextptr, "d", 1)) + gpus[device].dynamic = true; + else { + gpus[device].dynamic = false; + val = atoi(nextptr); + if (val == 0) return "disabled"; + if (val < MIN_INTENSITY || val > MAX_INTENSITY) + return "Invalid value passed to set intensity"; + tt = &gpus[device].intensity; + *tt = val; + gpus[device].xintensity = 0; // Disable shader based intensity + gpus[device].rawintensity = 0; // Disable raw intensity + } + + device++; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + if (!strncasecmp(nextptr, "d", 1)) + gpus[device].dynamic = true; + else { + gpus[device].dynamic = false; + val = atoi(nextptr); + if (val == 0) return "disabled"; + if (val < MIN_INTENSITY || val > MAX_INTENSITY) + return "Invalid value passed to set intensity"; + + tt = &gpus[device].intensity; + *tt = val; + gpus[device].xintensity = 0; // Disable shader based intensity + gpus[device].rawintensity = 0; // Disable raw intensity + } + device++; + } + if (device == 1) { + for (i = device; i < MAX_GPUDEVICES; i++) { + gpus[i].dynamic = gpus[0].dynamic; + gpus[i].intensity = gpus[0].intensity; + gpus[i].xintensity = 0; // Disable shader based intensity + gpus[i].rawintensity = 0; // Disable raw intensity + } + } + + return NULL; +} + +char *set_xintensity(char *arg) +{ + int i, device = 0, val = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for shader based intensity"; + val = atoi(nextptr); + if (val == 0) return "disabled"; + if (val < MIN_XINTENSITY || val > MAX_XINTENSITY) + return "Invalid value passed to set shader-based intensity"; + + gpus[device].dynamic = false; // Disable dynamic intensity + gpus[device].intensity = 0; // Disable regular intensity + gpus[device].rawintensity = 0; // Disable raw intensity + gpus[device].xintensity = val; + device++; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atoi(nextptr); + if (val == 0) return "disabled"; + if (val < MIN_XINTENSITY || val > MAX_XINTENSITY) + return "Invalid value passed to set shader based intensity"; + gpus[device].dynamic = false; // Disable dynamic intensity + gpus[device].intensity = 0; // Disable regular intensity + gpus[device].rawintensity = 0; // Disable raw intensity + gpus[device].xintensity = val; + device++; + } + if (device == 1) + for (i = device; i < MAX_GPUDEVICES; i++) { + gpus[i].dynamic = gpus[0].dynamic; + gpus[i].intensity = gpus[0].intensity; + gpus[i].rawintensity = gpus[0].rawintensity; + gpus[i].xintensity = gpus[0].xintensity; + } + + return NULL; +} + +char *set_rawintensity(char *arg) +{ + int i, device = 0, val = 0; + char *nextptr; + + nextptr = strtok(arg, ","); + if (nextptr == NULL) + return "Invalid parameters for raw intensity"; + val = atoi(nextptr); + if (val == 0) return "disabled"; + if (val < MIN_RAWINTENSITY || val > MAX_RAWINTENSITY) + return "Invalid value passed to set raw intensity"; + + gpus[device].dynamic = false; // Disable dynamic intensity + gpus[device].intensity = 0; // Disable regular intensity + gpus[device].xintensity = 0; // Disable xintensity + gpus[device].rawintensity = val; + device++; + + while ((nextptr = strtok(NULL, ",")) != NULL) { + val = atoi(nextptr); + if (val == 0) return "disabled"; + if (val < MIN_RAWINTENSITY || val > MAX_RAWINTENSITY) + return "Invalid value passed to set raw intensity"; + gpus[device].dynamic = false; // Disable dynamic intensity + gpus[device].intensity = 0; // Disable regular intensity + gpus[device].xintensity = 0; // Disable xintensity + gpus[device].rawintensity = val; + device++; + } + if (device == 1) + for (i = device; i < MAX_GPUDEVICES; i++) { + gpus[i].dynamic = gpus[0].dynamic; + gpus[i].intensity = gpus[0].intensity; + gpus[i].rawintensity = gpus[0].rawintensity; + gpus[i].xintensity = gpus[0].xintensity; + } + + return NULL; +} + + /* These options are available from config file or commandline */ static struct opt_table opt_config_table[] = { OPT_WITH_ARG("--algorithm", diff --git a/driver-opencl.c b/driver-opencl.c index 93a46d93..c9f62d4c 100644 --- a/driver-opencl.c +++ b/driver-opencl.c @@ -61,622 +61,6 @@ extern int gpu_fanspeed(int gpu); extern int gpu_fanpercent(int gpu); #endif -char *set_vector(char *arg) -{ - int i, val = 0, device = 0; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set vector"; - val = atoi(nextptr); - if (val != 1 && val != 2 && val != 4) - return "Invalid value passed to set_vector"; - - gpus[device++].vwidth = val; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atoi(nextptr); - if (val != 1 && val != 2 && val != 4) - return "Invalid value passed to set_vector"; - - gpus[device++].vwidth = val; - } - if (device == 1) { - for (i = device; i < MAX_GPUDEVICES; i++) - gpus[i].vwidth = gpus[0].vwidth; - } - - 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; -} - -char *set_shaders(char *arg) -{ - int i, val = 0, device = 0; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set lookup gap"; - val = atoi(nextptr); - - gpus[device++].shaders = val; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atoi(nextptr); - - gpus[device++].shaders = val; - } - if (device == 1) { - for (i = device; i < MAX_GPUDEVICES; i++) - gpus[i].shaders = gpus[0].shaders; - } - - return NULL; -} - -char *set_lookup_gap(char *arg) -{ - int i, val = 0, device = 0; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set lookup gap"; - val = atoi(nextptr); - - gpus[device++].opt_lg = val; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atoi(nextptr); - - gpus[device++].opt_lg = val; - } - if (device == 1) { - for (i = device; i < MAX_GPUDEVICES; i++) - gpus[i].opt_lg = gpus[0].opt_lg; - } - - return NULL; -} - -char *set_thread_concurrency(char *arg) -{ - int i, val = 0, device = 0; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set thread concurrency"; - val = atoi(nextptr); - - gpus[device++].opt_tc = val; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atoi(nextptr); - - gpus[device++].opt_tc = val; - } - if (device == 1) { - for (i = device; i < MAX_GPUDEVICES; i++) - gpus[i].opt_tc = gpus[0].opt_tc; - } - - return NULL; -} - -char *set_kernel(char *arg) -{ - char *nextptr; - int i, device = 0; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set kernel"; - - if (gpus[device].kernelname != NULL) - free(gpus[device].kernelname); - gpus[device].kernelname = strdup(nextptr); - device++; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - if (gpus[device].kernelname != NULL) - free(gpus[device].kernelname); - gpus[device].kernelname = strdup(nextptr); - device++; - } - - /* If only one kernel name provided, use same for all GPUs. */ - if (device == 1) { - for (i = device; i < MAX_GPUDEVICES; i++) { - if (gpus[i].kernelname != NULL) - free(gpus[i].kernelname); - gpus[i].kernelname = strdup(gpus[0].kernelname); - } - } - - return NULL; -} - -#ifdef HAVE_ADL -/* This function allows us to map an adl device to an opencl device for when - * simple enumeration has failed to match them. */ -char *set_gpu_map(char *arg) -{ - int val1 = 0, val2 = 0; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set gpu map"; - if (sscanf(arg, "%d:%d", &val1, &val2) != 2) - return "Invalid description for map pair"; - if (val1 < 0 || val1 > MAX_GPUDEVICES || val2 < 0 || val2 > MAX_GPUDEVICES) - return "Invalid value passed to set_gpu_map"; - - gpus[val1].virtual_adl = val2; - gpus[val1].mapped = true; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - if (sscanf(nextptr, "%d:%d", &val1, &val2) != 2) - return "Invalid description for map pair"; - if (val1 < 0 || val1 > MAX_GPUDEVICES || val2 < 0 || val2 > MAX_GPUDEVICES) - return "Invalid value passed to set_gpu_map"; - gpus[val1].virtual_adl = val2; - gpus[val1].mapped = true; - } - - 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; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set gpu engine"; - get_intrange(nextptr, &val1, &val2); - if (val1 < 0 || val1 > 9999 || val2 < 0 || val2 > 9999) - return "Invalid value passed to set_gpu_engine"; - - gpus[device].min_engine = val1; - gpus[device].gpu_engine = val2; - device++; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - get_intrange(nextptr, &val1, &val2); - if (val1 < 0 || val1 > 9999 || val2 < 0 || val2 > 9999) - return "Invalid value passed to set_gpu_engine"; - gpus[device].min_engine = val1; - gpus[device].gpu_engine = val2; - device++; - } - - if (device == 1) { - for (i = 1; i < MAX_GPUDEVICES; i++) { - gpus[i].min_engine = gpus[0].min_engine; - gpus[i].gpu_engine = gpus[0].gpu_engine; - } - } - - return NULL; -} - -char *set_gpu_fan(char *arg) -{ - int i, val1 = 0, val2 = 0, device = 0; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set gpu fan"; - get_intrange(nextptr, &val1, &val2); - if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100) - return "Invalid value passed to set_gpu_fan"; - - gpus[device].min_fan = val1; - gpus[device].gpu_fan = val2; - device++; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - get_intrange(nextptr, &val1, &val2); - if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100) - return "Invalid value passed to set_gpu_fan"; - - gpus[device].min_fan = val1; - gpus[device].gpu_fan = val2; - device++; - } - - if (device == 1) { - for (i = 1; i < MAX_GPUDEVICES; i++) { - gpus[i].min_fan = gpus[0].min_fan; - gpus[i].gpu_fan = gpus[0].gpu_fan; - } - } - - return NULL; -} - -char *set_gpu_memclock(char *arg) -{ - int i, val = 0, device = 0; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set gpu memclock"; - val = atoi(nextptr); - if (val < 0 || val >= 9999) - return "Invalid value passed to set_gpu_memclock"; - - gpus[device++].gpu_memclock = val; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atoi(nextptr); - if (val < 0 || val >= 9999) - return "Invalid value passed to set_gpu_memclock"; - - gpus[device++].gpu_memclock = val; - } - if (device == 1) { - for (i = device; i < MAX_GPUDEVICES; i++) - gpus[i].gpu_memclock = gpus[0].gpu_memclock; - } - - return NULL; -} - -char *set_gpu_memdiff(char *arg) -{ - int i, val = 0, device = 0; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set gpu memdiff"; - val = atoi(nextptr); - if (val < -9999 || val > 9999) - return "Invalid value passed to set_gpu_memdiff"; - - gpus[device++].gpu_memdiff = val; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atoi(nextptr); - if (val < -9999 || val > 9999) - return "Invalid value passed to set_gpu_memdiff"; - - gpus[device++].gpu_memdiff = val; - } - if (device == 1) { - for (i = device; i < MAX_GPUDEVICES; i++) - gpus[i].gpu_memdiff = gpus[0].gpu_memdiff; - } - - return NULL; -} - -char *set_gpu_powertune(char *arg) -{ - int i, val = 0, device = 0; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set gpu powertune"; - val = atoi(nextptr); - if (val < -99 || val > 99) - return "Invalid value passed to set_gpu_powertune"; - - gpus[device++].gpu_powertune = val; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atoi(nextptr); - if (val < -99 || val > 99) - return "Invalid value passed to set_gpu_powertune"; - - gpus[device++].gpu_powertune = val; - } - if (device == 1) { - for (i = device; i < MAX_GPUDEVICES; i++) - gpus[i].gpu_powertune = gpus[0].gpu_powertune; - } - - return NULL; -} - -char *set_gpu_vddc(char *arg) -{ - int i, device = 0; - float val = 0; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set gpu vddc"; - val = atof(nextptr); - if (val < 0 || val >= 9999) - return "Invalid value passed to set_gpu_vddc"; - - gpus[device++].gpu_vddc = val; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atof(nextptr); - if (val < 0 || val >= 9999) - return "Invalid value passed to set_gpu_vddc"; - - gpus[device++].gpu_vddc = val; - } - if (device == 1) { - for (i = device; i < MAX_GPUDEVICES; i++) - gpus[i].gpu_vddc = gpus[0].gpu_vddc; - } - - return NULL; -} - -char *set_temp_overheat(char *arg) -{ - int i, val = 0, device = 0, *to; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set temp overheat"; - val = atoi(nextptr); - if (val < 0 || val > 200) - return "Invalid value passed to set temp overheat"; - - to = &gpus[device++].adl.overtemp; - *to = val; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atoi(nextptr); - if (val < 0 || val > 200) - return "Invalid value passed to set temp overheat"; - - to = &gpus[device++].adl.overtemp; - *to = val; - } - if (device == 1) { - for (i = device; i < MAX_GPUDEVICES; i++) { - to = &gpus[i].adl.overtemp; - *to = val; - } - } - - return NULL; -} - -char *set_temp_target(char *arg) -{ - int i, val = 0, device = 0, *tt; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set temp target"; - val = atoi(nextptr); - if (val < 0 || val > 200) - return "Invalid value passed to set temp target"; - - tt = &gpus[device++].adl.targettemp; - *tt = val; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atoi(nextptr); - if (val < 0 || val > 200) - return "Invalid value passed to set temp target"; - - tt = &gpus[device++].adl.targettemp; - *tt = val; - } - if (device == 1) { - for (i = device; i < MAX_GPUDEVICES; i++) { - tt = &gpus[i].adl.targettemp; - *tt = val; - } - } - - return NULL; -} -#endif - -char *set_intensity(char *arg) -{ - int i, device = 0, *tt; - char *nextptr, val = 0; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for set intensity"; - if (!strncasecmp(nextptr, "d", 1)) - gpus[device].dynamic = true; - else { - gpus[device].dynamic = false; - val = atoi(nextptr); - if (val == 0) return "disabled"; - if (val < MIN_INTENSITY || val > MAX_INTENSITY) - return "Invalid value passed to set intensity"; - tt = &gpus[device].intensity; - *tt = val; - gpus[device].xintensity = 0; // Disable shader based intensity - gpus[device].rawintensity = 0; // Disable raw intensity - } - - device++; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - if (!strncasecmp(nextptr, "d", 1)) - gpus[device].dynamic = true; - else { - gpus[device].dynamic = false; - val = atoi(nextptr); - if (val == 0) return "disabled"; - if (val < MIN_INTENSITY || val > MAX_INTENSITY) - return "Invalid value passed to set intensity"; - - tt = &gpus[device].intensity; - *tt = val; - gpus[device].xintensity = 0; // Disable shader based intensity - gpus[device].rawintensity = 0; // Disable raw intensity - } - device++; - } - if (device == 1) { - for (i = device; i < MAX_GPUDEVICES; i++) { - gpus[i].dynamic = gpus[0].dynamic; - gpus[i].intensity = gpus[0].intensity; - gpus[i].xintensity = 0; // Disable shader based intensity - gpus[i].rawintensity = 0; // Disable raw intensity - } - } - - return NULL; -} - -char *set_xintensity(char *arg) -{ - int i, device = 0, val = 0; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for shader based intensity"; - val = atoi(nextptr); - if (val == 0) return "disabled"; - if (val < MIN_XINTENSITY || val > MAX_XINTENSITY) - return "Invalid value passed to set shader-based intensity"; - - gpus[device].dynamic = false; // Disable dynamic intensity - gpus[device].intensity = 0; // Disable regular intensity - gpus[device].rawintensity = 0; // Disable raw intensity - gpus[device].xintensity = val; - device++; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atoi(nextptr); - if (val == 0) return "disabled"; - if (val < MIN_XINTENSITY || val > MAX_XINTENSITY) - return "Invalid value passed to set shader based intensity"; - gpus[device].dynamic = false; // Disable dynamic intensity - gpus[device].intensity = 0; // Disable regular intensity - gpus[device].rawintensity = 0; // Disable raw intensity - gpus[device].xintensity = val; - device++; - } - if (device == 1) - for (i = device; i < MAX_GPUDEVICES; i++) { - gpus[i].dynamic = gpus[0].dynamic; - gpus[i].intensity = gpus[0].intensity; - gpus[i].rawintensity = gpus[0].rawintensity; - gpus[i].xintensity = gpus[0].xintensity; - } - - return NULL; -} - -char *set_rawintensity(char *arg) -{ - int i, device = 0, val = 0; - char *nextptr; - - nextptr = strtok(arg, ","); - if (nextptr == NULL) - return "Invalid parameters for raw intensity"; - val = atoi(nextptr); - if (val == 0) return "disabled"; - if (val < MIN_RAWINTENSITY || val > MAX_RAWINTENSITY) - return "Invalid value passed to set raw intensity"; - - gpus[device].dynamic = false; // Disable dynamic intensity - gpus[device].intensity = 0; // Disable regular intensity - gpus[device].xintensity = 0; // Disable xintensity - gpus[device].rawintensity = val; - device++; - - while ((nextptr = strtok(NULL, ",")) != NULL) { - val = atoi(nextptr); - if (val == 0) return "disabled"; - if (val < MIN_RAWINTENSITY || val > MAX_RAWINTENSITY) - return "Invalid value passed to set raw intensity"; - gpus[device].dynamic = false; // Disable dynamic intensity - gpus[device].intensity = 0; // Disable regular intensity - gpus[device].xintensity = 0; // Disable xintensity - gpus[device].rawintensity = val; - device++; - } - if (device == 1) - for (i = device; i < MAX_GPUDEVICES; i++) { - gpus[i].dynamic = gpus[0].dynamic; - gpus[i].intensity = gpus[0].intensity; - gpus[i].rawintensity = gpus[0].rawintensity; - gpus[i].xintensity = gpus[0].xintensity; - } - - return NULL; -} - void print_ndevs(int *ndevs) { opt_log_output = true;