Only display values in the log if they're supported and standardise device log line printing.
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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
diff --git a/adl.c b/adl.c
index 4f21444..0a2afc3 100644
--- a/adl.c
+++ b/adl.c
@@ -342,14 +342,14 @@ void init_adl(int nDevs)
static inline float __gpu_temp(struct gpu_adl *ga)
{
if (ADL_Overdrive5_Temperature_Get(ga->iAdapterIndex, 0, &ga->lpTemperature) != ADL_OK)
- return 0;
+ return -1;
return (float)ga->lpTemperature.iTemperature / 1000;
}
float gpu_temp(int gpu)
{
struct gpu_adl *ga;
- float ret = 0;
+ float ret = -1;
if (!gpus[gpu].has_adl || !adl_active)
return ret;
@@ -369,7 +369,7 @@ static inline int __gpu_engineclock(struct gpu_adl *ga)
int gpu_engineclock(int gpu)
{
struct gpu_adl *ga;
- int ret = 0;
+ int ret = -1;
if (!gpus[gpu].has_adl || !adl_active)
return ret;
@@ -392,7 +392,7 @@ static inline int __gpu_memclock(struct gpu_adl *ga)
int gpu_memclock(int gpu)
{
struct gpu_adl *ga;
- int ret = 0;
+ int ret = -1;
if (!gpus[gpu].has_adl || !adl_active)
return ret;
@@ -415,7 +415,7 @@ static inline float __gpu_vddc(struct gpu_adl *ga)
float gpu_vddc(int gpu)
{
struct gpu_adl *ga;
- float ret = 0;
+ float ret = -1;
if (!gpus[gpu].has_adl || !adl_active)
return ret;
@@ -433,43 +433,43 @@ out:
static inline int __gpu_activity(struct gpu_adl *ga)
{
if (!ga->lpOdParameters.iActivityReportingSupported)
- return 0;
+ return -1;
return ga->lpActivity.iActivityPercent;
}
int gpu_activity(int gpu)
{
struct gpu_adl *ga;
- int ret;
+ int ret = -1;
if (!gpus[gpu].has_adl || !adl_active)
- return 0;
+ return ret;
ga = &gpus[gpu].adl;
lock_adl();
ret = ADL_Overdrive5_CurrentActivity_Get(ga->iAdapterIndex, &ga->lpActivity);
unlock_adl();
if (ret != ADL_OK)
- return 0;
+ return ret;
if (!ga->lpOdParameters.iActivityReportingSupported)
- return 0;
+ return ret;
return ga->lpActivity.iActivityPercent;
}
static inline int __gpu_fanspeed(struct gpu_adl *ga)
{
if (!(ga->lpFanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_RPM_READ))
- return 0;
+ return -1;
ga->lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_RPM;
if (ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue) != ADL_OK)
- return 0;
+ return -1;
return ga->lpFanSpeedValue.iFanSpeed;
}
int gpu_fanspeed(int gpu)
{
struct gpu_adl *ga;
- int ret = 0;
+ int ret = -1;
if (!gpus[gpu].has_adl || !adl_active)
return ret;
@@ -494,10 +494,10 @@ static inline int __gpu_fanpercent(struct gpu_adl *ga)
int gpu_fanpercent(int gpu)
{
struct gpu_adl *ga;
- int ret = 0;
+ int ret = -1;
if (!gpus[gpu].has_adl || !adl_active)
- return -1;
+ return ret;
ga = &gpus[gpu].adl;
lock_adl();
@@ -511,7 +511,7 @@ static inline int __gpu_powertune(struct gpu_adl *ga)
int dummy = 0;
if (ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy) != ADL_OK)
- return 0;
+ return -1;
return ga->iPercentage;
}
diff --git a/main.c b/main.c
index feb093d..8645483 100644
--- a/main.c
+++ b/main.c
@@ -1801,26 +1801,49 @@ static bool curses_active_locked(void)
return ret;
}
-static void text_print_status(int thr_id)
+static void tailsprintf(char *f, const char *fmt, ...)
{
- struct cgpu_info *cgpu = thr_info[thr_id].cgpu;
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsprintf(f + strlen(f), fmt, ap);
+ va_end(ap);
+}
+static void get_statline(char *buf, struct cgpu_info *cgpu)
+{
+ sprintf(buf, "%sPU%d ", cgpu->is_gpu ? "G" : "C", cgpu->cpu_gpu);
#ifdef HAVE_ADL
if (cgpu->has_adl) {
int gpu = cgpu->cpu_gpu;
+ float gt = gpu_temp(gpu);
+ int gf = gpu_fanspeed(gpu);
- printf("GPU %d: [%.1f ] [%.1f/%.1f Mh/s] [A:%d R:%d HW:%d U:%.2f/m]\n",
- cgpu->cpu_gpu, gpu_temp(gpu), cgpu->rolling,
- cgpu->total_mhashes / total_secs,
- cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
- cgpu->utility);
- } else
+ if (gt != -1)
+ tailsprintf(buf, "%.1fC ", gt);
+ if (gf != -1)
+ tailsprintf(buf, "%dRPM ", gf);
+ if (gt || gf)
+ tailsprintf(buf, "| ");
+ }
#endif
- printf(" %sPU %d: [%.1f / %.1f Mh/s] [A:%d R:%d HW:%d U:%.2f/m]\n",
- cgpu->is_gpu ? "G" : "C", cgpu->cpu_gpu, cgpu->rolling,
- cgpu->total_mhashes / total_secs,
- cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
- cgpu->utility);
+ tailsprintf(buf, "(%ds):%.1f (avg):%.1f Mh/s | A:%d R:%d HW:%d U:%.2f/m",
+ opt_log_interval,
+ cgpu->rolling,
+ cgpu->total_mhashes / total_secs,
+ cgpu->accepted,
+ cgpu->rejected,
+ cgpu->hw_errors,
+ cgpu->utility);
+}
+
+static void text_print_status(int thr_id)
+{
+ struct cgpu_info *cgpu = thr_info[thr_id].cgpu;
+ char logline[255];
+
+ get_statline(logline, cgpu);
+ printf("%s\n", logline);
}
/* Must be called with curses mutex lock held and curses_active */
@@ -1866,8 +1889,17 @@ static void curses_print_devstatus(int thr_id)
mvwprintw(statuswin, gpucursor + gpu, 0, " GPU %d: ", gpu);
#ifdef HAVE_ADL
- if (cgpu->has_adl)
- wprintw(statuswin, "%.1fC %dRPM | ", gpu_temp(gpu), gpu_fanspeed(gpu));
+ if (cgpu->has_adl) {
+ float gt = gpu_temp(gpu);
+ int gf = gpu_fanspeed(gpu);
+
+ if (gt != -1)
+ wprintw(statuswin, "%.1fC ", gt);
+ if (gf != -1)
+ wprintw(statuswin, "%dRPM ", gf);
+ if (gt || gf)
+ wprintw(statuswin, "| ");
+ }
#endif
if (cgpu->status == LIFE_DEAD)
wprintw(statuswin, "DEAD ");
@@ -2060,18 +2092,10 @@ static bool submit_upstream_work(const struct work *work)
if (!opt_realquiet)
print_status(thr_id);
if (!want_per_device_stats) {
-#ifdef HAVE_ADL
- if (cgpu->has_adl) {
- int gpu = cgpu->cpu_gpu;
+ char logline[255];
- applog(LOG_INFO, "GPU %d %.1fC A:%d R:%d HW:%d U:%.2f/m",
- gpu, gpu_temp(gpu), cgpu->accepted,
- cgpu->rejected, cgpu->hw_errors, cgpu->utility);
- } else
-#endif
- applog(LOG_INFO, "%sPU %d A:%d R:%d HW:%d U:%.2f/m",
- cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, cgpu->accepted,
- cgpu->rejected, cgpu->hw_errors, cgpu->utility);
+ get_statline(logline, cgpu);
+ applog(LOG_INFO, "%s", logline);
}
json_decref(val);
@@ -3087,7 +3111,7 @@ retry:
for (gpu = 0; gpu < nDevs; gpu++) {
struct cgpu_info *cgpu = &gpus[gpu];
- wlog("GPU %d: [%.1f / %.1f Mh/s] [A:%d R:%d HW:%d U:%.2f/m]\n",
+ wlog("GPU %d: %.1f / %.1f Mh/s | A:%d R:%d HW:%d U:%.2f/m\n",
gpu, cgpu->rolling, cgpu->total_mhashes / total_secs,
cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
cgpu->utility);
@@ -3096,9 +3120,31 @@ retry:
int engineclock = 0, memclock = 0, activity = 0, fanspeed = 0, fanpercent = 0, powertune = 0;
float temp = 0, vddc = 0;
- if (gpu_stats(gpu, &temp, &engineclock, &memclock, &vddc, &activity, &fanspeed, &fanpercent, &powertune))
- wlog("%.1f C F: %d%% (%d RPM) E: %d MHz M: %d Mhz V: %.3fV A: %d%% P: %d%%\n",
- temp, fanpercent, fanspeed, engineclock, memclock, vddc, activity, powertune);
+ if (gpu_stats(gpu, &temp, &engineclock, &memclock, &vddc, &activity, &fanspeed, &fanpercent, &powertune)) {
+ char logline[255];
+
+ strcpy(logline, ""); // In case it has no data
+ if (temp != -1)
+ sprintf(logline, "%.1f C ", temp);
+ if (fanspeed != -1) {
+ tailsprintf(logline, "F: ");
+ if (fanpercent != -1)
+ tailsprintf(logline, "%d%% ", fanpercent);
+ tailsprintf(logline, "%d RPM) ", fanspeed);
+ }
+ if (engineclock != -1)
+ tailsprintf(logline, "E: %d MHz ", engineclock);
+ if (memclock != -1)
+ tailsprintf(logline, "M: %d Mhz ", memclock);
+ if (vddc != -1)
+ tailsprintf(logline, "V: %.3fV ", vddc);
+ if (activity != -1)
+ tailsprintf(logline, "A: %d%% ", activity);
+ if (powertune != -1)
+ tailsprintf(logline, "P: %d%%", powertune);
+ tailsprintf(logline, "\n");
+ wlog(logline);
+ }
}
#endif
wlog("Last initialised: %s\n", cgpu->init);
@@ -3324,47 +3370,16 @@ static void hashmeter(int thr_id, struct timeval *diff,
timeval_subtract(&elapsed, &now, &thr->cgpu->last_message_tv);
if (opt_log_interval <= elapsed.tv_sec) {
struct cgpu_info *cgpu = thr->cgpu;
+ char logline[255];
cgpu->last_message_tv = now;
-#ifdef HAVE_ADL
- if (cgpu->has_adl) {
- int gpu = cgpu->cpu_gpu;
-
- sprintf(
- statusline,
- "[GPU%d %.1f C (%ds):%.1f (avg):%.1f Mh/s] [A:%d R:%d HW:%d U:%.2f/m]",
- cgpu->cpu_gpu,
- gpu_temp(gpu),
- opt_log_interval,
- cgpu->rolling,
- cgpu->total_mhashes / total_secs,
- cgpu->accepted,
- cgpu->rejected,
- cgpu->hw_errors,
- cgpu->utility
- );
- } else
-#endif
- sprintf(
- statusline,
- "[%sPU%d (%ds):%.1f (avg):%.1f Mh/s] [A:%d R:%d HW:%d U:%.2f/m]",
- cgpu->is_gpu ? "G" : "C",
- cgpu->cpu_gpu,
- opt_log_interval,
- cgpu->rolling,
- cgpu->total_mhashes / total_secs,
- cgpu->accepted,
- cgpu->rejected,
- cgpu->hw_errors,
- cgpu->utility
- );
-
+ get_statline(logline, cgpu);
if (!curses_active) {
- printf("%s \r", statusline);
+ printf("%s \r", logline);
fflush(stdout);
} else
- applog(LOG_INFO, "%s", statusline);
+ applog(LOG_INFO, "%s", logline);
}
}
}
@@ -3392,7 +3407,7 @@ static void hashmeter(int thr_id, struct timeval *diff,
utility = total_accepted / ( total_secs ? total_secs : 1 ) * 60;
efficiency = total_getworks ? total_accepted * 100.0 / total_getworks : 0.0;
- sprintf(statusline, "[%s(%ds):%.1f (avg):%.1f Mh/s] [Q:%d A:%d R:%d HW:%d E:%.0f%% U:%.2f/m]",
+ sprintf(statusline, "%s(%ds):%.1f (avg):%.1f Mh/s | Q:%d A:%d R:%d HW:%d E:%.0f%% U:%.2f/m",
want_per_device_stats ? "ALL " : "",
opt_log_interval, rolling, total_mhashes_done / total_secs,
total_getworks, total_accepted, total_rejected, hw_errors, efficiency, utility);
@@ -4750,24 +4765,11 @@ static void *watchdog_thread(void *userdata)
static void log_print_status(int thr_id)
{
struct cgpu_info *cgpu;
+ char logline[255];
cgpu = thr_info[thr_id].cgpu;
-#ifdef HAVE_ADL
- if (cgpu->has_adl) {
- int gpu = cgpu->cpu_gpu;
-
- applog(LOG_WARNING, " GPU %d: [%.1f C] [%.1f/%.1f Mh/s] [A:%d R:%d HW:%d U:%.2f/m]",
- gpu, gpu_temp(gpu), cgpu->rolling,
- cgpu->total_mhashes / total_secs,
- cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
- cgpu->utility);
- } else
-#endif
- applog(LOG_WARNING, " %sPU %d: [%.1f / %.1f Mh/s] [A:%d R:%d HW:%d U:%.2f/m]",
- cgpu->is_gpu ? "G" : "C", cgpu->cpu_gpu, cgpu->rolling,
- cgpu->total_mhashes / total_secs,
- cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
- cgpu->utility);
+ get_statline(logline, cgpu);
+ applog(LOG_WARNING, "%s", logline);
}
static void print_summary(void)