nvml: fan speed

pull/841/head^2
FlightlessMango 1 year ago
parent 5aec3d817b
commit 2df384cdd7

@ -45,6 +45,7 @@ void getNvidiaGpuInfo(const struct overlay_params& params){
gpu_info.MemClock = nvidiaMemClock;
gpu_info.powerUsage = nvidiaPowerUsage / 1000;
gpu_info.memoryTotal = nvidiaMemory.total / (1024.f * 1024.f * 1024.f);
gpu_info.fan_speed = NvidiaFanSpeed;
if (params.enabled[OVERLAY_PARAM_ENABLED_throttling_status]){
gpu_info.is_temp_throttled = (nvml_throttle_reasons & 0x0000000000000060LL) != 0;
gpu_info.is_power_throttled = (nvml_throttle_reasons & 0x000000000000008CLL) != 0;

@ -214,6 +214,19 @@ bool libnvml_loader::Load(const std::string& library_name) {
return false;
}
#if defined(LIBRARY_LOADER_NVML_H_DLOPEN)
nvmlDeviceGetFanSpeed =
reinterpret_cast<decltype(this->nvmlDeviceGetFanSpeed)>(
dlsym(library_, "nvmlDeviceGetPowerUsage"));
#endif
#if defined(LIBRARY_LOADER_NVML_H_DT_NEEDED)
nvmlDeviceGetFanSpeed = &::nvmlDeviceGetFanSpeed;
#endif
if (!nvmlDeviceGetFanSpeed) {
CleanUp(true);
return false;
}
loaded_ = true;
return true;
}
@ -236,4 +249,5 @@ void libnvml_loader::CleanUp(bool unload) {
nvmlDeviceGetHandleByIndex_v2 = NULL;
nvmlDeviceGetHandleByPciBusId_v2 = NULL;
nvmlDeviceGetCurrentClocksThrottleReasons = NULL;
nvmlDeviceGetFanSpeed = NULL;
}

@ -38,6 +38,7 @@ class libnvml_loader {
decltype(&::nvmlErrorString) nvmlErrorString;
decltype(&::nvmlDeviceGetPowerUsage) nvmlDeviceGetPowerUsage;
decltype(&::nvmlDeviceGetCurrentClocksThrottleReasons) nvmlDeviceGetCurrentClocksThrottleReasons;
decltype(&::nvmlDeviceGetFanSpeed) nvmlDeviceGetFanSpeed;
private:
void CleanUp(bool unload);

@ -9,7 +9,7 @@ nvmlReturn_t result;
nvmlDevice_t nvidiaDevice;
nvmlPciInfo_t nvidiaPciInfo;
bool nvmlSuccess = false;
unsigned int nvidiaTemp = 0, nvidiaCoreClock = 0, nvidiaMemClock = 0, nvidiaPowerUsage = 0;
unsigned int nvidiaTemp = 0, nvidiaCoreClock = 0, nvidiaMemClock = 0, nvidiaPowerUsage = 0, NvidiaFanSpeed = 0;
unsigned long long nvml_throttle_reasons;
struct nvmlUtilization_st nvidiaUtilization;
struct nvmlMemory_st nvidiaMemory {};
@ -55,6 +55,7 @@ bool getNVMLInfo(const struct overlay_params& params){
nvml.nvmlDeviceGetClockInfo(nvidiaDevice, NVML_CLOCK_GRAPHICS, &nvidiaCoreClock);
nvml.nvmlDeviceGetClockInfo(nvidiaDevice, NVML_CLOCK_MEM, &nvidiaMemClock);
nvml.nvmlDeviceGetPowerUsage(nvidiaDevice, &nvidiaPowerUsage);
nvml.nvmlDeviceGetFanSpeed(nvidiaDevice, &NvidiaFanSpeed);
deviceID = nvidiaPciInfo.pciDeviceId >> 16;
if (params.enabled[OVERLAY_PARAM_ENABLED_throttling_status])
nvml.nvmlDeviceGetCurrentClocksThrottleReasons(nvidiaDevice, &nvml_throttle_reasons);

Loading…
Cancel
Save