-
Notifications
You must be signed in to change notification settings - Fork 14
/
types.go
265 lines (216 loc) · 5.5 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
// +build !windows
/*
* Tencent is pleased to support the open source community by making TKEStack available.
*
* Copyright (C) 2012-2019 Tencent. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at
*
* https://opensource.org/licenses/Apache-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package nvml
// #cgo CFLAGS: -I/usr/local/cuda/include
// #include "nvml_dl.h"
import "C"
import "time"
const (
szDriver = C.NVML_SYSTEM_DRIVER_VERSION_BUFFER_SIZE
szName = C.NVML_DEVICE_NAME_BUFFER_SIZE
szUUID = C.NVML_DEVICE_UUID_BUFFER_SIZE
szProcName = 64
OP_SUCCESS = C.NVML_SUCCESS
OP_INSUFFICIENT_SIZE = C.NVML_ERROR_INSUFFICIENT_SIZE
OP_TIMEOUT = C.NVML_ERROR_TIMEOUT
maxDevices = 128
)
type RestrictedAPI int
const (
RESTRICTED_API_SET_APPLICATION_CLOCKS RestrictedAPI = iota
RESTRICTED_API_SET_AUTO_BOOSTED_CLOCKS
RESTRICTED_API_COUNT
)
type ClockType int
const (
CLOCK_GRAPHICS ClockType = iota
CLOCK_SM
CLOCK_MEM
CLOCK_COUNT
)
type BrandType int
const (
BRAND_UNKNOWN BrandType = iota
BRAND_QUADRO
BRAND_TESLA
BRAND_NVS
BRAND_GRID
BRAND_GEFORCE
BRAND_COUNT
)
type GpuHandle struct{ dev C.nvmlDevice_t }
type BridgeChipInfo struct {
FwVersion uint
Type BridgeChipType
}
type BridgeChipType int
const (
BRIDGE_CHIP_PLX BridgeChipType = iota
BRIDGE_CHIP_BRO4
)
type ComputeMode int
const (
COMPUTEMODE_DEFAULT ComputeMode = iota
COMPUTEMODE_EXCLUSIVE_THREAD
COMPUTEMODE_PROHIBITED
COMPUTEMODE_EXCLUSIVE_PROCESS
COMPUTEMODE_COUNT
)
type ProcessInfo struct {
Pid uint
UsedGPUMemory uint64
}
type ClocksThrottleReasons uint64
const (
ClocksThrottleReasonAll ClocksThrottleReasons = ClocksThrottleReasonApplicationsClocksSetting |
ClocksThrottleReasonGpuIdle |
ClocksThrottleReasonHwSlowdown |
ClocksThrottleReasonNone |
ClocksThrottleReasonSwPowerCap |
ClocksThrottleReasonUnknown
ClocksThrottleReasonApplicationsClocksSetting = 0x0000000000000002
ClocksThrottleReasonGpuIdle = 0x0000000000000001
ClocksThrottleReasonHwSlowdown = 0x0000000000000008
ClocksThrottleReasonNone = 0x0000000000000000
ClocksThrottleReasonSwPowerCap = 0x0000000000000004
ClocksThrottleReasonUnknown = 0x8000000000000000
)
type MemoryErrorType int
const (
MEMORY_ERROR_TYPE_CORRECTED MemoryErrorType = iota
MEMORY_ERROR_TYPE_UNCORRECTED
MEMORY_ERROR_TYPE_COUNT
)
type EccCounterType int
const (
VOLATILE_ECC EccCounterType = iota
AGGREGATE_ECC
ECC_COUNTER_TYPE_COUNT
)
type EccErrorCounts struct {
DeviceMemory uint64
L1Cache uint64
L2Cache uint64
RegisterFile uint64
}
type GpuOperationMode int
const (
GOM_ALL_ON GpuOperationMode = iota
GOM_COMPUTE
GOM_LOW_DP
GOM_UNKNOWN
)
type PciInfo struct {
BusID string
Domain uint
Bus uint
Device uint
PciDeviceID uint
PciSubSystemID uint
}
type InforomObject int
const (
INFOROM_OEM InforomObject = iota
INFOROM_ECC
INFOROM_POWER
INFOROM_COUNT
)
type MemoryLocation int
const (
MEMORY_LOCATION_L1_CACHE = iota
MEMORY_LOCATION_L2_CACHE
MEMORY_LOCATION_DEVICE_MEMORY
MEMORY_LOCATION_REGISTER_FILE
MEMORY_LOCATION_TEXTURE_MEMORY
MEMORY_LOCATION_COUNT
)
type PcieUtilCounter int
const (
PCIE_UTIL_TX_BYTES PcieUtilCounter = iota
PCIE_UTIL_RX_BYTES
PCIE_UTIL_COUNT
)
type PageRetirementCause int
const (
PAGE_RETIREMENT_CAUSE_MULTIPLE_SINGLE_BIT_ECC_ERRORS PageRetirementCause = iota
PAGE_RETIREMENT_CAUSE_DOUBLE_BIT_ECC_ERROR
PAGE_RETIREMENT_CAUSE_COUNT
)
type TemperatureThresholds int
const (
TEMPERATURE_THRESHOLD_SHUTDOWN TemperatureThresholds = iota
TEMPERATURE_THRESHOLD_SLOWDOWN
TEMPERATURE_THRESHOLD_COUNT
)
type GpuTopologyLevel int
const (
TOPOLOGY_INTERNAL GpuTopologyLevel = iota
TOPOLOGY_SINGLE = 10
TOPOLOGY_MULTIPLE = 20
TOPOLOGY_HOSTBRIDGE = 30
TOPOLOGY_CPU = 40
TOPOLOGY_SYSTEM = 50
TOPOLOGY_UNKNOWN = 60
)
type Utilization struct {
GPU uint
Memory uint
}
type PerfPolicy int
const (
PERF_POLICY_POWER PerfPolicy = iota
PERF_POLICY_THERMAL
PERF_POLICY_COUNT
)
type ViolationTime struct {
ReferTime time.Duration
ViolationTime time.Duration
}
type HwbcEntry struct {
ID uint
FwVersion string
}
type ProcessUtilizationSample struct {
Pid uint
TimeStamp time.Duration
SmUtil uint
MemUtil uint
EncUtil uint
DecUtil uint
}
type EventSet struct{ set C.nvmlEventSet_t }
type EventType uint64
const (
EventTypeAll EventType = EventTypeNone |
EventTypeSingleBitEccError |
EventTypeDoubleBitEccError |
EventTypePState |
EventTypeXidCriticalError |
EventTypeClock
EventTypeNone = 0x0000000000000000
EventTypeSingleBitEccError = 0x0000000000000001
EventTypeDoubleBitEccError = 0x0000000000000002
EventTypePState = 0x0000000000000004
EventTypeXidCriticalError = 0x0000000000000008
EventTypeClock = 0x0000000000000010
)
type EventData struct {
Device GpuHandle
Data uint64
Types []EventType
}