Added --no-reasons flag

This commit is contained in:
moosecrap 2025-02-23 00:23:39 -08:00
parent 5e78a059a6
commit 60caeaf0ef
2 changed files with 18 additions and 9 deletions

View File

@ -55,6 +55,7 @@ Available options:
--watch N : Keep printing output every N seconds --watch N : Keep printing output every N seconds
--overwrite : Overwrite previously displayed info with --watch and --compact instead of continuously logging new lines --overwrite : Overwrite previously displayed info with --watch and --compact instead of continuously logging new lines
--color : Print headers in color in --compact mode for better readability --color : Print headers in color in --compact mode for better readability
--no-reasons : Do not query NVML for clocks reasons (can cause stuttering)
``` ```
### Examples: ### Examples:

View File

@ -37,9 +37,10 @@ static const char helpstring[] = "Available options:\n"
"--compact : Print sensor reading in a compact one-line per card format\n" "--compact : Print sensor reading in a compact one-line per card format\n"
"--watch N : Keep printing output every N seconds\n" "--watch N : Keep printing output every N seconds\n"
"--overwrite : Overwrite previously displayed info with --watch and --compact instead of continuously logging\n" "--overwrite : Overwrite previously displayed info with --watch and --compact instead of continuously logging\n"
"--color : Print headers in color in --compact mode for better readability\n"; "--color : Print headers in color in --compact mode for better readability\n"
"--no-reasons : Do not query NVML for clocks reasons (can cause stuttering)\n";
void print_gpu_info(int gpu_num, struct card_info gpus[], int compact); void print_gpu_info(int gpu_num, struct card_info gpus[], int compact, int no_reasons);
int main (int argc, char **argv) int main (int argc, char **argv)
{ {
@ -50,6 +51,7 @@ int main (int argc, char **argv)
int gpu_num = -1; /* Card to control */ int gpu_num = -1; /* Card to control */
int i2c_bus = -1; int i2c_bus = -1;
int overwrite = 0; int overwrite = 0;
int no_reasons = 0;
unsigned int watch = 0; unsigned int watch = 0;
char *fan_speed[ICX3_MAX_FANS] = {NULL}; char *fan_speed[ICX3_MAX_FANS] = {NULL};
@ -110,6 +112,8 @@ int main (int argc, char **argv)
} else if (strcmp(argv[i], "--color") == 0) { } else if (strcmp(argv[i], "--color") == 0) {
header_start = HEADER_COLOR_START; header_start = HEADER_COLOR_START;
header_end = HEADER_COLOR_END; header_end = HEADER_COLOR_END;
} else if (strcmp(argv[i], "--no-reasons") == 0) {
no_reasons = 1;
} else { } else {
printf(helpstring); printf(helpstring);
return 0; return 0;
@ -184,10 +188,10 @@ int main (int argc, char **argv)
for (int i = 0; i < gpu_count; i++){ for (int i = 0; i < gpu_count; i++){
if (i > 0) if (i > 0)
printf("\n"); printf("\n");
print_gpu_info(i, &gpus[i], compact); print_gpu_info(i, &gpus[i], compact, no_reasons);
} }
} else if (gpu_num <= gpu_count - 1) { } else if (gpu_num <= gpu_count - 1) {
print_gpu_info(gpu_num, &gpus[gpu_num], compact); print_gpu_info(gpu_num, &gpus[gpu_num], compact, no_reasons);
} }
if (!overwrite) if (!overwrite)
@ -209,7 +213,7 @@ int main (int argc, char **argv)
#endif #endif
} }
void print_gpu_info(int gpu_num, struct card_info *gpu, int compact) { void print_gpu_info(int gpu_num, struct card_info *gpu, int compact, int no_reasons) {
if (compact) { if (compact) {
/* One line per GPU */ /* One line per GPU */
printf("%s#%d FAN%s", header_start, gpu_num, header_end); printf("%s#%d FAN%s", header_start, gpu_num, header_end);
@ -241,8 +245,10 @@ void print_gpu_info(int gpu_num, struct card_info *gpu, int compact) {
#ifdef USE_NVML #ifdef USE_NVML
printf("%s MEM %s", header_start, header_end); printf("%s MEM %s", header_start, header_end);
printf("%3d%%", get_nvml_mem_util(gpu)); printf("%3d%%", get_nvml_mem_util(gpu));
printf("%s CLK %s", header_start, header_end); if (!no_reasons) {
print_nvml_clock_reason(1, gpu); printf("%s CLK %s", header_start, header_end);
print_nvml_clock_reason(1, gpu);
}
#endif #endif
@ -272,8 +278,10 @@ void print_gpu_info(int gpu_num, struct card_info *gpu, int compact) {
#ifdef USE_NVML #ifdef USE_NVML
printf("Mem util: %d%%\n", get_nvml_mem_util(gpu)); printf("Mem util: %d%%\n", get_nvml_mem_util(gpu));
printf("Clock reasons: "); if (!no_reasons) {
print_nvml_clock_reason(0, gpu); printf("Clock reasons: ");
print_nvml_clock_reason(0, gpu);
}
printf("\n"); printf("\n");
#endif #endif
} }