Added support for some NVML sensors.
GPU temp sensor and clock reasons.
This commit is contained in:
+47
-19
@@ -5,6 +5,10 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef USE_NVML
|
||||
#include "nvidia-sensors.h"
|
||||
#endif
|
||||
|
||||
#include "icx3.h"
|
||||
#include "evga-card.h"
|
||||
|
||||
@@ -32,7 +36,7 @@ int main (int argc, char **argv)
|
||||
int print_info = 0;
|
||||
int compact = 0;
|
||||
int gpu_num = -1; /* Card to control */
|
||||
int watch = -1;
|
||||
unsigned int watch = 0;
|
||||
char *fan_speed[ICX3_MAX_FANS] = {NULL};
|
||||
|
||||
/* Input parsing */
|
||||
@@ -125,33 +129,57 @@ int main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* NVML init */
|
||||
#ifdef USE_NVML
|
||||
int nvml_ok = init_nvml();
|
||||
nvmlDevice_t* device[MAX_GPUS];
|
||||
#endif
|
||||
|
||||
/* print sensor info */
|
||||
print:
|
||||
if (print_info) {
|
||||
if (gpu_num == -1) {
|
||||
for (int i = 0; i < gpu_count; i++){
|
||||
print_gpu_info(i, gpus, compact);
|
||||
}
|
||||
} else if (gpu_num <= gpu_count - 1) {
|
||||
print_gpu_info(gpu_num, gpus, compact);
|
||||
}
|
||||
}
|
||||
if (watch > 0) {
|
||||
sleep(watch);
|
||||
goto print;
|
||||
do {
|
||||
if (gpu_num == -1) {
|
||||
for (int i = 0; i < gpu_count; i++){
|
||||
print_gpu_info(i, &gpus[i], compact);
|
||||
}
|
||||
} else if (gpu_num <= gpu_count - 1) {
|
||||
print_gpu_info(gpu_num, &gpus[gpu_num], compact);
|
||||
}
|
||||
sleep(watch);
|
||||
} while (watch > 0);
|
||||
}
|
||||
|
||||
#ifdef USE_NVML
|
||||
nvmlShutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
void print_gpu_info(int gpu_num, struct card_info gpus[], int compact) {
|
||||
void print_gpu_info(int gpu_num, struct card_info *gpu, int compact) {
|
||||
if (compact) {
|
||||
/* One line per GPU */
|
||||
printf("#%d ", gpu_num);
|
||||
print_icx3_fans_oneline(&gpus[gpu_num]);
|
||||
print_icx3_temps_oneline(&gpus[gpu_num]);
|
||||
print_icx3_fans_oneline(gpu);
|
||||
printf(" GPU");
|
||||
#ifdef USE_NVML
|
||||
print_nvml_temp(1, gpu);
|
||||
#endif
|
||||
print_icx3_temps_oneline(gpu);
|
||||
printf("°C");
|
||||
#ifdef USE_NVML
|
||||
print_nvml_clock_reason(1, gpu);
|
||||
#endif
|
||||
printf("\n");
|
||||
} else {
|
||||
printf("#%d: %s (%s) @ %s\n", gpu_num, gpus[gpu_num].card_name, gpus[gpu_num].i2c_dev_path, gpus[gpu_num].pci_id);
|
||||
print_icx3_fans(&gpus[gpu_num]);
|
||||
print_icx3_temps(&gpus[gpu_num]);
|
||||
/* One line per GPU sensor */
|
||||
printf("#%d: %s (%s) @ %s\n", gpu_num, gpu->card_name, gpu->i2c_dev_path, gpu->pci_id);
|
||||
print_icx3_fans(gpu);
|
||||
#ifdef USE_NVML
|
||||
print_nvml_temp(0, gpu);
|
||||
#endif
|
||||
print_icx3_temps(gpu);
|
||||
#ifdef USE_NVML
|
||||
print_nvml_clock_reason(0, gpu);
|
||||
#endif
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user