gpustack-runtime 0.1.40.post1__py3-none-any.whl → 0.1.41.post1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gpustack_runtime/__init__.py +1 -1
- gpustack_runtime/__main__.py +5 -3
- gpustack_runtime/_version.py +2 -2
- gpustack_runtime/_version_appendix.py +1 -1
- gpustack_runtime/cmds/__init__.py +5 -3
- gpustack_runtime/cmds/__types__.py +1 -1
- gpustack_runtime/cmds/deployer.py +140 -18
- gpustack_runtime/cmds/detector.py +1 -1
- gpustack_runtime/cmds/images.py +1 -1
- gpustack_runtime/deployer/__init__.py +28 -2
- gpustack_runtime/deployer/__patches__.py +1 -1
- gpustack_runtime/deployer/__types__.py +2 -1
- gpustack_runtime/deployer/__utils__.py +2 -2
- gpustack_runtime/deployer/cdi/__init__.py +86 -5
- gpustack_runtime/deployer/cdi/__types__.py +92 -29
- gpustack_runtime/deployer/cdi/__utils__.py +180 -0
- gpustack_runtime/deployer/cdi/amd.py +146 -0
- gpustack_runtime/deployer/cdi/ascend.py +164 -0
- gpustack_runtime/deployer/cdi/hygon.py +147 -0
- gpustack_runtime/deployer/cdi/iluvatar.py +136 -0
- gpustack_runtime/deployer/cdi/metax.py +148 -0
- gpustack_runtime/deployer/cdi/thead.py +57 -23
- gpustack_runtime/deployer/docker.py +9 -8
- gpustack_runtime/deployer/k8s/deviceplugin/__init__.py +325 -0
- gpustack_runtime/deployer/k8s/deviceplugin/__types__.py +131 -0
- gpustack_runtime/deployer/k8s/deviceplugin/plugin.py +590 -0
- gpustack_runtime/deployer/k8s/types/kubelet/deviceplugin/v1beta1/__init__.py +3 -0
- gpustack_runtime/deployer/k8s/types/kubelet/deviceplugin/v1beta1/api.proto +212 -0
- gpustack_runtime/deployer/k8s/types/kubelet/deviceplugin/v1beta1/api_pb2.py +86 -0
- gpustack_runtime/deployer/k8s/types/kubelet/deviceplugin/v1beta1/api_pb2.pyi +168 -0
- gpustack_runtime/deployer/k8s/types/kubelet/deviceplugin/v1beta1/api_pb2_grpc.py +358 -0
- gpustack_runtime/deployer/k8s/types/kubelet/deviceplugin/v1beta1/constants.py +34 -0
- gpustack_runtime/deployer/kuberentes.py +50 -4
- gpustack_runtime/deployer/podman.py +9 -8
- gpustack_runtime/detector/__init__.py +42 -5
- gpustack_runtime/detector/__types__.py +8 -24
- gpustack_runtime/detector/__utils__.py +46 -39
- gpustack_runtime/detector/amd.py +55 -66
- gpustack_runtime/detector/ascend.py +29 -41
- gpustack_runtime/detector/cambricon.py +3 -3
- gpustack_runtime/detector/hygon.py +21 -49
- gpustack_runtime/detector/iluvatar.py +44 -60
- gpustack_runtime/detector/metax.py +54 -37
- gpustack_runtime/detector/mthreads.py +74 -36
- gpustack_runtime/detector/nvidia.py +130 -93
- gpustack_runtime/detector/pyacl/__init__.py +1 -1
- gpustack_runtime/detector/pyamdgpu/__init__.py +1 -1
- gpustack_runtime/detector/pyamdsmi/__init__.py +1 -1
- gpustack_runtime/detector/pycuda/__init__.py +1 -1
- gpustack_runtime/detector/pydcmi/__init__.py +1 -1
- gpustack_runtime/detector/pyhsa/__init__.py +1 -1
- gpustack_runtime/detector/pymxsml/__init__.py +1553 -1
- gpustack_runtime/detector/pyrocmcore/__init__.py +1 -1
- gpustack_runtime/detector/pyrocmsmi/__init__.py +1 -1
- gpustack_runtime/detector/thead.py +41 -60
- gpustack_runtime/envs.py +106 -12
- gpustack_runtime/logging.py +6 -2
- {gpustack_runtime-0.1.40.post1.dist-info → gpustack_runtime-0.1.41.post1.dist-info}/METADATA +6 -1
- gpustack_runtime-0.1.41.post1.dist-info/RECORD +67 -0
- gpustack_runtime/detector/pymxsml/mxsml.py +0 -1580
- gpustack_runtime/detector/pymxsml/mxsml_extension.py +0 -816
- gpustack_runtime/detector/pymxsml/mxsml_mcm.py +0 -476
- gpustack_runtime-0.1.40.post1.dist-info/RECORD +0 -55
- {gpustack_runtime-0.1.40.post1.dist-info → gpustack_runtime-0.1.41.post1.dist-info}/WHEEL +0 -0
- {gpustack_runtime-0.1.40.post1.dist-info → gpustack_runtime-0.1.41.post1.dist-info}/entry_points.txt +0 -0
- {gpustack_runtime-0.1.40.post1.dist-info → gpustack_runtime-0.1.41.post1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,816 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Copyright © 2024 MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights Reserved.
|
|
3
|
-
|
|
4
|
-
This software and associated documentation files (hereinafter collectively referred to as
|
|
5
|
-
"Software") is a proprietary commercial software developed by MetaX Integrated Circuits
|
|
6
|
-
(Shanghai) Co., Ltd. and/or its affiliates (hereinafter collectively referred to as “MetaX”).
|
|
7
|
-
The information presented in the Software belongs to MetaX. Without prior written permission
|
|
8
|
-
from MetaX, no entity or individual has the right to obtain a copy of the Software to deal in
|
|
9
|
-
the Software, including but not limited to use, copy, modify, merge, disclose, publish,
|
|
10
|
-
distribute, sublicense, and/or sell copies of the Software or substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
The Software is provided for reference only, without warranty of any kind, either express or
|
|
13
|
-
implied, including but not limited to the warranty of merchantability, fitness for any purpose
|
|
14
|
-
and/or noninfringement. In no case shall MetaX be liable for any claim, damage or other liability
|
|
15
|
-
arising from, out of or in connection with the Software.
|
|
16
|
-
|
|
17
|
-
If the Software need to be used in conjunction with any third-party software or open source
|
|
18
|
-
software, the rights to the third-party software or open source software still belong to the
|
|
19
|
-
copyright owners. For details, please refer to the respective notices or licenses. Please comply
|
|
20
|
-
with the provisions of the relevant notices or licenses. If the open source software licenses
|
|
21
|
-
additionally require the disposal of rights related to this Software, please contact MetaX
|
|
22
|
-
immediately and obtain MetaX 's written consent.
|
|
23
|
-
|
|
24
|
-
MetaX reserves the right, at its sole discretion, to change, modify, add or remove portions of the
|
|
25
|
-
Software, at any time. MetaX reserves all the right for the final explanation.
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
# Python bindings for the MXSML library
|
|
29
|
-
from ctypes import *
|
|
30
|
-
import sys
|
|
31
|
-
import string
|
|
32
|
-
from .mxsml import convertStrBytes, _searchMxsmlLibrary
|
|
33
|
-
from .mxsml import _MxsmlBaseStructure as _MxsmlExBaseStructure
|
|
34
|
-
from .mxsml import mxsmlFriendlyObject as mxSmlExFriendlyOnject
|
|
35
|
-
from .mxsml import mxsmlStructToFriendlyObject as mxSmlExStructToFriendlyObject
|
|
36
|
-
from .mxsml import mxsmlFriendlyObjectToStruct as mxSmlExFriendlyObjectToStruct
|
|
37
|
-
|
|
38
|
-
# C Type mappings
|
|
39
|
-
# Enums
|
|
40
|
-
_mxSmlExEnableState_t = c_uint
|
|
41
|
-
MXSMLEX_FEATURE_DISABLED = 0
|
|
42
|
-
MXSMLEX_FEATURE_ENABLED = 1
|
|
43
|
-
|
|
44
|
-
_mxSmlExTemperatureSensors_t = c_uint
|
|
45
|
-
MXSMLEX_TEMPERATURE_GPU = 0
|
|
46
|
-
MXSMLEX_TEMPERATURE_COUNT = 1
|
|
47
|
-
|
|
48
|
-
_mxSmlExPcieUtilCounter_t = c_uint
|
|
49
|
-
MXSMLEX_PCIE_UTIL_TX_BYTES = 0
|
|
50
|
-
MXSMLEX_PCIE_UTIL_RX_BYTES = 1
|
|
51
|
-
MXSMLEX_PCIE_UTIL_COUNT = 2
|
|
52
|
-
|
|
53
|
-
_mxSmlExTemperatureThresholds_t = c_uint
|
|
54
|
-
MXSMLEX_TEMPERATURE_THRESHOLD_SHUTDOWN = 0
|
|
55
|
-
MXSMLEX_TEMPERATURE_THRESHOLD_SLOWDOWN = 1
|
|
56
|
-
MXSMLEX_TEMPERATURE_THRESHOLD_MEM_MAX = 2
|
|
57
|
-
MXSMLEX_TEMPERATURE_THRESHOLD_GPU_MAX = 3
|
|
58
|
-
MXSMLEX_TEMPERATURE_THRESHOLD_ACOUSTIC_MIN = 4
|
|
59
|
-
MXSMLEX_TEMPERATURE_THRESHOLD_ACOUSTIC_CURR = 5
|
|
60
|
-
MXSMLEX_TEMPERATURE_THRESHOLD_ACOUSTIC_MAX = 6
|
|
61
|
-
MXSMLEX_TEMPERATURE_THRESHOLD_COUNT = 7
|
|
62
|
-
|
|
63
|
-
_mxSmlExClockType_t = c_uint
|
|
64
|
-
MXSMLEX_CLOCK_GRAPHICS = 0
|
|
65
|
-
MXSMLEX_CLOCK_SM = 1
|
|
66
|
-
MXSMLEX_CLOCK_MEM = 2
|
|
67
|
-
MXSMLEX_CLOCK_VIDEO = 3
|
|
68
|
-
MXSMLEX_CLOCK_COUNT = 4
|
|
69
|
-
|
|
70
|
-
_mxSmlExGpuP2PStatus_t = c_uint
|
|
71
|
-
MXSMLEX_P2P_STATUS_OK = 0
|
|
72
|
-
MXSMLEX_P2P_STATUS_CHIPSET_NOT_SUPPORTED = 1
|
|
73
|
-
MXSMLEX_P2P_STATUS_GPU_NOT_SUPPORTED = 2
|
|
74
|
-
MXSMLEX_P2P_STATUS_IOH_TOPOLOGY_NOT_SUPPORTED = 3
|
|
75
|
-
MXSMLEX_P2P_STATUS_DISABLED_BY_REGKEY = 4
|
|
76
|
-
MXSMLEX_P2P_STATUS_NOT_SUPPORTED = 5
|
|
77
|
-
MXSMLEX_P2P_STATUS_UNKNOWN = 6
|
|
78
|
-
|
|
79
|
-
_mxSmlExGpuP2PCapsIndex_t = c_uint
|
|
80
|
-
MXSMLEX_P2P_CAPS_INDEX_READ = 0
|
|
81
|
-
MXSMLEX_P2P_CAPS_INDEX_WRITE = 1
|
|
82
|
-
MXSMLEX_P2P_CAPS_INDEX_MXLINK = 2
|
|
83
|
-
MXSMLEX_P2P_CAPS_INDEX_ATOMICS = 3
|
|
84
|
-
MXSMLEX_P2P_CAPS_INDEX_PROP = 4
|
|
85
|
-
MXSMLEX_P2P_CAPS_INDEX_UNKNOWN = 5
|
|
86
|
-
|
|
87
|
-
_mxSmlExPstates_t = c_uint
|
|
88
|
-
MXSMLEX_PSTATE_0 = 0 # Performance state 0 -- Maximum Performance.
|
|
89
|
-
MXSMLEX_PSTATE_1 = 1
|
|
90
|
-
MXSMLEX_PSTATE_2 = 2
|
|
91
|
-
MXSMLEX_PSTATE_3 = 3
|
|
92
|
-
MXSMLEX_PSTATE_4 = 4
|
|
93
|
-
MXSMLEX_PSTATE_5 = 5
|
|
94
|
-
MXSMLEX_PSTATE_6 = 6
|
|
95
|
-
MXSMLEX_PSTATE_7 = 7
|
|
96
|
-
MXSMLEX_PSTATE_8 = 8
|
|
97
|
-
MXSMLEX_PSTATE_9 = 9
|
|
98
|
-
MXSMLEX_PSTATE_10 = 10
|
|
99
|
-
MXSMLEX_PSTATE_11 = 11
|
|
100
|
-
MXSMLEX_PSTATE_12 = 12
|
|
101
|
-
MXSMLEX_PSTATE_13 = 13
|
|
102
|
-
MXSMLEX_PSTATE_14 = 14
|
|
103
|
-
MXSMLEX_PSTATE_15 = 15 # Performance state 15 -- Minimum Performance.
|
|
104
|
-
MXSMLEX_PSTATE_UNKNOWN = 32 # Unknown performance state.
|
|
105
|
-
|
|
106
|
-
_mxSmlExGpuTopologyLevel_t = c_uint
|
|
107
|
-
MXSMLEX_TOPOLOGY_INTERNAL = 0
|
|
108
|
-
MXSMLEX_TOPOLOGY_SINGLE = 10
|
|
109
|
-
MXSMLEX_TOPOLOGY_MULTIPLE = 20
|
|
110
|
-
MXSMLEX_TOPOLOGY_HOSTBRIDGE = 30
|
|
111
|
-
MXSMLEX_TOPOLOGY_NODE = 40
|
|
112
|
-
MXSMLEX_TOPOLOGY_SYSTEM = 50
|
|
113
|
-
|
|
114
|
-
_mxSmlExMetaXLinkDeviceType_t = c_uint
|
|
115
|
-
MXSMLEX_METAXLINK_DEVICE_TYPE_GPU = 0x00
|
|
116
|
-
MXSMLEX_METAXLINK_DEVICE_TYPE_NPU = 0x01
|
|
117
|
-
MXSMLEX_METAXLINK_DEVICE_TYPE_SWITCH = 0x02
|
|
118
|
-
MXSMLEX_METAXLINK_DEVICE_TYPE_UNKNOWN = 0xFF
|
|
119
|
-
|
|
120
|
-
_mxSmlExValueType_t = c_uint
|
|
121
|
-
MXSMLEX_VALUE_TYPE_DOUBLE = 0
|
|
122
|
-
MXSMLEX_VALUE_TYPE_UNSIGNED_INT = 1
|
|
123
|
-
MXSMLEX_VALUE_TYPE_UNSIGNED_LONG = 2
|
|
124
|
-
MXSMLEX_VALUE_TYPE_UNSIGNED_LONG_LONG = 3
|
|
125
|
-
MXSMLEX_VALUE_TYPE_SIGNED_LONG_LONG = 4
|
|
126
|
-
MXSMLEX_VALUE_TYPE_SIGNED_INT = 5
|
|
127
|
-
MXSMLEX_VALUE_TYPE_COUNT = 6
|
|
128
|
-
|
|
129
|
-
_mxSmlExReturn_t = c_uint
|
|
130
|
-
MXSMLEX_SUCCESS = 0
|
|
131
|
-
MXSMLEX_ERROR_UNINITIALIZED = 1
|
|
132
|
-
MXSMLEX_ERROR_INVALID_ARGUMENT = 2
|
|
133
|
-
MXSMLEX_ERROR_NOT_SUPPORTED = 3
|
|
134
|
-
MXSMLEX_ERROR_NO_PERMISSION = 4
|
|
135
|
-
MXSMLEX_ERROR_ALREADY_INITIALIZED = 5
|
|
136
|
-
MXSMLEX_ERROR_NOT_FOUND = 6
|
|
137
|
-
MXSMLEX_ERROR_INSUFFICIENT_SIZE = 7
|
|
138
|
-
MXSMLEX_ERROR_INSUFFICIENT_POWER = 8
|
|
139
|
-
MXSMLEX_ERROR_DRIVER_NOT_LOADED = 9
|
|
140
|
-
MXSMLEX_ERROR_TIMEOUT = 10
|
|
141
|
-
MXSMLEX_ERROR_IRQ_ISSUE = 11
|
|
142
|
-
MXSMLEX_ERROR_LIBRARY_NOT_FOUND = 12
|
|
143
|
-
MXSMLEX_ERROR_FUNCTION_NOT_FOUND = 13
|
|
144
|
-
MXSMLEX_ERROR_CORRUPTED_INFOROM = 14
|
|
145
|
-
MXSMLEX_ERROR_GPU_IS_LOST = 15
|
|
146
|
-
MXSMLEX_ERROR_RESET_REQUIRED = 16
|
|
147
|
-
MXSMLEX_ERROR_OPERATING_SYSTEM = 17
|
|
148
|
-
MXSMLEX_ERROR_LIB_RM_VERSION_MISMATCH = 18
|
|
149
|
-
MXSMLEX_ERROR_IN_USE = 19
|
|
150
|
-
MXSMLEX_ERROR_MEMORY = 20
|
|
151
|
-
MXSMLEX_ERROR_NO_DATA = 21
|
|
152
|
-
MXSMLEX_ERROR_VGPU_ECC_NOT_SUPPORTED = 22
|
|
153
|
-
MXSMLEX_ERROR_INSUFFICIENT_RESOURCES = 23
|
|
154
|
-
MXSMLEX_ERROR_FREQ_NOT_SUPPORTED = 24
|
|
155
|
-
MXSMLEX_ERROR_ARGUMENT_VERSION_MISMATCH = 25
|
|
156
|
-
MXSMLEX_ERROR_DEPRECATED = 26
|
|
157
|
-
MXSMLEX_ERROR_UNKNOWN = 999
|
|
158
|
-
|
|
159
|
-
# buffer size
|
|
160
|
-
MXSMLEX_DEVICE_UUID_BUFFER_SIZE = 80 # Guaranteed maximum possible size for device UUID
|
|
161
|
-
MXSMLEX_DEVICE_UUID_V2_BUFFER_SIZE = 96
|
|
162
|
-
MXSMLEX_NAME_V2_BUFFER_SIZE = 96
|
|
163
|
-
MXSMLEX_DRIVER_VERSION_BUFFER_SIZE = (
|
|
164
|
-
80 # Guaranteed maximum possible size for driver version
|
|
165
|
-
)
|
|
166
|
-
MXSMLEX_SYSTEM_MXSMLEX_VERSION_BUFFER_SIZE = 80
|
|
167
|
-
MXSMLEX_DBDF_ID_BUFFER_V2_SIZE = (
|
|
168
|
-
16 # Guaranteed maximum possible size for BDF ID legacy
|
|
169
|
-
)
|
|
170
|
-
MXSMLEX_DBDF_ID_BUFFER_SIZE = 32 # Guaranteed maximum possible size for BDF ID
|
|
171
|
-
|
|
172
|
-
MXSMLEX_FI_DEV_METAXLINK_LINK_COUNT = (
|
|
173
|
-
91 # Field value enums used to query MetaXLink number
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
## Error Checking ##
|
|
178
|
-
class MXSMLEXError(Exception):
|
|
179
|
-
_valClassMapping = dict()
|
|
180
|
-
_errcode_to_string = {
|
|
181
|
-
MXSMLEX_ERROR_UNINITIALIZED: "Uninitialized",
|
|
182
|
-
MXSMLEX_ERROR_INVALID_ARGUMENT: "Invalid Argument",
|
|
183
|
-
MXSMLEX_ERROR_NOT_SUPPORTED: "Not Supported",
|
|
184
|
-
MXSMLEX_ERROR_NO_PERMISSION: "Insufficient Permissions",
|
|
185
|
-
MXSMLEX_ERROR_ALREADY_INITIALIZED: "Already Initialized",
|
|
186
|
-
MXSMLEX_ERROR_NOT_FOUND: "Not Found",
|
|
187
|
-
MXSMLEX_ERROR_INSUFFICIENT_SIZE: "Insufficient Size",
|
|
188
|
-
MXSMLEX_ERROR_INSUFFICIENT_POWER: "Insufficient External Power",
|
|
189
|
-
MXSMLEX_ERROR_DRIVER_NOT_LOADED: "Driver Not Loaded",
|
|
190
|
-
MXSMLEX_ERROR_TIMEOUT: "Timeout",
|
|
191
|
-
MXSMLEX_ERROR_IRQ_ISSUE: "Interrupt Request Issue",
|
|
192
|
-
MXSMLEX_ERROR_LIBRARY_NOT_FOUND: "MXSML Shared Library Not Found",
|
|
193
|
-
MXSMLEX_ERROR_FUNCTION_NOT_FOUND: "Function Not Found",
|
|
194
|
-
MXSMLEX_ERROR_CORRUPTED_INFOROM: "Corrupted infoROM",
|
|
195
|
-
MXSMLEX_ERROR_GPU_IS_LOST: "GPU is lost",
|
|
196
|
-
MXSMLEX_ERROR_RESET_REQUIRED: "GPU requires restart",
|
|
197
|
-
MXSMLEX_ERROR_OPERATING_SYSTEM: "The operating system has blocked the request.",
|
|
198
|
-
MXSMLEX_ERROR_LIB_RM_VERSION_MISMATCH: "RM has detected an MXSML/RM version mismatch.",
|
|
199
|
-
MXSMLEX_ERROR_MEMORY: "Insufficient Memory",
|
|
200
|
-
MXSMLEX_ERROR_UNKNOWN: "Unknown Error",
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
def __new__(typ, value):
|
|
204
|
-
if typ == MXSMLEXError:
|
|
205
|
-
typ = MXSMLEXError._valClassMapping.get(value, typ)
|
|
206
|
-
obj = Exception.__new__(typ)
|
|
207
|
-
obj.value = value
|
|
208
|
-
return obj
|
|
209
|
-
|
|
210
|
-
def __str__(self):
|
|
211
|
-
try:
|
|
212
|
-
if self.value not in MXSMLEXError._errcode_to_string:
|
|
213
|
-
MXSMLEXError._errcode_to_string[self.value] = str(
|
|
214
|
-
mxSmlExErrorString(self.value)
|
|
215
|
-
)
|
|
216
|
-
return MXSMLEXError._errcode_to_string[self.value]
|
|
217
|
-
except MXSMLEXError:
|
|
218
|
-
return "MXSMLEX Error with code %d" % self.value
|
|
219
|
-
|
|
220
|
-
def __eq__(self, other):
|
|
221
|
-
return self.value == other.value
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
def _generateErrorSubclass():
|
|
225
|
-
# Create execption subclass for each MXSMLEX Error
|
|
226
|
-
def generate_new_func(val):
|
|
227
|
-
def new(typ):
|
|
228
|
-
obj = MXSMLEXError.__new__(typ, val)
|
|
229
|
-
return obj
|
|
230
|
-
|
|
231
|
-
return new
|
|
232
|
-
|
|
233
|
-
this_module = sys.modules[__name__]
|
|
234
|
-
mxsmlErrorsNames = [x for x in dir(this_module) if x.startswith("MXSMLEXError_")]
|
|
235
|
-
for err_name in mxsmlErrorsNames:
|
|
236
|
-
class_name = "MXSMLEXError_" + string.capwords(
|
|
237
|
-
err_name.replace("MXSMLEXError_", ""), "_"
|
|
238
|
-
).replace("_", "")
|
|
239
|
-
err_val = getattr(this_module, err_name)
|
|
240
|
-
new_error_class = type(
|
|
241
|
-
class_name, (MXSMLEXError,), {"__new__": generate_new_func(err_val)}
|
|
242
|
-
)
|
|
243
|
-
new_error_class.__module__ = __name__
|
|
244
|
-
setattr(this_module, class_name, new_error_class)
|
|
245
|
-
MXSMLEXError._valClassMapping[err_val] = new_error_class
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
_generateErrorSubclass()
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
## Device structures
|
|
252
|
-
class struct_c_mxSmlExDevice_t(Structure):
|
|
253
|
-
pass # opaque handle
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
c_mxSmlExDevice_t = POINTER(struct_c_mxSmlExDevice_t)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
class c_mxSmlExMemory_t(_MxsmlExBaseStructure):
|
|
260
|
-
_fields_ = [
|
|
261
|
-
("total", c_ulonglong),
|
|
262
|
-
("free", c_ulonglong),
|
|
263
|
-
("used", c_ulonglong),
|
|
264
|
-
]
|
|
265
|
-
_default_format_ = "%d B"
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
class c_mxSmlExPciInfo_t(_MxsmlExBaseStructure):
|
|
269
|
-
_fields_ = [
|
|
270
|
-
(
|
|
271
|
-
"busIdLegacy",
|
|
272
|
-
c_char * MXSMLEX_DBDF_ID_BUFFER_V2_SIZE,
|
|
273
|
-
), # The legacy tuple domain:bus:device.function PCI identifier
|
|
274
|
-
(
|
|
275
|
-
"domain",
|
|
276
|
-
c_uint,
|
|
277
|
-
), # The PCI domain on which the device's bus resides, 0 to 0xffffffff
|
|
278
|
-
("bus", c_uint), # The bus on which the device resides, 0 to 0xff
|
|
279
|
-
("device", c_uint), # The device's id on the bus, 0 to 31
|
|
280
|
-
("pciDeviceId", c_uint), # The combined 16-bit device id and 16-bit vendor id
|
|
281
|
-
("pciSubSystemId", c_uint), # The 32-bit Sub System Device ID
|
|
282
|
-
(
|
|
283
|
-
"busId",
|
|
284
|
-
c_char * MXSMLEX_DBDF_ID_BUFFER_SIZE,
|
|
285
|
-
), # The tuple domain:bus:device.function PCI identifier
|
|
286
|
-
]
|
|
287
|
-
_format_ = {
|
|
288
|
-
"domain": "0x%08X",
|
|
289
|
-
"bus": "0x%02X",
|
|
290
|
-
"device": "0x%02X",
|
|
291
|
-
"pciDeviceId": "0x%08X",
|
|
292
|
-
"pciSubSystemId": "0x%08X",
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
class c_mxSmlExUtilization_t(_MxsmlExBaseStructure):
|
|
297
|
-
_fields_ = [
|
|
298
|
-
("gpu", c_uint),
|
|
299
|
-
("memory", c_uint),
|
|
300
|
-
]
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
class c_mxsmlExProcessInfo_t(_MxsmlExBaseStructure):
|
|
304
|
-
_fields_ = [
|
|
305
|
-
("computeInstanceId", c_uint),
|
|
306
|
-
("gpuInstanceId", c_uint),
|
|
307
|
-
("pid", c_uint),
|
|
308
|
-
("usedGpuMemory", c_ulonglong),
|
|
309
|
-
]
|
|
310
|
-
_default_format_ = "%dxxx"
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
class c_mxSmlExExcludedDeviceInfo_t(_MxsmlExBaseStructure):
|
|
314
|
-
_fields_ = [
|
|
315
|
-
("pciInfo", c_mxSmlExPciInfo_t),
|
|
316
|
-
("uuid", c_char * MXSMLEX_DEVICE_UUID_BUFFER_SIZE),
|
|
317
|
-
]
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
class c_mxSmlExValue_t(Union):
|
|
321
|
-
_fields_ = [
|
|
322
|
-
("dVal", c_double),
|
|
323
|
-
("siVal", c_int),
|
|
324
|
-
("sllVal", c_longlong),
|
|
325
|
-
("uiVal", c_uint),
|
|
326
|
-
("ulVal", c_ulong),
|
|
327
|
-
("ullVal", c_ulonglong),
|
|
328
|
-
]
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
class c_mxSmlExFieldValue_t(_MxsmlExBaseStructure):
|
|
332
|
-
_fields_ = [
|
|
333
|
-
("fieldId", c_uint),
|
|
334
|
-
("latencyUsec", c_longlong),
|
|
335
|
-
("mxSmlExReturn", _mxSmlExReturn_t),
|
|
336
|
-
("scopeId", c_uint),
|
|
337
|
-
("timestamp", c_longlong),
|
|
338
|
-
("value", c_mxSmlExValue_t),
|
|
339
|
-
("valueType", _mxSmlExValueType_t),
|
|
340
|
-
]
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
class c_mxSmlExSample_t(_MxsmlExBaseStructure):
|
|
344
|
-
_fields_ = [("timeStamp", c_ulonglong), ("sampleValue", c_mxSmlExValue_t)]
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
mxSmlExClocksThrottleReasonAll = 0x00000000000001FF
|
|
348
|
-
mxSmlExClocksThrottleReasonApplicationsClocksSetting = 0x0000000000000002
|
|
349
|
-
mxSmlExClocksThrottleReasonDisplayClockSetting = 0x0000000000000100
|
|
350
|
-
mxSmlExClocksThrottleReasonGpuIdle = 0x0000000000000001
|
|
351
|
-
mxSmlExClocksThrottleReasonHwPowerBrakeSlowdown = 0x0000000000000080
|
|
352
|
-
mxSmlExClocksThrottleReasonHwSlowdown = 0x0000000000000008
|
|
353
|
-
mxSmlExClocksThrottleReasonHwThermalSlowdown = 0x0000000000000040
|
|
354
|
-
mxSmlExClocksThrottleReasonNone = 0x0000000000000000
|
|
355
|
-
mxSmlExClocksThrottleReasonSwPowerCap = 0x0000000000000004
|
|
356
|
-
mxSmlExClocksThrottleReasonSwThermalSlowdown = 0x0000000000000020
|
|
357
|
-
mxSmlExClocksThrottleReasonSyncBoost = 0x0000000000000010
|
|
358
|
-
|
|
359
|
-
## Lib loading ##
|
|
360
|
-
mxSmlExLib = None
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
def _mxsmlExCheckReturn(ret):
|
|
364
|
-
if ret != MXSMLEX_SUCCESS:
|
|
365
|
-
raise MXSMLEXError(ret)
|
|
366
|
-
return ret
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
## Function access ##
|
|
370
|
-
_mxsmlExFunctionPointerCache = (
|
|
371
|
-
dict()
|
|
372
|
-
) # function pointers are cached to prevent unnecessary libLoadLock locking
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
def _mxsmlExGetFunctionPointer(name):
|
|
376
|
-
if name in _mxsmlExFunctionPointerCache:
|
|
377
|
-
return _mxsmlExFunctionPointerCache[name]
|
|
378
|
-
|
|
379
|
-
global mxSmlExLib
|
|
380
|
-
if mxSmlExLib == None:
|
|
381
|
-
raise MXSMLEXError(MXSMLEX_ERROR_UNINITIALIZED)
|
|
382
|
-
try:
|
|
383
|
-
_mxsmlExFunctionPointerCache[name] = getattr(mxSmlExLib, name)
|
|
384
|
-
return _mxsmlExFunctionPointerCache[name]
|
|
385
|
-
except AttributeError:
|
|
386
|
-
raise MXSMLEXError(MXSMLEX_ERROR_FUNCTION_NOT_FOUND)
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
def _loadMxsmlLibrary():
|
|
390
|
-
global mxSmlExLib
|
|
391
|
-
if mxSmlExLib != None:
|
|
392
|
-
return
|
|
393
|
-
|
|
394
|
-
try:
|
|
395
|
-
if sys.platform[:3] == "win":
|
|
396
|
-
_mxsmlExCheckReturn(MXSMLEX_ERROR_NOT_SUPPORTED)
|
|
397
|
-
else:
|
|
398
|
-
path_libmxsml = _searchMxsmlLibrary()
|
|
399
|
-
if not path_libmxsml:
|
|
400
|
-
_mxsmlExCheckReturn(MXSMLEX_ERROR_LIBRARY_NOT_FOUND)
|
|
401
|
-
else:
|
|
402
|
-
mxSmlExLib = CDLL(path_libmxsml)
|
|
403
|
-
except OSError as ose:
|
|
404
|
-
_mxsmlExCheckReturn(MXSMLEX_ERROR_LIBRARY_NOT_FOUND)
|
|
405
|
-
if mxSmlExLib == None:
|
|
406
|
-
_mxsmlExCheckReturn(MXSMLEX_ERROR_LIBRARY_NOT_FOUND)
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
## C function wrappers ##
|
|
410
|
-
def mxSmlExInit():
|
|
411
|
-
_loadMxsmlLibrary()
|
|
412
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExInit")
|
|
413
|
-
ret = fn()
|
|
414
|
-
_mxsmlExCheckReturn(ret)
|
|
415
|
-
return None
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
def mxSmlExShutdown():
|
|
419
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExShutdown")
|
|
420
|
-
ret = fn()
|
|
421
|
-
_mxsmlExCheckReturn(ret)
|
|
422
|
-
return None
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
@convertStrBytes
|
|
426
|
-
def mxSmlExErrorString(result):
|
|
427
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExErrorString")
|
|
428
|
-
fn.restype = c_char_p # otherwise return is an int
|
|
429
|
-
ret = fn(_mxSmlExReturn_t(result))
|
|
430
|
-
return ret
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
## System get functions
|
|
434
|
-
@convertStrBytes
|
|
435
|
-
def mxSmlExSystemGetDriverVersion():
|
|
436
|
-
version = create_string_buffer(MXSMLEX_DRIVER_VERSION_BUFFER_SIZE)
|
|
437
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExSystemGetDriverVersion")
|
|
438
|
-
ret = fn(version, c_uint(MXSMLEX_DRIVER_VERSION_BUFFER_SIZE))
|
|
439
|
-
_mxsmlExCheckReturn(ret)
|
|
440
|
-
return version.value
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
@convertStrBytes
|
|
444
|
-
def mxSmlExSystemGetMXSMLEXVersion():
|
|
445
|
-
version = create_string_buffer(MXSMLEX_SYSTEM_MXSMLEX_VERSION_BUFFER_SIZE)
|
|
446
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExSystemGetMxsmlVersion")
|
|
447
|
-
ret = fn(version, c_uint(MXSMLEX_SYSTEM_MXSMLEX_VERSION_BUFFER_SIZE))
|
|
448
|
-
_mxsmlExCheckReturn(ret)
|
|
449
|
-
return version.value
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
## Device get functions
|
|
453
|
-
def mxSmlExDeviceGetCount():
|
|
454
|
-
device_count = c_uint()
|
|
455
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetCount")
|
|
456
|
-
ret = fn(byref(device_count))
|
|
457
|
-
_mxsmlExCheckReturn(ret)
|
|
458
|
-
return device_count.value
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
def mxSmlExMacaDeviceGetCount():
|
|
462
|
-
device_count = c_uint()
|
|
463
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExMacaDeviceGetCount")
|
|
464
|
-
ret = fn(byref(device_count))
|
|
465
|
-
_mxsmlExCheckReturn(ret)
|
|
466
|
-
return device_count.value
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
def mxSmlExDeviceGetHandleByIndex(index):
|
|
470
|
-
device_index = c_uint(index)
|
|
471
|
-
device = c_mxSmlExDevice_t()
|
|
472
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExGetDeviceHandleByIndex")
|
|
473
|
-
ret = fn(device_index, byref(device))
|
|
474
|
-
_mxsmlExCheckReturn(ret)
|
|
475
|
-
return device
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
@convertStrBytes
|
|
479
|
-
def mxSmlExDeviceGetHandleByUUID(uuid):
|
|
480
|
-
handle = c_mxSmlExDevice_t()
|
|
481
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetHandleByUUID")
|
|
482
|
-
ret = fn(uuid, byref(handle))
|
|
483
|
-
_mxsmlExCheckReturn(ret)
|
|
484
|
-
return handle
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
@convertStrBytes
|
|
488
|
-
def mxSmlExDeviceGetHandleByPciBusId(pci_bus_id):
|
|
489
|
-
busId = c_char_p(pci_bus_id)
|
|
490
|
-
device = c_mxSmlExDevice_t()
|
|
491
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExGetDeviceHandleByPciBusId")
|
|
492
|
-
ret = fn(busId, byref(device))
|
|
493
|
-
_mxsmlExCheckReturn(ret)
|
|
494
|
-
return device
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
@convertStrBytes
|
|
498
|
-
def mxSmlExDeviceGetName(handle):
|
|
499
|
-
device_name = create_string_buffer(MXSMLEX_NAME_V2_BUFFER_SIZE)
|
|
500
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetName")
|
|
501
|
-
ret = fn(handle, device_name, c_uint(MXSMLEX_NAME_V2_BUFFER_SIZE))
|
|
502
|
-
_mxsmlExCheckReturn(ret)
|
|
503
|
-
return device_name.value
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
@convertStrBytes
|
|
507
|
-
def mxSmlExDeviceGetUUID(handle):
|
|
508
|
-
uuid = create_string_buffer(MXSMLEX_DEVICE_UUID_V2_BUFFER_SIZE)
|
|
509
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetUUID")
|
|
510
|
-
ret = fn(handle, uuid, c_uint(MXSMLEX_DEVICE_UUID_V2_BUFFER_SIZE))
|
|
511
|
-
_mxsmlExCheckReturn(ret)
|
|
512
|
-
return uuid.value
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
def mxSmlExDeviceGetPciInfo(handle):
|
|
516
|
-
pci_info = c_mxSmlExPciInfo_t()
|
|
517
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetPciInfo")
|
|
518
|
-
ret = fn(handle, byref(pci_info))
|
|
519
|
-
_mxsmlExCheckReturn(ret)
|
|
520
|
-
return pci_info
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
def mxSmlExDeviceGetMemoryInfo(handle, version=None):
|
|
524
|
-
memory_info = c_mxSmlExMemory_t()
|
|
525
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetMemoryInfo")
|
|
526
|
-
ret = fn(handle, byref(memory_info))
|
|
527
|
-
_mxsmlExCheckReturn(ret)
|
|
528
|
-
return memory_info
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
def mxSmlExDeviceGetFanSpeed(handle):
|
|
532
|
-
fan_speed = c_uint()
|
|
533
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetFanSpeed")
|
|
534
|
-
ret = fn(handle, byref(fan_speed))
|
|
535
|
-
_mxsmlExCheckReturn(ret)
|
|
536
|
-
return fan_speed.value
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
def mxSmlExDeviceGetFanSpeed_v2(handle, fan):
|
|
540
|
-
fan_speed = c_uint()
|
|
541
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetFanSpeed_v2")
|
|
542
|
-
ret = fn(handle, c_uint(fan), byref(fan_speed))
|
|
543
|
-
_mxsmlExCheckReturn(ret)
|
|
544
|
-
return fan_speed.value
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
def mxSmlExDeviceGetUtilizationRates(handle):
|
|
548
|
-
util = c_mxSmlExUtilization_t()
|
|
549
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetUtilization")
|
|
550
|
-
ret = fn(handle, byref(util))
|
|
551
|
-
_mxsmlExCheckReturn(ret)
|
|
552
|
-
return util
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
def mxSmlExDeviceGetMinorNumber(handle):
|
|
556
|
-
minor_number = c_uint()
|
|
557
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetMinorNumber")
|
|
558
|
-
ret = fn(handle, byref(minor_number))
|
|
559
|
-
_mxsmlExCheckReturn(ret)
|
|
560
|
-
return minor_number.value
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
def mxSmlExDeviceGetMetaXLinkState(handle, link):
|
|
564
|
-
is_active = _mxSmlExEnableState_t()
|
|
565
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetMetaXLinkState")
|
|
566
|
-
ret = fn(handle, link, byref(is_active))
|
|
567
|
-
_mxsmlExCheckReturn(ret)
|
|
568
|
-
return is_active.value
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
def mxSmlExDeviceGetMetaXLinkRemotePciInfo(device, link):
|
|
572
|
-
pci_info = c_mxSmlExPciInfo_t()
|
|
573
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetMetaXLinkRemotePciInfo_v2")
|
|
574
|
-
ret = fn(device, link, byref(pci_info))
|
|
575
|
-
_mxsmlExCheckReturn(ret)
|
|
576
|
-
return pci_info
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
def mxSmlExDeviceGetTemperature(handle, sensor):
|
|
580
|
-
temp = c_uint()
|
|
581
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetTemperature")
|
|
582
|
-
ret = fn(handle, _mxSmlExTemperatureSensors_t(sensor), byref(temp))
|
|
583
|
-
_mxsmlExCheckReturn(ret)
|
|
584
|
-
return temp.value
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
def mxSmlExDeviceGetCurrPcieLinkWidth(handle):
|
|
588
|
-
width = c_uint()
|
|
589
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetCurrPcieLinkWidth")
|
|
590
|
-
ret = fn(handle, byref(width))
|
|
591
|
-
_mxsmlExCheckReturn(ret)
|
|
592
|
-
return width.value
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
def mxSmlExDeviceGetComputeRunningProcesses(handle):
|
|
596
|
-
count = c_uint(0)
|
|
597
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetComputeRunningProcesses")
|
|
598
|
-
ret = fn(handle, byref(count), (c_mxsmlExProcessInfo_t * 1)())
|
|
599
|
-
|
|
600
|
-
if ret == MXSMLEX_SUCCESS:
|
|
601
|
-
return []
|
|
602
|
-
elif ret == MXSMLEX_ERROR_INSUFFICIENT_SIZE:
|
|
603
|
-
# oversize the array incase more processes are created
|
|
604
|
-
count.value = count.value * 2 + 5
|
|
605
|
-
processes = (c_mxsmlExProcessInfo_t * count.value)()
|
|
606
|
-
ret = fn(handle, byref(count), byref(processes))
|
|
607
|
-
_mxsmlExCheckReturn(ret)
|
|
608
|
-
|
|
609
|
-
process_array = []
|
|
610
|
-
for i in range(count.value):
|
|
611
|
-
process_array.append(mxSmlExStructToFriendlyObject(processes[i]))
|
|
612
|
-
return process_array
|
|
613
|
-
else:
|
|
614
|
-
# error case
|
|
615
|
-
raise MXSMLEXError(ret)
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
def mxSmlExDeviceGetComputeCapability(handle):
|
|
619
|
-
major = c_int()
|
|
620
|
-
minor = c_int()
|
|
621
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetComputeCapability")
|
|
622
|
-
ret = fn(handle, byref(major), byref(minor))
|
|
623
|
-
_mxsmlExCheckReturn(ret)
|
|
624
|
-
return (major.value, minor.value)
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
def mxSmlExDeviceGetPowerUsage(handle):
|
|
628
|
-
watts = c_uint()
|
|
629
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExGetPowerUsage")
|
|
630
|
-
ret = fn(handle, byref(watts))
|
|
631
|
-
_mxsmlExCheckReturn(ret)
|
|
632
|
-
return watts.value
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
def mxSmlExDeviceGetPowerManagementLimit(handle):
|
|
636
|
-
limit = c_uint()
|
|
637
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExGetPowerManagementLimit")
|
|
638
|
-
ret = fn(handle, byref(limit))
|
|
639
|
-
_mxsmlExCheckReturn(ret)
|
|
640
|
-
return limit.value
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
def mxSmlExDeviceGetMaxPcieLinkWidth(handle):
|
|
644
|
-
width = c_uint()
|
|
645
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExGetMaxPcieLinkWidth")
|
|
646
|
-
ret = fn(handle, byref(width))
|
|
647
|
-
_mxsmlExCheckReturn(ret)
|
|
648
|
-
return width.value
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
def mxSmlExGetPcieThroughput(handle, counter):
|
|
652
|
-
throughput = c_uint()
|
|
653
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExGetPcieThroughput")
|
|
654
|
-
ret = fn(handle, _mxSmlExPcieUtilCounter_t(counter), byref(throughput))
|
|
655
|
-
_mxsmlExCheckReturn(ret)
|
|
656
|
-
return throughput.value
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
def mxSmlExDeviceGetTemperatureThreshold(handle, threshold):
|
|
660
|
-
temp = c_uint()
|
|
661
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetTemperatureThreshold")
|
|
662
|
-
ret = fn(handle, _mxSmlExTemperatureThresholds_t(threshold), byref(temp))
|
|
663
|
-
_mxsmlExCheckReturn(ret)
|
|
664
|
-
return temp.value
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
def mxSmlExDeviceGetClockInfo(handle, clock_type):
|
|
668
|
-
clock = c_uint()
|
|
669
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetClockInfo")
|
|
670
|
-
ret = fn(handle, _mxSmlExClockType_t(clock_type), byref(clock))
|
|
671
|
-
_mxsmlExCheckReturn(ret)
|
|
672
|
-
return clock.value
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
def mxSmlExDeviceGetCurrentClocksThrottleReasons(handle):
|
|
676
|
-
reasons = c_ulonglong()
|
|
677
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetCurrentClocksThrottleReasons")
|
|
678
|
-
ret = fn(handle, byref(reasons))
|
|
679
|
-
_mxsmlExCheckReturn(ret)
|
|
680
|
-
return reasons.value
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
def mxSmlExDeviceGetSupportedClocksThrottleReasons(handle):
|
|
684
|
-
reasons = c_ulonglong()
|
|
685
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetSupportedClocksThrottleReasons")
|
|
686
|
-
ret = fn(handle, byref(reasons))
|
|
687
|
-
_mxsmlExCheckReturn(ret)
|
|
688
|
-
return reasons.value
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
def mxSmlExDeviceGetCpuAffinity(handle, cpu_set_size):
|
|
692
|
-
affinity_array = c_ulonglong * cpu_set_size
|
|
693
|
-
affinity = affinity_array()
|
|
694
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetCpuAffinity")
|
|
695
|
-
ret = fn(handle, c_uint(cpu_set_size), byref(affinity))
|
|
696
|
-
_mxsmlExCheckReturn(ret)
|
|
697
|
-
return affinity
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
def mxSmlExDeviceGetSupportedMemoryClocks(handle):
|
|
701
|
-
count = c_uint(0)
|
|
702
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetSupportedMemoryClocks")
|
|
703
|
-
# Get count
|
|
704
|
-
ret = fn(handle, byref(count), (c_uint * 1)())
|
|
705
|
-
|
|
706
|
-
if ret == MXSMLEX_SUCCESS:
|
|
707
|
-
return []
|
|
708
|
-
elif ret == MXSMLEX_ERROR_INSUFFICIENT_SIZE:
|
|
709
|
-
clocks = (c_uint * count.value)()
|
|
710
|
-
ret = fn(handle, byref(count), clocks)
|
|
711
|
-
_mxsmlExCheckReturn(ret)
|
|
712
|
-
return [clk for clk in clocks]
|
|
713
|
-
else:
|
|
714
|
-
raise MXSMLEXError(ret)
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
def mxSmlExDeviceGetSupportedGraphicsClocks(handle, clock_MHz):
|
|
718
|
-
count = c_uint(0)
|
|
719
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetSupportedGraphicsClocks")
|
|
720
|
-
# Get count
|
|
721
|
-
ret = fn(handle, clock_MHz, byref(count), (c_uint * 1)())
|
|
722
|
-
|
|
723
|
-
if ret == MXSMLEX_SUCCESS:
|
|
724
|
-
return []
|
|
725
|
-
elif ret == MXSMLEX_ERROR_INSUFFICIENT_SIZE:
|
|
726
|
-
clocks = (c_uint * count.value)()
|
|
727
|
-
ret = fn(handle, clock_MHz, byref(count), clocks)
|
|
728
|
-
_mxsmlExCheckReturn(ret)
|
|
729
|
-
return [clk for clk in clocks]
|
|
730
|
-
else:
|
|
731
|
-
raise MXSMLEXError(ret)
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
def mxSmlExDeviceSetApplicationsClocks(handle, mem_clock, graphics_clock):
|
|
735
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceSetApplicationsClocks")
|
|
736
|
-
ret = fn(handle, c_uint(mem_clock), c_uint(graphics_clock))
|
|
737
|
-
_mxsmlExCheckReturn(ret)
|
|
738
|
-
return
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
def mxSmlExDeviceResetApplicationsClocks(handle):
|
|
742
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceResetApplicationsClocks")
|
|
743
|
-
ret = fn(handle)
|
|
744
|
-
_mxsmlExCheckReturn(ret)
|
|
745
|
-
return
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
def mxSmlExDeviceGetApplicationsClock(handle, clock_type):
|
|
749
|
-
clock = c_uint()
|
|
750
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetApplicationsClock")
|
|
751
|
-
ret = fn(handle, _mxSmlExClockType_t(clock_type), byref(clock))
|
|
752
|
-
_mxsmlExCheckReturn(ret)
|
|
753
|
-
return clock.value
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
def mxSmlExDeviceGetP2PStatus(handle1, handle2, p2p_index):
|
|
757
|
-
status = _mxSmlExGpuP2PStatus_t()
|
|
758
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetP2PStatus")
|
|
759
|
-
ret = fn(handle1, handle2, _mxSmlExGpuP2PCapsIndex_t(p2p_index), byref(status))
|
|
760
|
-
_mxsmlExCheckReturn(ret)
|
|
761
|
-
return status.value
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
def mxSmlExDeviceGetPerformanceState(handle):
|
|
765
|
-
state = _mxSmlExPstates_t()
|
|
766
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetPerformanceState")
|
|
767
|
-
ret = fn(handle, byref(state))
|
|
768
|
-
_mxsmlExCheckReturn(ret)
|
|
769
|
-
return state.value
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
def mxSmlExDeviceSetAutoBoostedClocksEnabled(handle, enabled):
|
|
773
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceSetAutoBoostedClocksEnabled")
|
|
774
|
-
ret = fn(handle, _mxSmlExEnableState_t(enabled))
|
|
775
|
-
_mxsmlExCheckReturn(ret)
|
|
776
|
-
return
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
def mxSmlExDeviceGetAutoBoostedClocksEnabled(handle):
|
|
780
|
-
is_enabled = _mxSmlExEnableState_t()
|
|
781
|
-
is_enabled_default = _mxSmlExEnableState_t()
|
|
782
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetAutoBoostedClocksEnabled")
|
|
783
|
-
ret = fn(handle, byref(is_enabled), byref(is_enabled_default))
|
|
784
|
-
_mxsmlExCheckReturn(ret)
|
|
785
|
-
return [is_enabled.value, is_enabled_default.value]
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
def mxSmlExDeviceGetTopologyCommonAncestor(handle1, handle2):
|
|
789
|
-
level = _mxSmlExGpuTopologyLevel_t()
|
|
790
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetTopologyCommonAncestor")
|
|
791
|
-
ret = fn(handle1, handle2, byref(level))
|
|
792
|
-
_mxsmlExCheckReturn(ret)
|
|
793
|
-
return level.value
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
def mxSmlExDeviceGetMetaXLinkRemoteDeviceType(handle, link):
|
|
797
|
-
mxlk_type = _mxSmlExMetaXLinkDeviceType_t()
|
|
798
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetMetaXLinkRemoteDeviceType")
|
|
799
|
-
ret = fn(handle, c_uint(link), byref(mxlk_type))
|
|
800
|
-
_mxsmlExCheckReturn(ret)
|
|
801
|
-
return mxlk_type.value
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
def mxSmlExDeviceGetFieldValues(handle, field_ids):
|
|
805
|
-
values = (c_mxSmlExFieldValue_t * len(field_ids))()
|
|
806
|
-
fn = _mxsmlExGetFunctionPointer("mxSmlExDeviceGetFieldValues")
|
|
807
|
-
|
|
808
|
-
for i, field_id in enumerate(field_ids):
|
|
809
|
-
try:
|
|
810
|
-
(values[i].fieldId, values[i].scopeId) = field_id
|
|
811
|
-
except TypeError:
|
|
812
|
-
values[i].fieldId = field_id
|
|
813
|
-
|
|
814
|
-
ret = fn(handle, c_int(len(field_ids)), byref(values))
|
|
815
|
-
_mxsmlExCheckReturn(ret)
|
|
816
|
-
return values
|