forked from NVIDIA/k8s-device-plugin
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdevice.go
97 lines (85 loc) · 2.49 KB
/
device.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
package main
import (
"github.com/NVIDIA/gpu-monitoring-tools/bindings/go/nvml"
)
// Topology defined the whole topology for the node
type Topology struct {
SystemInfo HostSystemInfo `json:"systemInfo"`
CPUInfo HostCPUInfo `json:"cpuInfo"`
CPUPkg []HostCPUPackage `json:"cpuPkg"`
MemorySize int64 `json:"memorySize"`
NumaInfo *HostNumaInfo `json:"numaInfo,omitempty"`
SmcPresent *bool `json:"smcPresent"`
GPUDevice []*nvml.Device `json:"gpuDevice,omitempty"`
}
// HostSystemInfo define system info
type HostSystemInfo struct {
Vendor string `json:"vendor"`
Model string `json:"model"`
UUID string `json:"uuid"`
SerialNumber string `json:"serialNumber,omitempty"`
OSName string `json:"osName"`
OSRelease string `json:"osRelease"`
OSVersion string `json:"osVersion"`
Architecture string `json:"architecture"`
}
// HostCPUInfo define CPU info
type HostCPUInfo struct {
NumCPUPackages int16
NumCPUCores int16
NumCPUThreads int16
Hz int64
}
// HostCPUPackage define CPU package
type HostCPUPackage struct {
Index int16
Vendor string
FamilyNumber int16
ModelNumber int16
Model string
Stepping int16
}
// HostCPUCacheType define CPU cache type
type HostCPUCacheType int
const (
// HostCPUL1Cache Level 1 Data (or Unified) Cache.
HostCPUL1Cache HostCPUCacheType = iota
// HostCPUL2Cache Level 2 Data (or Unified) Cache.
HostCPUL2Cache
// HostCPUL3Cache Level 3 Data (or Unified) Cache.
HostCPUL3Cache
// HostCPUL4Cache Level 4 Data (or Unified) Cache.
HostCPUL4Cache
// HostCPUL5Cache Level 5 Data (or Unified) Cache.
HostCPUL5Cache
// HostCPUL1iCache Level 1 instruction Cache.
HostCPUL1iCache
// HostCPUL2iCache Level 2 instruction Cache.
HostCPUL2iCache
// HostCPUL3iCache Level 3 instruction Cache.
HostCPUL3iCache
)
type HostCPUCache struct {
Size uint64
Depth int
LineSize int
Associativity int
Type HostCPUCacheType
}
type HostCPUCore struct {
ProcessUnits []HostCPUProcessUnit
}
type HostCPUProcessUnit struct {
}
type HostNumaInfo struct {
Type string `json:"type"`
NumNodes int32 `json:"numNodes"`
NumaNode []HostNumaNode `json:"numaNode,omitempty"`
}
// HostNumaNode defined numa node spec
type HostNumaNode struct {
TypeID byte `json:"typeId"`
CPUID []int16 `json:"cpuID"`
MemoryRangeBegin int64 `json:"memoryRangeBegin"`
MemoryRangeLength int64 `json:"memoryRangeLength"`
}