2 * Author......: Jens Steube <jens.steube@gmail.com>
9 #if defined(HAVE_HWMON) && defined(HAVE_NVML)
14 * Declarations from nvml.h
17 typedef struct nvmlDevice_st
* nvmlDevice_t
;
19 typedef struct nvmlPciInfo_st
{
24 unsigned int pciDeviceId
;
25 unsigned int pciSubSystemId
;
28 typedef struct nvmlUtilization_st
{
29 unsigned int gpu
; // GPU kernel execution last second, percent
30 unsigned int memory
; // GPU memory read/write last second, percent
33 typedef enum nvmlTemperatureSensors_enum
{
34 NVML_TEMPERATURE_GPU
= 0 // Temperature sensor for the GPU die
35 } nvmlTemperatureSensors_t
;
37 typedef enum nvmlReturn_enum
{
38 NVML_SUCCESS
= 0, // The operation was successful
39 NVML_ERROR_UNINITIALIZED
= 1, // NVML was not first initialized with nvmlInit()
40 NVML_ERROR_INVALID_ARGUMENT
= 2, // A supplied argument is invalid
41 NVML_ERROR_NOT_SUPPORTED
= 3, // The requested operation is not available on target device
42 NVML_ERROR_NO_PERMISSION
= 4, // The current user does not have permission for operation
43 NVML_ERROR_ALREADY_INITIALIZED
= 5, // Deprecated: Multiple initializations are now allowed through ref counting
44 NVML_ERROR_NOT_FOUND
= 6, // A query to find an object was unsuccessful
45 NVML_ERROR_INSUFFICIENT_SIZE
= 7, // An input argument is not large enough
46 NVML_ERROR_INSUFFICIENT_POWER
= 8, // A device's external power cables are not properly attached
47 NVML_ERROR_DRIVER_NOT_LOADED
= 9, // NVIDIA driver is not loaded
48 NVML_ERROR_TIMEOUT
= 10, // User provided timeout passed
49 NVML_ERROR_UNKNOWN
= 999 // An internal driver error occurred
53 * End of declarations from nvml.h
56 typedef nvmlDevice_t HM_ADAPTER_NV
;
58 typedef const char * (*NVML_ERROR_STRING
) (nvmlReturn_t
);
59 typedef int (*NVML_INIT
) ();
60 typedef int (*NVML_SHUTDOWN
) ();
61 typedef nvmlReturn_t (*NVML_DEVICE_GET_NAME
) (nvmlDevice_t
, char *, unsigned int);
62 typedef nvmlReturn_t (*NVML_DEVICE_GET_HANDLE_BY_INDEX
) (unsigned int, nvmlDevice_t
*);
63 typedef nvmlReturn_t (*NVML_DEVICE_GET_TEMPERATURE
) (nvmlDevice_t
, nvmlTemperatureSensors_t
, unsigned int *);
64 typedef nvmlReturn_t (*NVML_DEVICE_GET_FAN_SPEED
) (nvmlDevice_t
, unsigned int *);
65 typedef nvmlReturn_t (*NVML_DEVICE_GET_POWER_USAGE
) (nvmlDevice_t
, unsigned int *);
66 typedef nvmlReturn_t (*NVML_DEVICE_GET_UTILIZATION_RATES
) (nvmlDevice_t
, nvmlUtilization_t
*);
68 nvmlReturn_t
hc_NVML_nvmlInit (HM_LIB hDLL
);
69 nvmlReturn_t
hc_NVML_nvmlShutdown (HM_LIB hDLL
);
70 nvmlReturn_t
hc_NVML_nvmlDeviceGetName (HM_LIB hDLL
, nvmlDevice_t device
, char *name
, unsigned int length
);
71 nvmlReturn_t
hc_NVML_nvmlDeviceGetHandleByIndex (HM_LIB hDLL
, int, unsigned int index
, nvmlDevice_t
*device
);
72 nvmlReturn_t
hc_NVML_nvmlDeviceGetTemperature (HM_LIB hDLL
, nvmlDevice_t device
, nvmlTemperatureSensors_t sensorType
, unsigned int *temp
);
73 nvmlReturn_t
hc_NVML_nvmlDeviceGetFanSpeed (HM_LIB hDLL
, int, nvmlDevice_t device
, unsigned int *speed
);
74 nvmlReturn_t
hc_NVML_nvmlDeviceGetPowerUsage (HM_LIB hDLL
, nvmlDevice_t device
, unsigned int *power
);
75 nvmlReturn_t
hc_NVML_nvmlDeviceGetUtilizationRates (HM_LIB hDLL
, nvmlDevice_t device
, nvmlUtilization_t
*utilization
);
77 #endif // HAVE_HWMON && HAVE_NVML