2015-12-04 14:47:52 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2015-12-04 14:47:52 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2016-09-05 19:47:26 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "logging.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "dynloader.h"
|
|
|
|
#include "ext_nvml.h"
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
int nvml_init (NVML_PTR *nvml)
|
2015-12-15 19:34:07 +00:00
|
|
|
{
|
2016-07-11 12:45:17 +00:00
|
|
|
if (!nvml) return -1;
|
2015-12-15 19:34:07 +00:00
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
memset (nvml, 0, sizeof (NVML_PTR));
|
2015-12-15 19:34:07 +00:00
|
|
|
|
2016-09-07 20:29:57 +00:00
|
|
|
#if defined (_WIN)
|
2016-05-31 20:48:58 +00:00
|
|
|
nvml->lib = hc_dlopen ("nvml.dll");
|
|
|
|
|
|
|
|
if (!nvml->lib)
|
|
|
|
{
|
|
|
|
DWORD BufferSize = 1024;
|
|
|
|
|
2016-07-17 18:32:47 +00:00
|
|
|
DWORD Type = REG_SZ;
|
2016-05-31 20:48:58 +00:00
|
|
|
|
2016-07-17 18:32:47 +00:00
|
|
|
char *Buffer = (char *) mymalloc (BufferSize + 1);
|
|
|
|
|
|
|
|
HKEY hKey = 0;
|
|
|
|
|
2016-10-01 12:26:12 +00:00
|
|
|
if (RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\NVSMI", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
|
2016-07-17 18:32:47 +00:00
|
|
|
{
|
2016-10-01 12:26:12 +00:00
|
|
|
if (RegQueryValueExA (hKey, "NVSMIPATH", NULL, &Type, (LPBYTE)Buffer, &BufferSize) == ERROR_SUCCESS)
|
2016-07-17 18:32:47 +00:00
|
|
|
{
|
|
|
|
Buffer[BufferSize] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-22 13:56:32 +00:00
|
|
|
//if (user_options->quiet == false)
|
2016-09-05 19:47:26 +00:00
|
|
|
// log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled.");
|
2016-07-17 18:32:47 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey (hKey);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-22 13:56:32 +00:00
|
|
|
//if (user_options->quiet == false)
|
2016-09-05 19:47:26 +00:00
|
|
|
// log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled.");
|
2016-07-17 18:32:47 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-05-31 20:48:58 +00:00
|
|
|
|
|
|
|
strcat (Buffer, "\\nvml.dll");
|
|
|
|
|
|
|
|
nvml->lib = hc_dlopen (Buffer);
|
|
|
|
|
|
|
|
myfree (Buffer);
|
|
|
|
}
|
|
|
|
|
2016-09-07 20:29:57 +00:00
|
|
|
#elif defined (_POSIX)
|
2016-02-02 00:14:33 +00:00
|
|
|
nvml->lib = hc_dlopen ("libnvidia-ml.so", RTLD_NOW);
|
2016-05-31 20:48:58 +00:00
|
|
|
#endif
|
2016-02-02 00:14:33 +00:00
|
|
|
|
|
|
|
if (!nvml->lib)
|
2015-12-15 19:34:07 +00:00
|
|
|
{
|
2016-09-22 13:56:32 +00:00
|
|
|
//if (user_options->quiet == false)
|
2016-09-05 19:47:26 +00:00
|
|
|
// log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled.");
|
2015-12-15 19:34:07 +00:00
|
|
|
|
2016-07-11 12:45:17 +00:00
|
|
|
return -1;
|
2015-12-15 19:34:07 +00:00
|
|
|
}
|
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
HC_LOAD_FUNC(nvml, nvmlErrorString, NVML_ERROR_STRING, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlInit, NVML_INIT, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlShutdown, NVML_SHUTDOWN, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetName, NVML_DEVICE_GET_NAME, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetHandleByIndex, NVML_DEVICE_GET_HANDLE_BY_INDEX, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperature, NVML_DEVICE_GET_TEMPERATURE, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetFanSpeed, NVML_DEVICE_GET_FAN_SPEED, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerUsage, NVML_DEVICE_GET_POWER_USAGE, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetUtilizationRates, NVML_DEVICE_GET_UTILIZATION_RATES, NVML, 0)
|
2016-05-28 14:49:23 +00:00
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetClockInfo, NVML_DEVICE_GET_CLOCKINFO, NVML, 0)
|
2016-05-28 22:59:24 +00:00
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperatureThreshold, NVML_DEVICE_GET_THRESHOLD, NVML, 0)
|
2016-05-29 14:54:07 +00:00
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkGeneration, NVML_DEVICE_GET_CURRPCIELINKGENERATION, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkWidth, NVML_DEVICE_GET_CURRPCIELINKWIDTH, NVML, 0)
|
2016-05-31 22:57:57 +00:00
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrentClocksThrottleReasons, NVML_DEVICE_GET_CURRENTCLOCKSTHROTTLEREASONS, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetSupportedClocksThrottleReasons, NVML_DEVICE_GET_SUPPORTEDCLOCKSTHROTTLEREASONS, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceSetComputeMode, NVML_DEVICE_SET_COMPUTEMODE, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceSetGpuOperationMode, NVML_DEVICE_SET_OPERATIONMODE, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerManagementLimitConstraints, NVML_DEVICE_GET_POWERMANAGEMENTLIMITCONSTRAINTS, NVML, 0)
|
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceSetPowerManagementLimit, NVML_DEVICE_SET_POWERMANAGEMENTLIMIT, NVML, 0)
|
2016-06-01 17:01:44 +00:00
|
|
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerManagementLimit, NVML_DEVICE_GET_POWERMANAGEMENTLIMIT, NVML, 0)
|
2016-02-02 00:14:33 +00:00
|
|
|
|
|
|
|
return 0;
|
2015-12-15 19:34:07 +00:00
|
|
|
}
|
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
void nvml_close (NVML_PTR *nvml)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2016-02-02 00:14:33 +00:00
|
|
|
if (nvml)
|
2015-12-15 19:34:07 +00:00
|
|
|
{
|
2016-02-02 00:14:33 +00:00
|
|
|
if (nvml->lib)
|
|
|
|
hc_dlclose (nvml->lib);
|
2015-12-15 19:34:07 +00:00
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
myfree (nvml);
|
2015-12-15 19:34:07 +00:00
|
|
|
}
|
2016-02-02 00:14:33 +00:00
|
|
|
}
|
2015-12-15 19:34:07 +00:00
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
const char *hm_NVML_nvmlErrorString (NVML_PTR *nvml, nvmlReturn_t nvml_rc)
|
|
|
|
{
|
|
|
|
if (!nvml) return NULL;
|
|
|
|
|
|
|
|
return nvml->nvmlErrorString (nvml_rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
nvmlReturn_t hm_NVML_nvmlInit (NVML_PTR *nvml)
|
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2016-02-02 00:14:33 +00:00
|
|
|
|
2016-08-27 05:09:34 +00:00
|
|
|
nvmlReturn_t nvml_rc = (nvmlReturn_t)nvml->nvmlInit ();
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2016-02-02 00:14:33 +00:00
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlInit()", nvml_rc, string);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlShutdown (NVML_PTR *nvml)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2015-12-15 19:34:07 +00:00
|
|
|
|
2016-08-27 05:09:34 +00:00
|
|
|
nvmlReturn_t nvml_rc = (nvmlReturn_t)nvml->nvmlShutdown ();
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2016-02-02 00:14:33 +00:00
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlShutdown()", nvml_rc, string);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetName (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, char *name, unsigned int length)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2015-12-15 19:34:07 +00:00
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetName (device, name, length);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2016-06-01 17:01:44 +00:00
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetName()", nvml_rc, string);
|
|
|
|
}
|
2015-12-04 14:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetHandleByIndex (NVML_PTR *nvml, int skip_warnings, unsigned int index, nvmlDevice_t *device)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2015-12-15 19:34:07 +00:00
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetHandleByIndex (index, device);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2015-12-15 19:34:07 +00:00
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
2016-02-02 00:14:33 +00:00
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2015-12-15 19:34:07 +00:00
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetHandleByIndex()", nvml_rc, string);
|
|
|
|
}
|
2015-12-04 14:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetTemperature (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2015-12-15 19:34:07 +00:00
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperature (device, sensorType, temp);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2016-06-01 17:01:44 +00:00
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetTemperature()", nvml_rc, string);
|
|
|
|
}
|
2015-12-04 14:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetFanSpeed (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *speed)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2015-12-15 19:34:07 +00:00
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetFanSpeed (device, speed);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2015-12-15 19:34:07 +00:00
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
2016-02-02 00:14:33 +00:00
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2015-12-15 19:34:07 +00:00
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetFanSpeed()", nvml_rc, string);
|
|
|
|
}
|
2015-12-04 14:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetPowerUsage (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *power)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2015-12-15 19:34:07 +00:00
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerUsage (device, power);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2016-06-01 17:01:44 +00:00
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetPowerUsage()", nvml_rc, string);
|
|
|
|
}
|
2015-12-04 14:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetUtilizationRates (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlUtilization_t *utilization)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2015-12-15 19:34:07 +00:00
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetUtilizationRates (device, utilization);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2016-06-01 17:01:44 +00:00
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetUtilizationRates()", nvml_rc, string);
|
|
|
|
}
|
2015-12-04 14:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
2016-05-28 14:49:23 +00:00
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetClockInfo (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock)
|
2016-05-28 14:49:23 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2016-05-28 14:49:23 +00:00
|
|
|
|
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetClockInfo (device, type, clock);
|
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2016-06-01 17:01:44 +00:00
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2016-05-28 14:49:23 +00:00
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetClockInfo()", nvml_rc, string);
|
|
|
|
}
|
2016-05-28 14:49:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetTemperatureThreshold (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp)
|
2016-05-28 22:59:24 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2016-05-28 22:59:24 +00:00
|
|
|
|
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperatureThreshold (device, thresholdType, temp);
|
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2016-06-01 17:01:44 +00:00
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2016-05-28 22:59:24 +00:00
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetTemperatureThreshold()", nvml_rc, string);
|
|
|
|
}
|
2016-05-28 22:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
2016-05-29 14:54:07 +00:00
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *currLinkGen)
|
2016-05-29 14:54:07 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2016-05-29 14:54:07 +00:00
|
|
|
|
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkGeneration (device, currLinkGen);
|
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2016-06-01 17:01:44 +00:00
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2016-05-29 14:54:07 +00:00
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetCurrPcieLinkGeneration()", nvml_rc, string);
|
|
|
|
}
|
2016-05-29 14:54:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *currLinkWidth)
|
2016-05-29 14:54:07 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2016-05-29 14:54:07 +00:00
|
|
|
|
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkWidth (device, currLinkWidth);
|
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2016-06-01 17:01:44 +00:00
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2016-05-31 22:57:57 +00:00
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetCurrPcieLinkWidth()", nvml_rc, string);
|
|
|
|
}
|
2016-05-31 22:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned long long *clocksThrottleReasons)
|
2016-05-31 22:57:57 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2016-05-31 22:57:57 +00:00
|
|
|
|
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrentClocksThrottleReasons (device, clocksThrottleReasons);
|
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2016-06-01 17:01:44 +00:00
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2016-05-31 22:57:57 +00:00
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetCurrentClocksThrottleReasons()", nvml_rc, string);
|
|
|
|
}
|
2016-05-31 22:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons)
|
2016-05-31 22:57:57 +00:00
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2016-05-31 22:57:57 +00:00
|
|
|
|
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetSupportedClocksThrottleReasons (device, supportedClocksThrottleReasons);
|
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
2016-06-01 17:01:44 +00:00
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
2016-05-31 22:57:57 +00:00
|
|
|
|
2016-06-01 17:01:44 +00:00
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetSupportedClocksThrottleReasons()", nvml_rc, string);
|
|
|
|
}
|
2016-05-31 22:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceSetComputeMode (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlComputeMode_t mode)
|
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2016-05-31 22:57:57 +00:00
|
|
|
|
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetComputeMode (device, mode);
|
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
|
|
|
|
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceSetComputeMode()", nvml_rc, string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceSetGpuOperationMode (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlGpuOperationMode_t mode)
|
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2016-05-31 22:57:57 +00:00
|
|
|
|
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetGpuOperationMode (device, mode);
|
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
|
|
|
|
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceSetGpuOperationMode()", nvml_rc, string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit)
|
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2016-05-31 22:57:57 +00:00
|
|
|
|
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerManagementLimitConstraints (device, minLimit, maxLimit);
|
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
|
|
|
|
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetPowerManagementLimitConstraints()", nvml_rc, string);
|
|
|
|
}
|
|
|
|
}
|
2016-05-29 14:54:07 +00:00
|
|
|
|
2016-05-31 22:57:57 +00:00
|
|
|
return nvml_rc;
|
|
|
|
}
|
2016-05-29 14:54:07 +00:00
|
|
|
|
2016-05-31 22:57:57 +00:00
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceSetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int limit)
|
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2016-05-31 22:57:57 +00:00
|
|
|
|
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetPowerManagementLimit (device, limit);
|
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
|
|
|
|
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceSetPowerManagementLimit()", nvml_rc, string);
|
|
|
|
}
|
2016-05-29 14:54:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|
2016-06-01 17:01:44 +00:00
|
|
|
|
|
|
|
nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *limit)
|
|
|
|
{
|
2016-10-01 11:17:46 +00:00
|
|
|
if (!nvml) return (nvmlReturn_t) -1;
|
2016-06-01 17:01:44 +00:00
|
|
|
|
|
|
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerManagementLimit (device, limit);
|
|
|
|
|
|
|
|
if (nvml_rc != NVML_SUCCESS)
|
|
|
|
{
|
|
|
|
if (skip_warnings == 0)
|
|
|
|
{
|
|
|
|
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
|
|
|
|
|
|
|
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetPowerManagementLimit()", nvml_rc, string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nvml_rc;
|
|
|
|
}
|