Allow temperature targets to be set on a per-card basis on the command line.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
diff --git a/adl.c b/adl.c
index c04b8c6..cf36e2c 100644
--- a/adl.c
+++ b/adl.c
@@ -22,9 +22,9 @@
bool adl_active;
int opt_hysteresis = 3;
-int opt_targettemp = 75;
-int opt_overheattemp = 85;
-int opt_cutofftemp = 95;
+const int opt_targettemp = 75;
+const int opt_overheattemp = 85;
+const int opt_cutofftemp = 95;
static pthread_mutex_t adl_lock;
// Memory allocation function
@@ -321,9 +321,12 @@ void init_adl(int nDevs)
}
/* Set some default temperatures for autotune when enabled */
- ga->targettemp = opt_targettemp;
- ga->overtemp = opt_overheattemp;
- ga->cutofftemp = opt_cutofftemp;
+ if (!ga->targettemp)
+ ga->targettemp = opt_targettemp;
+ if (!ga->overtemp)
+ ga->overtemp = opt_overheattemp;
+ if (!ga->cutofftemp)
+ ga->cutofftemp = opt_cutofftemp;
if (opt_autofan) {
ga->autofan = true;
/* Set a safe starting default if we're automanaging fan speeds */
diff --git a/adl.h b/adl.h
index a86b78c..50bd5b8 100644
--- a/adl.h
+++ b/adl.h
@@ -3,9 +3,9 @@
#ifdef HAVE_ADL
bool adl_active;
int opt_hysteresis;
-int opt_targettemp;
-int opt_overheattemp;
-int opt_cutofftemp;
+const int opt_targettemp;
+const int opt_overheattemp;
+const int opt_cutofftemp;
void init_adl(int nDevs);
float gpu_temp(int gpu);
int gpu_engineclock(int gpu);
diff --git a/main.c b/main.c
index 0ec711b..5dd013e 100644
--- a/main.c
+++ b/main.c
@@ -972,11 +972,6 @@ static char *set_int_0_to_10(const char *arg, int *i)
return set_int_range(arg, i, 0, 10);
}
-static char *set_int_0_to_200(const char *arg, int *i)
-{
- return set_int_range(arg, i, 0, 200);
-}
-
static char *set_int_1_to_10(const char *arg, int *i)
{
return set_int_range(arg, i, 1, 10);
@@ -1278,6 +1273,104 @@ static char *set_gpu_vddc(char *arg)
return NULL;
}
+static char *set_temp_cutoff(char *arg)
+{
+ int i, val = 0, device = 0, *tco;
+ char *nextptr;
+
+ nextptr = strtok(arg, ",");
+ if (nextptr == NULL)
+ return "Invalid parameters for set temp cutoff";
+ val = atoi(nextptr);
+ if (val < 0 || val > 200)
+ return "Invalid value passed to set temp cutoff";
+
+ tco = &gpus[device++].adl.cutofftemp;
+ *tco = val;
+
+ while ((nextptr = strtok(NULL, ",")) != NULL) {
+ val = atoi(nextptr);
+ if (val < 0 || val > 200)
+ return "Invalid value passed to set temp cutoff";
+
+ tco = &gpus[device++].adl.cutofftemp;
+ *tco = val;
+ }
+ if (device == 1) {
+ for (i = device; i < 16; i++) {
+ tco = &gpus[i].adl.cutofftemp;
+ *tco = val;
+ }
+ }
+
+ return NULL;
+}
+
+static 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 < 16; i++) {
+ to = &gpus[i].adl.overtemp;
+ *to = val;
+ }
+ }
+
+ return NULL;
+}
+
+static 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 < 16; i++) {
+ tt = &gpus[i].adl.targettemp;
+ *tt = val;
+ }
+ }
+
+ return NULL;
+}
#endif
/* These options are available from config file or commandline */
@@ -1349,13 +1442,13 @@ static struct opt_table opt_config_table[] = {
"GPU fan percentage range - one value, range and/or comma separated list (e.g. 0-85,85,65)"),
OPT_WITH_ARG("--gpu-memclock",
set_gpu_memclock, NULL, NULL,
- "Set the GPU memory (over)clock in Mhz - one value for all or separate by commas for per card."),
+ "Set the GPU memory (over)clock in Mhz - one value for all or separate by commas for per card"),
OPT_WITH_ARG("--gpu-powertune",
set_gpu_powertune, NULL, NULL,
- "Set the GPU powertune percentage - one value for all or separate by commas for per card."),
+ "Set the GPU powertune percentage - one value for all or separate by commas for per card"),
OPT_WITH_ARG("--gpu-vddc",
set_gpu_vddc, NULL, NULL,
- "Set the GPU voltage in Volts - one value for all or separate by commas for per card."),
+ "Set the GPU voltage in Volts - one value for all or separate by commas for per card"),
#endif
OPT_WITH_ARG("--intensity|-I",
forced_int_1010, NULL, &scan_intensity,
@@ -1443,17 +1536,17 @@ static struct opt_table opt_config_table[] = {
#endif
#ifdef HAVE_ADL
OPT_WITH_ARG("--temp-cutoff",
- set_int_0_to_200, opt_show_intval, &opt_cutofftemp,
- "Set the temperature where a GPU device will be automatically disabled"),
+ set_temp_cutoff, opt_show_intval, &opt_cutofftemp,
+ "Temperature where a GPU device will be automatically disabled, one value or comma separated list"),
OPT_WITH_ARG("--temp-hysteresis",
set_int_1_to_10, opt_show_intval, &opt_hysteresis,
"Set how much the temperature can fluctuate outside limits when automanaging speeds"),
OPT_WITH_ARG("--temp-overheat",
- set_int_0_to_200, opt_show_intval, &opt_overheattemp,
- "Set the overheat temperature when automatically managing fan and GPU speeds"),
+ set_temp_overheat, opt_show_intval, &opt_overheattemp,
+ "Overheat temperature when automatically managing fan and GPU speeds, one value or comma separated list"),
OPT_WITH_ARG("--temp-target",
- set_int_0_to_200, opt_show_intval, &opt_targettemp,
- "Set the target temperature when automatically managing fan and GPU speeds"),
+ set_temp_target, opt_show_intval, &opt_targettemp,
+ "Target temperature when automatically managing fan and GPU speeds, one value or comma separated list"),
#endif
OPT_WITHOUT_ARG("--text-only|-T",
opt_set_invbool, &use_curses,