Initial commit
[hashcat.git] / src / ext_nvml.c
1 /**
2 * Author......: Jens Steube <jens.steube@gmail.com>
3 * License.....: MIT
4 */
5
6 #include <ext_nvml.h>
7
8 nvmlReturn_t hc_NVML_nvmlInit (void)
9 {
10 nvmlReturn_t nvml_rc = nvmlInit ();
11
12 if (nvml_rc != NVML_SUCCESS)
13 {
14 const char *string = nvmlErrorString (nvml_rc);
15
16 log_info ("WARN: %s %d %s\n", "nvmlInit()", nvml_rc, string);
17 }
18
19 return nvml_rc;
20 }
21
22 nvmlReturn_t hc_NVML_nvmlShutdown (void)
23 {
24 nvmlReturn_t nvml_rc = nvmlShutdown ();
25
26 if (nvml_rc != NVML_SUCCESS)
27 {
28 const char *string = nvmlErrorString (nvml_rc);
29
30 log_info ("WARN: %s %d %s\n", "nvmlShutdown()", nvml_rc, string);
31 }
32
33 return nvml_rc;
34 }
35
36 nvmlReturn_t hc_NVML_nvmlDeviceGetName (nvmlDevice_t device, char *name, unsigned int length)
37 {
38 nvmlReturn_t nvml_rc = nvmlDeviceGetName (device, name, length);
39
40 if (nvml_rc != NVML_SUCCESS)
41 {
42 const char *string = nvmlErrorString (nvml_rc);
43
44 log_info ("WARN: %s %d %s\n", "nvmlDeviceGetName()", nvml_rc, string);
45 }
46
47 return nvml_rc;
48 }
49
50 nvmlReturn_t hc_NVML_nvmlDeviceGetHandleByIndex (unsigned int index, nvmlDevice_t *device)
51 {
52 nvmlReturn_t nvml_rc = nvmlDeviceGetHandleByIndex (index, device);
53
54 if (nvml_rc != NVML_SUCCESS)
55 {
56 const char *string = nvmlErrorString (nvml_rc);
57
58 log_info ("WARN: %s %d %s\n", "nvmlDeviceGetHandleByIndex()", nvml_rc, string);
59 }
60
61 return nvml_rc;
62 }
63
64 nvmlReturn_t hc_NVML_nvmlDeviceGetTemperature (nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp)
65 {
66 nvmlReturn_t nvml_rc = nvmlDeviceGetTemperature (device, sensorType, temp);
67
68 if (nvml_rc != NVML_SUCCESS)
69 {
70 *temp = -1;
71
72 //const char *string = nvmlErrorString (nvml_rc);
73
74 //log_info ("WARN: %s %d %s\n", "nvmlDeviceGetTemperature()", nvml_rc, string);
75 }
76
77 return nvml_rc;
78 }
79
80 nvmlReturn_t hc_NVML_nvmlDeviceGetFanSpeed (nvmlDevice_t device, unsigned int *speed)
81 {
82 nvmlReturn_t nvml_rc = nvmlDeviceGetFanSpeed (device, speed);
83
84 if (nvml_rc != NVML_SUCCESS)
85 {
86 *speed = -1;
87
88 //const char *string = nvmlErrorString (nvml_rc);
89
90 //log_info ("WARN: %s %d %s\n", "nvmlDeviceGetFanSpeed()", nvml_rc, string);
91 }
92
93 return nvml_rc;
94 }
95
96 /* only tesla following */
97
98 nvmlReturn_t hc_NVML_nvmlDeviceGetPowerUsage (nvmlDevice_t device, unsigned int *power)
99 {
100 nvmlReturn_t nvml_rc = nvmlDeviceGetPowerUsage (device, power);
101
102 if (nvml_rc != NVML_SUCCESS)
103 {
104 *power = -1;
105
106 //const char *string = nvmlErrorString (nvml_rc);
107
108 //log_info ("WARN: %s %d %s\n", "nvmlDeviceGetPowerUsage()", nvml_rc, string);
109 }
110
111 return nvml_rc;
112 }
113
114 nvmlReturn_t hc_NVML_nvmlDeviceGetUtilizationRates (nvmlDevice_t device, nvmlUtilization_t *utilization)
115 {
116 nvmlReturn_t nvml_rc = nvmlDeviceGetUtilizationRates (device, utilization);
117
118 if (nvml_rc != NVML_SUCCESS)
119 {
120 utilization->gpu = -1;
121 utilization->memory = -1;
122
123 //const char *string = nvmlErrorString (nvml_rc);
124
125 //log_info ("WARN: %s %d %s\n", "nvmlDeviceGetUtilizationRates()", nvml_rc, string);
126 }
127
128 return nvml_rc;
129 }