Added NVML memory controller load percentage.
This commit is contained in:
+32
-13
@@ -10,6 +10,17 @@ void init_nvml()
|
||||
printf("Could not init NVML: %s\n", nvmlErrorString(result));
|
||||
}
|
||||
|
||||
int get_nvml_handle(nvmlDevice_t *device, struct card_info *card)
|
||||
{
|
||||
nvmlReturn_t result;
|
||||
result = nvmlDeviceGetHandleByPciBusId_v2(card->pci_id, device);
|
||||
if (result != NVML_SUCCESS) {
|
||||
printf("Failed to get device handle for card at %s: %s\n", card->pci_id, nvmlErrorString(result));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void print_nvml_clock_reason(int compact, struct card_info *card)
|
||||
{
|
||||
unsigned long long reasons = get_nvml_clock_reasons(card);
|
||||
@@ -36,21 +47,17 @@ void print_nvml_clock_reason(int compact, struct card_info *card)
|
||||
printf("None");
|
||||
|
||||
if (!compact)
|
||||
printf(" (0x%llx)\n", reasons);
|
||||
printf(" (0x%llx)", reasons);
|
||||
}
|
||||
|
||||
unsigned int get_nvml_temp(struct card_info *card)
|
||||
{
|
||||
nvmlReturn_t result;
|
||||
nvmlDevice_t nvml_device;
|
||||
result = nvmlDeviceGetHandleByPciBusId_v2(card->pci_id, &nvml_device);
|
||||
if (result != NVML_SUCCESS) {
|
||||
printf("Failed to get device handle for card at %s: %s\n", card->pci_id, nvmlErrorString(result));
|
||||
if (!get_nvml_handle(&nvml_device, card))
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int temp;
|
||||
result = nvmlDeviceGetTemperature(nvml_device, NVML_TEMPERATURE_GPU, &temp);
|
||||
nvmlReturn_t result = nvmlDeviceGetTemperature(nvml_device, NVML_TEMPERATURE_GPU, &temp);
|
||||
if (result != NVML_SUCCESS) {
|
||||
printf("Failed to get temperature for card at %s: %s\n", card->pci_id, nvmlErrorString(result));
|
||||
return 0;
|
||||
@@ -60,16 +67,12 @@ unsigned int get_nvml_temp(struct card_info *card)
|
||||
|
||||
unsigned long long get_nvml_clock_reasons(struct card_info *card)
|
||||
{
|
||||
nvmlReturn_t result;
|
||||
nvmlDevice_t nvml_device;
|
||||
result = nvmlDeviceGetHandleByPciBusId_v2(card->pci_id, &nvml_device);
|
||||
if (result != NVML_SUCCESS) {
|
||||
printf("Failed to get device handle for card at %s: %s\n", card->pci_id, nvmlErrorString(result));
|
||||
if (!get_nvml_handle(&nvml_device, card))
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long long reasons;
|
||||
result = nvmlDeviceGetCurrentClocksEventReasons(nvml_device, &reasons) ;
|
||||
nvmlReturn_t result = nvmlDeviceGetCurrentClocksEventReasons(nvml_device, &reasons) ;
|
||||
if (result != NVML_SUCCESS) {
|
||||
printf("Failed to get clock reasons for card at %s: %s\n", card->pci_id, nvmlErrorString(result));
|
||||
return 0;
|
||||
@@ -78,3 +81,19 @@ unsigned long long get_nvml_clock_reasons(struct card_info *card)
|
||||
return reasons;
|
||||
}
|
||||
|
||||
unsigned int get_nvml_mem_util(struct card_info *card)
|
||||
{
|
||||
nvmlDevice_t nvml_device;
|
||||
if (!get_nvml_handle(&nvml_device, card))
|
||||
return 0;
|
||||
|
||||
nvmlUtilization_t util;
|
||||
nvmlReturn_t result = nvmlDeviceGetUtilizationRates(nvml_device, &util);
|
||||
if (result != NVML_SUCCESS) {
|
||||
printf("Failed to get clock reasons for card at %s: %s\n", card->pci_id, nvmlErrorString(result));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return util.memory;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user