Fixes when compiling with both NVML and DCGM.
NVML temp code updated (driver version ~555 and up)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <dirent.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "blackwell-sensors.h"
|
||||
|
||||
|
||||
@@ -36,6 +36,12 @@ struct card_info {
|
||||
void *nvml_device; /* Pointer to nvmlDevice_t for use in NVML calls */
|
||||
};
|
||||
|
||||
struct clock_reason {
|
||||
unsigned long long mask;
|
||||
char *short_name;
|
||||
char *long_name;
|
||||
};
|
||||
|
||||
unsigned short read_pci_id(char *device_path, char *field);
|
||||
char *read_nvidia_pci_address(char *device_path);
|
||||
void mmap_bar0(struct card_info *card);
|
||||
|
||||
+4
-4
@@ -78,8 +78,8 @@ void print_dcgm(int compact, int overwrite)
|
||||
else
|
||||
printf("Clock reasons: ");
|
||||
|
||||
for (int i = 0; i < (sizeof(clock_reason_names) / sizeof(struct clock_reason)); i++) {
|
||||
if (clock_reasons & clock_reason_names[i].mask) {
|
||||
for (int i = 0; i < (sizeof(dcgm_clock_reason_names) / sizeof(struct clock_reason)); i++) {
|
||||
if (clock_reasons & dcgm_clock_reason_names[i].mask) {
|
||||
if (!single_reason) {
|
||||
if (compact)
|
||||
printf(",");
|
||||
@@ -89,9 +89,9 @@ void print_dcgm(int compact, int overwrite)
|
||||
single_reason = 0;
|
||||
|
||||
if (compact)
|
||||
printf("%s", clock_reason_names[i].short_name);
|
||||
printf("%s", dcgm_clock_reason_names[i].short_name);
|
||||
else
|
||||
printf("%s", clock_reason_names[i].long_name);
|
||||
printf("%s", dcgm_clock_reason_names[i].long_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-7
@@ -26,13 +26,7 @@ static struct metric_reading metric_readings[] =
|
||||
{DCGM_FI_PROF_DRAM_ACTIVE, "DRAM", "Memory BW Utilization"}
|
||||
};
|
||||
|
||||
struct clock_reason {
|
||||
unsigned long long mask;
|
||||
char *short_name;
|
||||
char *long_name;
|
||||
};
|
||||
|
||||
static struct clock_reason clock_reason_names[] =
|
||||
static struct clock_reason dcgm_clock_reason_names[] =
|
||||
{
|
||||
{DCGM_CLOCKS_EVENT_REASON_GPU_IDLE, "Idle", "GPU idle"},
|
||||
{DCGM_CLOCKS_EVENT_REASON_CLOCKS_SETTING, "AppClk", "Application clocks"},
|
||||
|
||||
+9
-7
@@ -25,8 +25,8 @@ void print_nvml_clock_reason(int compact, struct card_info *card)
|
||||
unsigned long long reasons = get_nvml_clock_reasons(card);
|
||||
int single_reason = 1;
|
||||
|
||||
for (int i = 0; i < (sizeof(clock_reason_names) / sizeof(struct clock_reason)); i++) {
|
||||
if (reasons & clock_reason_names[i].mask) {
|
||||
for (int i = 0; i < (sizeof(nvml_clock_reason_names) / sizeof(struct clock_reason)); i++) {
|
||||
if (reasons & nvml_clock_reason_names[i].mask) {
|
||||
if (!single_reason) {
|
||||
if (compact)
|
||||
printf(",");
|
||||
@@ -36,9 +36,9 @@ void print_nvml_clock_reason(int compact, struct card_info *card)
|
||||
single_reason = 0;
|
||||
|
||||
if (compact)
|
||||
printf("%s", clock_reason_names[i].short_name);
|
||||
printf("%s", nvml_clock_reason_names[i].short_name);
|
||||
else
|
||||
printf("%s", clock_reason_names[i].long_name);
|
||||
printf("%s", nvml_clock_reason_names[i].long_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,13 +56,15 @@ unsigned int get_nvml_temp(struct card_info *card)
|
||||
if (card->nvml_device == NULL)
|
||||
return 0;
|
||||
|
||||
unsigned int temp;
|
||||
nvmlReturn_t result = nvmlDeviceGetTemperature(*(nvmlDevice_t*)(card->nvml_device), NVML_TEMPERATURE_GPU, &temp);
|
||||
nvmlTemperature_t temp;
|
||||
temp.version = nvmlTemperature_v1;
|
||||
temp.sensorType = NVML_TEMPERATURE_GPU;
|
||||
nvmlReturn_t result = nvmlDeviceGetTemperatureV(*(nvmlDevice_t*)(card->nvml_device), &temp);
|
||||
if (result != NVML_SUCCESS) {
|
||||
printf("Failed to get temperature for card at %s: %s\n", card->pci_id, nvmlErrorString(result));
|
||||
return 0;
|
||||
}
|
||||
return temp;
|
||||
return temp.temperature;
|
||||
}
|
||||
|
||||
unsigned long long get_nvml_clock_reasons(struct card_info *card)
|
||||
|
||||
+1
-7
@@ -2,13 +2,7 @@
|
||||
|
||||
#include "evga-card.h"
|
||||
|
||||
struct clock_reason {
|
||||
unsigned long long mask;
|
||||
char *short_name;
|
||||
char *long_name;
|
||||
};
|
||||
|
||||
static struct clock_reason clock_reason_names[] =
|
||||
static struct clock_reason nvml_clock_reason_names[] =
|
||||
{
|
||||
{nvmlClocksEventReasonGpuIdle, "Idle", "GPU idle"},
|
||||
{nvmlClocksEventReasonApplicationsClocksSetting, "AppClk", "Application clocks"},
|
||||
|
||||
Reference in New Issue
Block a user