Add device_field for memory clock

Currently, GPU clocks and GPU memory clocks have
the same same field width size in the interface,
which is presumed to be in the thousands of MHz.
However, memory clocks reported by the GPU can be
in the tens of thousands range, presumably to
account for memory features such as PAM4 (like on
the RTX 4090). This causes the GPU memory clock
field to be one byte short when 5 digit clocks
are reported, cutting the 'z' from MHz.
This commit fixes that by adding a new
device_field for the memory clock that's one char
longer than the device_field for the GPU clocks,
and makes the appropriate changes in usage and
calculations that rely on these values.
This commit is contained in:
nvmd
2025-09-13 01:19:13 -03:00
parent 339ee0b10a
commit 62f753f51c
2 changed files with 18 additions and 15 deletions

View File

@@ -144,6 +144,7 @@ enum device_field {
device_power,
device_pcie,
device_clock,
device_mem_clock,
device_shadercores,
device_l2features,
device_execengines,

View File

@@ -43,9 +43,9 @@
#include <unistd.h>
static unsigned int sizeof_device_field[device_field_count] = {
[device_name] = 11, [device_fan_speed] = 11, [device_temperature] = 10,
[device_power] = 15, [device_clock] = 11, [device_pcie] = 46,
[device_shadercores] = 7, [device_l2features] = 11, [device_execengines] = 11,
[device_name] = 11, [device_fan_speed] = 11, [device_temperature] = 10, [device_power] = 15,
[device_clock] = 11, [device_mem_clock] = 12, [device_pcie] = 46, [device_shadercores] = 7,
[device_l2features] = 11, [device_execengines] = 11,
};
static unsigned int sizeof_process_field[process_field_count] = {
@@ -74,22 +74,24 @@ static void alloc_device_window(unsigned int start_row, unsigned int start_col,
dwin->gpu_clock_info = newwin(1, sizeof_device_field[device_clock], start_row + 1, start_col);
if (dwin->gpu_clock_info == NULL)
goto alloc_error;
dwin->mem_clock_info = newwin(1, sizeof_device_field[device_clock], start_row + 1,
dwin->mem_clock_info = newwin(1, sizeof_device_field[device_mem_clock], start_row + 1,
start_col + spacer + sizeof_device_field[device_clock]);
if (dwin->mem_clock_info == NULL)
goto alloc_error;
dwin->temperature = newwin(1, sizeof_device_field[device_temperature], start_row + 1,
start_col + spacer * 2 + sizeof_device_field[device_clock] * 2);
dwin->temperature =
newwin(1, sizeof_device_field[device_temperature], start_row + 1,
start_col + spacer * 2 + sizeof_device_field[device_clock] + sizeof_device_field[device_mem_clock]);
if (dwin->temperature == NULL)
goto alloc_error;
dwin->fan_speed =
newwin(1, sizeof_device_field[device_fan_speed], start_row + 1,
start_col + spacer * 3 + sizeof_device_field[device_clock] * 2 + sizeof_device_field[device_temperature]);
dwin->fan_speed = newwin(1, sizeof_device_field[device_fan_speed], start_row + 1,
start_col + spacer * 3 + sizeof_device_field[device_clock] +
sizeof_device_field[device_mem_clock] + sizeof_device_field[device_temperature]);
if (dwin->fan_speed == NULL)
goto alloc_error;
dwin->power_info = newwin(1, sizeof_device_field[device_power], start_row + 1,
start_col + spacer * 4 + sizeof_device_field[device_clock] * 2 +
sizeof_device_field[device_temperature] + sizeof_device_field[device_fan_speed]);
dwin->power_info =
newwin(1, sizeof_device_field[device_power], start_row + 1,
start_col + spacer * 4 + sizeof_device_field[device_clock] + sizeof_device_field[device_mem_clock] +
sizeof_device_field[device_temperature] + sizeof_device_field[device_fan_speed]);
if (dwin->power_info == NULL)
goto alloc_error;
@@ -341,9 +343,9 @@ static void alloc_plot_window(unsigned devices_count, struct window_position *pl
static unsigned device_length(void) {
return max(sizeof_device_field[device_name] + sizeof_device_field[device_pcie] + 1,
2 * sizeof_device_field[device_clock] + sizeof_device_field[device_temperature] +
sizeof_device_field[device_fan_speed] + sizeof_device_field[device_power] + 4);
sizeof_device_field[device_clock] + sizeof_device_field[device_mem_clock] +
sizeof_device_field[device_temperature] + sizeof_device_field[device_fan_speed] +
sizeof_device_field[device_power] + 4);
}
static pid_t nvtop_pid;