mbltml.py Source File

mbltml.py Source File#

mbltml: mbltml.py Source File
mbltml Test Preview
mbltml — EN
mbltml.py
Go to the documentation of this file.
1
4
5import os
6import glob
7import platform
8from ctypes import *
9from pathlib import Path
10from typing import List, Set
11
12
15
16
17MBLTML_DRIVER_VERSION_BUFFER_SIZE = 80
18
19MBLTML_ON_DEVICE_DRIVER_VERSION_BUFFER_SIZE = 80
20
21MBLTML_FIRMWARE_VERSION_BUFFER_SIZE = 80
22
23MBLTML_NODE_NAME_BUFFER_SIZE = 80
24
25
29mbltmlDeviceType_t = c_uint
30MBLTML_DEVICE_ERROR = 0x0
31MBLTML_DEVICE_ARIES = 0x1
32MBLTML_DEVICE_REGULUS = 0x2
33MBLTML_DEVICE_REGULUS_USB = 0x4
34
35
36mbltmlHardwareVersion_t = c_uint
37MBLTML_HARDWARE_VERSION_ARIES_RA = 0x00000001
38MBLTML_HARDWARE_VERSION_REGULUS_RA = 0x00000002
39MBLTML_HARDWARE_VERSION_ARIES_RB = 0x00000003
40MBLTML_HARDWARE_VERSION_REGULUS_RB = 0x00000004
41MBLTML_HARDWARE_VERSION_ERROR = 0x7FFFFFFF
42
43
46mbltmlStatusCode_t = c_uint
47MBLTML_SUCCESS = 0
48MBLTML_DRIVER_NOT_FOUND = 2
49MBLTML_INVALID_ARGUMENT = 3
50MBLTML_UNINITIALIZED = 1
51MBLTML_NOT_SUPPORTED = 4
52MBLTML_INSUFFICIENT_LENGTH = 5
53
54
58mbltmlExtraPmicId_t = c_uint
59MBLTML_EXTRA_PMIC_ID_NPU = 0
60MBLTML_EXTRA_PMIC_ID_DDR = 1
61MBLTML_EXTRA_PMIC_ID_PMIC = 2
62MBLTML_EXTRA_PMIC_ID_GOLDFINGER = 3
63
64
65mbltmlCluster_t = c_uint
66MBLTML_CLUSTER_0 = 0x00010000
67MBLTML_CLUSTER_1 = 0x00020000
68MBLTML_CLUSTER_ERROR = 0x7FFF0000
69
70
71mbltmlCore_t = c_uint
72MBLTML_CORE_0 = 1
73MBLTML_CORE_1 = 2
74MBLTML_CORE_2 = 3
75MBLTML_CORE_3 = 4
76MBLTML_CORE_GLOBAL = 0x0000FFFE
77MBLTML_CORE_ERROR = 0x0000FFFF
78
79
80# Classes
81class mbltmlCoreId_t(Structure):
82 """@brief Composite identifier of an NPU core (cluster + core).
83
84 @var cluster Cluster to which the core belongs (mbltmlCluster_t).
85 @var core Core within the cluster (mbltmlCore_t).
86 """
87
88 cluster: mbltmlCluster_t
89 core: mbltmlCore_t
90 _fields_ = [
91 ("cluster", mbltmlCluster_t),
92 ("core", mbltmlCore_t),
93 ]
94
95 def __repr__(self):
96 d = {"cluster": self.cluster, "core": self.core}
97 return "{}({})".format(
98 self.__class__.__name__,
99 ", ".join("{}={}".format(k, v) for k, v in d.items()),
100 )
101
102
103class mbltmlCoreInfo_t(Structure):
104 """@brief Per-core usage record returned by mbltmlGetCoreInfos().
105
106 Utilization for the core can be computed as @c npu_time / @c interval
107 when @c interval is non-zero.
108
109 @var core_id Identifier of the core (mbltmlCoreId_t).
110 @var npu_time Accumulated NPU active time on the core, in microseconds.
111 @var interval Sampling interval covered by @c npu_time, in microseconds.
112 """
113
114 core_id: mbltmlCoreId_t
115 npu_time: c_int64
116 interval: c_int64
117 _fields_ = [
118 ("core_id", mbltmlCoreId_t),
119 ("npu_time", c_int64),
120 ("interval", c_int64),
121 ]
122
123 def __repr__(self):
124 d = {
125 "core_id": self.core_id,
126 "npu_time": self.npu_time,
127 "interval": self.interval,
128 }
129 return "{}({})".format(
130 self.__class__.__name__,
131 ", ".join("{}={}".format(k, v) for k, v in d.items()),
132 )
133
134
135class mbltmlProcessInfo_t(Structure):
136 """@brief Per-process usage record returned by mbltmlGetProcessInfos().
137
138 Utilization for the process can be computed as
139 @c total_npu_time_us / @c total_interval_us when @c total_interval_us
140 is non-zero.
141
142 @var pid Process ID.
143 @var counts Number of NPU samples attributed to the process.
144 @var npu_memory_usage Device memory currently used by the process, in bytes.
145 @var total_interval_us Total sampling interval, in microseconds.
146 @var total_npu_time_us Total NPU active time used by the process, in microseconds.
147 """
148
149 pid: c_int
150 counts: c_int
151 npu_memory_usage: c_int64
152 total_interval_us: c_int64
153 total_npu_time_us: c_int64
154 _fields_ = [
155 ("pid", c_int),
156 ("counts", c_int),
157 ("npu_memory_usage", c_int64),
158 ("total_interval_us", c_int64),
159 ("total_npu_time_us", c_int64),
160 ]
161
162 def __repr__(self):
163 d = {
164 "pid": self.pid,
165 "counts": self.counts,
166 "npu_memory_usage": self.npu_memory_usage,
167 "total_interval_us": self.total_interval_us,
168 "total_npu_time_us": self.total_npu_time_us,
169 }
170 return "{}({})".format(
171 self.__class__.__name__,
172 ", ".join("{}={}".format(k, v) for k, v in d.items()),
173 )
174
175
176_clib = None
177
178
179def _loadLibrary() -> None:
180 global _clib
181 if _clib != None:
182 return
183 lib_fname = "mbltml.dll" if platform.system() == "Windows" else f"libmbltml.so*"
184 pattern = os.path.join(Path(__file__).resolve().parent, lib_fname)
185 candidates = glob.glob(pattern)
186 if not candidates:
187 raise FileNotFoundError(f"No library matching {pattern}")
188 candidates.sort(key=len, reverse=True)
189 _clib = CDLL(str(candidates[0]))
190
191 _clib.mbltmlInit.argtypes = []
192 _clib.mbltmlInit.restype = mbltmlStatusCode_t
193 _clib.mbltmlInitDevices.argtypes = [mbltmlDeviceType_t]
194 _clib.mbltmlInitDevices.restype = mbltmlStatusCode_t
195 _clib.mbltmlShutdown.argtypes = []
196 _clib.mbltmlShutdown.restype = mbltmlStatusCode_t
197 _clib.mbltmlGetDeviceCount.argtypes = [POINTER(c_uint)]
198 _clib.mbltmlGetDeviceCount.restype = mbltmlStatusCode_t
199 _clib.mbltmlGetDriverVersion.argtypes = [mbltmlDeviceType_t, POINTER(c_char), c_int]
200 _clib.mbltmlGetDriverVersion.restype = mbltmlStatusCode_t
201 _clib.mbltmlGetDriverRevision.argtypes = [mbltmlDeviceType_t, POINTER(c_uint)]
202 _clib.mbltmlGetDriverRevision.restype = mbltmlStatusCode_t
203 _clib.mbltmlGetNodeName.argtypes = [c_int, POINTER(c_char), c_int]
204 _clib.mbltmlGetNodeName.restype = mbltmlStatusCode_t
205 _clib.mbltmlGetDeviceType.argtypes = [c_int, POINTER(mbltmlDeviceType_t)]
206 _clib.mbltmlGetDeviceType.restype = mbltmlStatusCode_t
207 _clib.mbltmlGetHardwareVersion.argtypes = [c_int, POINTER(mbltmlHardwareVersion_t)]
208 _clib.mbltmlGetHardwareVersion.restype = mbltmlStatusCode_t
209 _clib.mbltmlGetOnDeviceDriverVersion.argtypes = [c_int, POINTER(c_char), c_uint]
210 _clib.mbltmlGetOnDeviceDriverVersion.restype = mbltmlStatusCode_t
211 _clib.mbltmlGetOnDeviceDriverRevision.argtypes = [c_int, POINTER(c_uint)]
212 _clib.mbltmlGetOnDeviceDriverRevision.restype = mbltmlStatusCode_t
213 _clib.mbltmlGetFirmwareVersion.argtypes = [c_int, POINTER(c_char), c_uint]
214 _clib.mbltmlGetFirmwareVersion.restype = mbltmlStatusCode_t
215 _clib.mbltmlGetFirmwareRevision.argtypes = [c_int, POINTER(c_uint)]
216 _clib.mbltmlGetFirmwareRevision.restype = mbltmlStatusCode_t
217 _clib.mbltmlGetFirmwareCRC.argtypes = [c_int, POINTER(c_uint)]
218 _clib.mbltmlGetFirmwareCRC.restype = mbltmlStatusCode_t
219 _clib.mbltmlGetTemperature.argtypes = [c_int, POINTER(c_int)]
220 _clib.mbltmlGetTemperature.restype = mbltmlStatusCode_t
221 _clib.mbltmlGetSignalType.argtypes = [c_int, POINTER(c_uint)]
222 _clib.mbltmlGetSignalType.restype = mbltmlStatusCode_t
223 _clib.mbltmlGetNPUClock.argtypes = [c_int, POINTER(c_uint)]
224 _clib.mbltmlGetNPUClock.restype = mbltmlStatusCode_t
225 _clib.mbltmlGetBusClock.argtypes = [c_int, POINTER(c_uint)]
226 _clib.mbltmlGetBusClock.restype = mbltmlStatusCode_t
227 _clib.mbltmlGetFanDuty.argtypes = [c_int, POINTER(c_int)]
228 _clib.mbltmlGetFanDuty.restype = mbltmlStatusCode_t
229 _clib.mbltmlGetVendorId.argtypes = [c_int, POINTER(c_uint)]
230 _clib.mbltmlGetVendorId.restype = mbltmlStatusCode_t
231 _clib.mbltmlGetDeviceId.argtypes = [c_int, POINTER(c_uint)]
232 _clib.mbltmlGetDeviceId.restype = mbltmlStatusCode_t
233 _clib.mbltmlGetSubVendorId.argtypes = [c_int, POINTER(c_uint)]
234 _clib.mbltmlGetSubVendorId.restype = mbltmlStatusCode_t
235 _clib.mbltmlGetSubDeviceId.argtypes = [c_int, POINTER(c_uint)]
236 _clib.mbltmlGetSubDeviceId.restype = mbltmlStatusCode_t
237 _clib.mbltmlGetPcieGen.argtypes = [c_int, POINTER(c_uint)]
238 _clib.mbltmlGetPcieGen.restype = mbltmlStatusCode_t
239 _clib.mbltmlGetPcieLanes.argtypes = [c_int, POINTER(c_uint)]
240 _clib.mbltmlGetPcieLanes.restype = mbltmlStatusCode_t
241 _clib.mbltmlGetPcieRev.argtypes = [c_int, POINTER(c_uint)]
242 _clib.mbltmlGetPcieRev.restype = mbltmlStatusCode_t
243 _clib.mbltmlGetPcieClassCode.argtypes = [c_int, POINTER(c_uint)]
244 _clib.mbltmlGetPcieClassCode.restype = mbltmlStatusCode_t
245 _clib.mbltmlGetTotalPower.argtypes = [c_int, POINTER(c_double)]
246 _clib.mbltmlGetTotalPower.restype = mbltmlStatusCode_t
247 _clib.mbltmlGetTotalCurrent.argtypes = [c_int, POINTER(c_double)]
248 _clib.mbltmlGetTotalCurrent.restype = mbltmlStatusCode_t
249 _clib.mbltmlGetTotalVoltage.argtypes = [c_int, POINTER(c_double)]
250 _clib.mbltmlGetTotalVoltage.restype = mbltmlStatusCode_t
251 _clib.mbltmlGetExtraPmicPower.argtypes = [c_int, POINTER(c_double)]
252 _clib.mbltmlGetExtraPmicPower.restype = mbltmlStatusCode_t
253 _clib.mbltmlGetExtraPmicCurrent.argtypes = [c_int, POINTER(c_double)]
254 _clib.mbltmlGetExtraPmicCurrent.restype = mbltmlStatusCode_t
255 _clib.mbltmlGetExtraPmicVoltage.argtypes = [c_int, POINTER(c_double)]
256 _clib.mbltmlGetExtraPmicVoltage.restype = mbltmlStatusCode_t
257 _clib.mbltmlGetExtraPmicId.argtypes = [c_int, POINTER(mbltmlExtraPmicId_t)]
258 _clib.mbltmlGetExtraPmicId.restype = mbltmlStatusCode_t
259 _clib.mbltmlGetTotalUtilization.argtypes = [c_int, POINTER(c_double)]
260 _clib.mbltmlGetTotalUtilization.restype = mbltmlStatusCode_t
261 _clib.mbltmlGetMemoryUsage.argtypes = [c_int, POINTER(c_int64)]
262 _clib.mbltmlGetMemoryUsage.restype = mbltmlStatusCode_t
263 _clib.mbltmlGetMemoryTotal.argtypes = [c_int, POINTER(c_int64)]
264 _clib.mbltmlGetMemoryTotal.restype = mbltmlStatusCode_t
265 _clib.mbltmlGetProcessInfos.argtypes = [
266 c_int,
267 POINTER(mbltmlProcessInfo_t),
268 POINTER(c_uint),
269 ]
270 _clib.mbltmlGetProcessInfos.restype = mbltmlStatusCode_t
271 _clib.mbltmlGetCoreInfos.argtypes = [
272 c_int,
273 POINTER(mbltmlCoreInfo_t),
274 POINTER(c_uint),
275 ]
276 _clib.mbltmlGetCoreInfos.restype = mbltmlStatusCode_t
277 _clib.mbltmlSetExtraPmicID.argtypes = [c_int, mbltmlExtraPmicId_t]
278 _clib.mbltmlSetExtraPmicID.restype = mbltmlStatusCode_t
279
280
281class MBLTMLError(Exception):
282 """@brief Base exception raised by the mbltml Python binding.
283
284 Wraps a non-success mbltmlStatusCode_t returned by the underlying C
285 library. Instantiating MBLTMLError with a known status code yields the
286 matching subclass (e.g., MBLTMLInvalidArgumentError).
287
288 @var code The mbltmlStatusCode_t value associated with this exception.
289 """
290
291 _code_to_class = {}
292 _errcode_to_string = {
293 MBLTML_DRIVER_NOT_FOUND: "Driver is not found",
294 MBLTML_INVALID_ARGUMENT: "Invalid Argument",
295 MBLTML_UNINITIALIZED: "Uninitilized mbltml.",
296 MBLTML_NOT_SUPPORTED: "Unspported Function for Target Device",
297 MBLTML_INSUFFICIENT_LENGTH: "Insufficient Length",
298 }
299
300 def __new__(cls, code: mbltmlStatusCode_t):
301 if cls is MBLTMLError and code in MBLTMLError._code_to_class:
302 cls = MBLTMLError._code_to_class[code]
303 obj = Exception.__new__(cls)
304 obj.code = code
305 return obj
306
307 def __str__(self):
308 return MBLTMLError._errcode_to_string[self.code]
309
310 def __eq__(self, other):
311 return self.code == other.code
312
313
314class MBLTMLDriverNotFoundError(MBLTMLError):
315 """@brief Raised when the required driver cannot be located.
316
317 Wraps MBLTML_DRIVER_NOT_FOUND.
318 """
319
320 pass
321
322
323class MBLTMLInvalidArgumentError(MBLTMLError):
324 """@brief Raised when one or more arguments are invalid.
325
326 Wraps MBLTML_INVALID_ARGUMENT. Typical causes include a NULL pointer or
327 a @c dev_no that is out of range of the device count.
328 """
329
330 pass
331
332
333class MBLTMLUninitializedError(MBLTMLError):
334 """@brief Raised when an API is called before initialization.
335
336 Wraps MBLTML_UNINITIALIZED. Call mbltmlInit() or mbltmlInitDevices() first.
337 """
338
339 pass
340
341
342class MBLTMLNotSupportedError(MBLTMLError):
343 """@brief Raised when the feature is not supported on the target device.
344
345 Wraps MBLTML_NOT_SUPPORTED.
346 """
347
348 pass
349
350
352 """@brief Raised when the output buffer is too small to hold the result.
353
354 Wraps MBLTML_INSUFFICIENT_LENGTH.
355 """
356
357 pass
358
359
360MBLTMLError._code_to_class = {
361 MBLTML_DRIVER_NOT_FOUND: MBLTMLDriverNotFoundError,
362 MBLTML_INVALID_ARGUMENT: MBLTMLInvalidArgumentError,
363 MBLTML_UNINITIALIZED: MBLTMLUninitializedError,
364 MBLTML_NOT_SUPPORTED: MBLTMLNotSupportedError,
365 MBLTML_INSUFFICIENT_LENGTH: MBLTMLInsufficientLengthError,
366}
367
368
369def _mbltmlThrowError(ret: mbltmlStatusCode_t) -> None:
370 if ret != MBLTML_SUCCESS:
371 raise MBLTMLError(ret)
372
373
374# Function calls
375def mbltmlInit() -> None:
376 """@brief Initialize the mbltml library for all supported device types.
377
378 Equivalent to calling mbltmlInitDevices() with every mbltmlDeviceType_t
379 enabled. Must be called (directly or via mbltmlInitDevices()) before any
380 other mbltml API.
381
382 @throws MBLTMLError on failure.
383 """
384 _loadLibrary()
385 ret = _clib.mbltmlInit()
386 _mbltmlThrowError(ret)
387
388
389def mbltmlInitDevices(device_types: Set[mbltmlDeviceType_t]) -> None:
390 """@brief Initialize the mbltml library for a selected set of device types.
391
392 @param device_types Set of mbltmlDeviceType_t values indicating which
393 device families to enumerate and monitor.
394 @throws MBLTMLError on failure.
395 """
396 _loadLibrary()
397 all_device_types = 0
398 for dt in device_types:
399 all_device_types = all_device_types | dt
400 ret = _clib.mbltmlInitDevices(all_device_types)
401 _mbltmlThrowError(ret)
402
403
404def mbltmlShutdown() -> None:
405 """@brief Release all resources held by the mbltml library.
406
407 After this call, any further API usage requires re-initialization via
408 mbltmlInit() or mbltmlInitDevices().
409
410 @throws MBLTMLError on failure.
411 """
412 _loadLibrary()
413 ret = _clib.mbltmlShutdown()
414 _mbltmlThrowError(ret)
415
416
417def mbltmlGetDeviceCount() -> int:
418 """@brief Get the total number of devices detected by the library.
419
420 @note Supported on all device types.
421
422 @return The number of devices detected.
423 @throws MBLTMLError on failure.
424 """
425 _loadLibrary()
426 value = c_uint()
427 ret = _clib.mbltmlGetDeviceCount(byref(value))
428 _mbltmlThrowError(ret)
429 return value.value
430
431
432def mbltmlGetDriverVersion(device_type: mbltmlDeviceType_t) -> str:
433 """@brief Get the driver version string for a specific device family.
434
435 @note Supported on all device types.
436
437 @param device_type Device family whose driver version is queried.
438 @return The driver version string.
439 @throws MBLTMLError on failure.
440 """
441 _loadLibrary()
442 buf = create_string_buffer(MBLTML_DRIVER_VERSION_BUFFER_SIZE)
443 ret = _clib.mbltmlGetDriverVersion(
444 device_type, buf, MBLTML_DRIVER_VERSION_BUFFER_SIZE
445 )
446 _mbltmlThrowError(ret)
447 return buf.value.decode()
448
449
450def mbltmlGetDriverRevision(device_type: mbltmlDeviceType_t) -> int:
451 """@brief Get the driver revision number for a specific device family.
452
453 @note Supported on all device types.
454
455 @param device_type Device family whose driver revision is queried.
456 @return The driver revision number.
457 @throws MBLTMLError on failure.
458 """
459 _loadLibrary()
460 value = c_uint()
461 ret = _clib.mbltmlGetDriverRevision(device_type, byref(value))
462 _mbltmlThrowError(ret)
463 return value.value
464
465
466def mbltmlGetNodeName(dev_no: int) -> str:
467 """@brief Get the node name of a device.
468
469 @note Supported on all device types.
470
471 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
472 @return The node name string.
473 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
474 @throws MBLTMLError on other failures.
475 """
476 _loadLibrary()
477 buf = create_string_buffer(MBLTML_NODE_NAME_BUFFER_SIZE)
478 ret = _clib.mbltmlGetNodeName(dev_no, buf, MBLTML_NODE_NAME_BUFFER_SIZE)
479 _mbltmlThrowError(ret)
480 return buf.value.decode()
481
482
483def mbltmlGetDeviceType(dev_no: int) -> mbltmlDeviceType_t:
484 """@brief Get the device family type of a device.
485
486 @note Supported on all device types.
487
488 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
489 @return The mbltmlDeviceType_t of the device.
490 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
491 @throws MBLTMLError on other failures.
492 """
493 _loadLibrary()
494 value = c_uint()
495 ret = _clib.mbltmlGetDeviceType(dev_no, byref(value))
496 _mbltmlThrowError(ret)
497 return value.value
498
499
500def mbltmlGetHardwareVersion(dev_no: int) -> mbltmlHardwareVersion_t:
501 """@brief Get the hardware version of a device.
502
503 @note Supported on all device types.
504
505 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
506 @return The mbltmlHardwareVersion_t of the device.
507 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
508 @throws MBLTMLError on other failures.
509 """
510 _loadLibrary()
511 value = c_uint()
512 ret = _clib.mbltmlGetHardwareVersion(dev_no, byref(value))
513 _mbltmlThrowError(ret)
514 return value.value
515
516
517def mbltmlGetOnDeviceDriverVersion(dev_no: int) -> str:
518 """@brief Get the on-device driver version string of a device.
519
520 @note Supported on MBLTML_DEVICE_REGULUS_USB only.
521
522 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
523 @return The on-device driver version string.
524 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
525 @throws MBLTMLError on other failures.
526 """
527 _loadLibrary()
528 buf = create_string_buffer(MBLTML_ON_DEVICE_DRIVER_VERSION_BUFFER_SIZE)
529 ret = _clib.mbltmlGetOnDeviceDriverVersion(
530 dev_no, buf, MBLTML_ON_DEVICE_DRIVER_VERSION_BUFFER_SIZE
531 )
532 _mbltmlThrowError(ret)
533 return buf.value.decode()
534
535
536def mbltmlGetOnDeviceDriverRevision(dev_no: int) -> int:
537 """@brief Get the on-device driver revision number of a device.
538
539 @note Supported on MBLTML_DEVICE_REGULUS_USB only.
540
541 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
542 @return The on-device driver revision.
543 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
544 @throws MBLTMLError on other failures.
545 """
546 _loadLibrary()
547 value = c_uint()
548 ret = _clib.mbltmlGetOnDeviceDriverRevision(dev_no, byref(value))
549 _mbltmlThrowError(ret)
550 return value.value
551
552
553def mbltmlGetFirmwareVersion(dev_no: int) -> str:
554 """@brief Get the firmware version string of a device.
555
556 @note Supported on MBLTML_DEVICE_ARIES only.
557
558 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
559 @return The firmware version string.
560 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
561 @throws MBLTMLError on other failures.
562 """
563 _loadLibrary()
564 buf = create_string_buffer(MBLTML_FIRMWARE_VERSION_BUFFER_SIZE)
565 ret = _clib.mbltmlGetFirmwareVersion(
566 dev_no, buf, MBLTML_FIRMWARE_VERSION_BUFFER_SIZE
567 )
568 _mbltmlThrowError(ret)
569 return buf.value.decode()
570
571
572def mbltmlGetFirmwareRevision(dev_no: int) -> int:
573 """@brief Get the firmware revision number of a device.
574
575 @note Supported on MBLTML_DEVICE_ARIES only.
576
577 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
578 @return The firmware revision.
579 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
580 @throws MBLTMLError on other failures.
581 """
582 _loadLibrary()
583 value = c_uint()
584 ret = _clib.mbltmlGetFirmwareRevision(dev_no, byref(value))
585 _mbltmlThrowError(ret)
586 return value.value
587
588
589def mbltmlGetFirmwareCRC(dev_no: int) -> int:
590 """@brief Get the CRC of the currently-loaded firmware image.
591
592 @note Supported on MBLTML_DEVICE_ARIES only.
593
594 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
595 @return The firmware CRC.
596 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
597 @throws MBLTMLError on other failures.
598 """
599 _loadLibrary()
600 value = c_uint()
601 ret = _clib.mbltmlGetFirmwareCRC(dev_no, byref(value))
602 _mbltmlThrowError(ret)
603 return value.value
604
605
606def mbltmlGetTemperature(dev_no: int) -> int:
607 """@brief Get the current die temperature of a device.
608
609 @note Supported on all device types.
610
611 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
612 @return The temperature reading.
613 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
614 @throws MBLTMLError on other failures.
615 """
616 _loadLibrary()
617 value = c_int()
618 ret = _clib.mbltmlGetTemperature(dev_no, byref(value))
619 _mbltmlThrowError(ret)
620 return value.value
621
622
623def mbltmlGetSignalType(dev_no: int) -> int:
624 """@brief Get the current signal-type indicator reported by the device.
625
626 @note Supported on all device types.
627
628 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
629 @return The signal-type value.
630 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
631 @throws MBLTMLError on other failures.
632 """
633 _loadLibrary()
634 value = c_uint()
635 ret = _clib.mbltmlGetSignalType(dev_no, byref(value))
636 _mbltmlThrowError(ret)
637 return value.value
638
639
640def mbltmlGetNPUClock(dev_no: int) -> int:
641 """@brief Get the current NPU clock frequency of a device.
642
643 @note Supported on all device types.
644
645 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
646 @return The NPU clock value.
647 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
648 @throws MBLTMLError on other failures.
649 """
650 _loadLibrary()
651 value = c_uint()
652 ret = _clib.mbltmlGetNPUClock(dev_no, byref(value))
653 _mbltmlThrowError(ret)
654 return value.value
655
656
657def mbltmlGetBusClock(dev_no: int) -> int:
658 """@brief Get the current bus clock frequency of a device.
659
660 @note Supported on MBLTML_DEVICE_ARIES only.
661
662 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
663 @return The bus clock value.
664 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
665 @throws MBLTMLError on other failures.
666 """
667 _loadLibrary()
668 value = c_uint()
669 ret = _clib.mbltmlGetBusClock(dev_no, byref(value))
670 _mbltmlThrowError(ret)
671 return value.value
672
673
674def mbltmlGetFanDuty(dev_no: int) -> int:
675 """@brief Get the current cooling-fan duty cycle of a device.
676
677 @note Supported on MBLTML_DEVICE_ARIES only.
678
679 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
680 @return The fan duty value.
681 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
682 @throws MBLTMLError on other failures.
683 """
684 _loadLibrary()
685 value = c_int()
686 ret = _clib.mbltmlGetFanDuty(dev_no, byref(value))
687 _mbltmlThrowError(ret)
688 return value.value
689
690
691def mbltmlGetVendorId(dev_no: int) -> int:
692 """@brief Get the PCIe vendor ID of a device.
693
694 @note Supported on MBLTML_DEVICE_ARIES only.
695
696 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
697 @return The vendor ID.
698 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
699 @throws MBLTMLError on other failures.
700 """
701 _loadLibrary()
702 value = c_uint()
703 ret = _clib.mbltmlGetVendorId(dev_no, byref(value))
704 _mbltmlThrowError(ret)
705 return value.value
706
707
708def mbltmlGetDeviceId(dev_no: int) -> int:
709 """@brief Get the PCIe device ID of a device.
710
711 @note Supported on MBLTML_DEVICE_ARIES only.
712
713 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
714 @return The device ID.
715 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
716 @throws MBLTMLError on other failures.
717 """
718 _loadLibrary()
719 value = c_uint()
720 ret = _clib.mbltmlGetDeviceId(dev_no, byref(value))
721 _mbltmlThrowError(ret)
722 return value.value
723
724
725def mbltmlGetSubVendorId(dev_no: int) -> int:
726 """@brief Get the PCIe subsystem vendor ID of a device.
727
728 @note Supported on MBLTML_DEVICE_ARIES only.
729
730 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
731 @return The subsystem vendor ID.
732 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
733 @throws MBLTMLError on other failures.
734 """
735 _loadLibrary()
736 value = c_uint()
737 ret = _clib.mbltmlGetSubVendorId(dev_no, byref(value))
738 _mbltmlThrowError(ret)
739 return value.value
740
741
742def mbltmlGetSubDeviceId(dev_no: int) -> int:
743 """@brief Get the PCIe subsystem device ID of a device.
744
745 @note Supported on MBLTML_DEVICE_ARIES only.
746
747 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
748 @return The subsystem device ID.
749 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
750 @throws MBLTMLError on other failures.
751 """
752 _loadLibrary()
753 value = c_uint()
754 ret = _clib.mbltmlGetSubDeviceId(dev_no, byref(value))
755 _mbltmlThrowError(ret)
756 return value.value
757
758
759def mbltmlGetPcieGen(dev_no: int) -> int:
760 """@brief Get the negotiated PCIe link generation of a device.
761
762 @note Supported on MBLTML_DEVICE_ARIES only.
763
764 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
765 @return The PCIe generation.
766 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
767 @throws MBLTMLError on other failures.
768 """
769 _loadLibrary()
770 value = c_uint()
771 ret = _clib.mbltmlGetPcieGen(dev_no, byref(value))
772 _mbltmlThrowError(ret)
773 return value.value
774
775
776def mbltmlGetPcieLanes(dev_no: int) -> int:
777 """@brief Get the negotiated PCIe link width (in lanes) of a device.
778
779 @note Supported on MBLTML_DEVICE_ARIES only.
780
781 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
782 @return The lane count.
783 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
784 @throws MBLTMLError on other failures.
785 """
786 _loadLibrary()
787 value = c_uint()
788 ret = _clib.mbltmlGetPcieLanes(dev_no, byref(value))
789 _mbltmlThrowError(ret)
790 return value.value
791
792
793def mbltmlGetPcieRev(dev_no: int) -> int:
794 """@brief Get the PCIe configuration-space revision ID of a device.
795
796 @note Supported on MBLTML_DEVICE_ARIES only.
797
798 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
799 @return The revision value.
800 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
801 @throws MBLTMLError on other failures.
802 """
803 _loadLibrary()
804 value = c_uint()
805 ret = _clib.mbltmlGetPcieRev(dev_no, byref(value))
806 _mbltmlThrowError(ret)
807 return value.value
808
809
810def mbltmlGetPcieClassCode(dev_no: int) -> int:
811 """@brief Get the PCIe configuration-space class code of a device.
812
813 @note Supported on MBLTML_DEVICE_ARIES only.
814
815 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
816 @return The class code.
817 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
818 @throws MBLTMLError on other failures.
819 """
820 _loadLibrary()
821 value = c_uint()
822 ret = _clib.mbltmlGetPcieClassCode(dev_no, byref(value))
823 _mbltmlThrowError(ret)
824 return value.value
825
826
827def mbltmlGetTotalPower(dev_no: int) -> float:
828 """@brief Get the total instantaneous power consumption of a device (W).
829
830 @note Supported on MBLTML_DEVICE_ARIES only.
831
832 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
833 @return The power reading.
834 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
835 @throws MBLTMLError on other failures.
836 """
837 _loadLibrary()
838 value = c_double()
839 ret = _clib.mbltmlGetTotalPower(dev_no, byref(value))
840 _mbltmlThrowError(ret)
841 return value.value
842
843
844def mbltmlGetTotalCurrent(dev_no: int) -> float:
845 """@brief Get the total instantaneous current draw of a device (A).
846
847 @note Supported on MBLTML_DEVICE_ARIES only.
848
849 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
850 @return The current reading.
851 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
852 @throws MBLTMLError on other failures.
853 """
854 _loadLibrary()
855 value = c_double()
856 ret = _clib.mbltmlGetTotalCurrent(dev_no, byref(value))
857 _mbltmlThrowError(ret)
858 return value.value
859
860
861def mbltmlGetTotalVoltage(dev_no: int) -> float:
862 """@brief Get the total instantaneous supply voltage of a device (V).
863
864 @note Supported on MBLTML_DEVICE_ARIES only.
865
866 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
867 @return The voltage reading.
868 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
869 @throws MBLTMLError on other failures.
870 """
871 _loadLibrary()
872 value = c_double()
873 ret = _clib.mbltmlGetTotalVoltage(dev_no, byref(value))
874 _mbltmlThrowError(ret)
875 return value.value
876
877
878def mbltmlGetExtraPmicPower(dev_no: int) -> float:
879 """@brief Get the power consumption of the extra PMIC rail currently
880 selected for the device (W).
881
882 @note Supported on MBLTML_DEVICE_ARIES only.
883
884 The selected rail is controlled by mbltmlSetExtraPmicID() and can be
885 queried via mbltmlGetExtraPmicId().
886
887 The firmware refreshes this reading once per second. After changing the
888 selected rail with mbltmlSetExtraPmicID(), allow up to 1 second for the
889 new rail's value to be reported.
890
891 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
892 @return The power reading.
893 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
894 @throws MBLTMLError on other failures.
895 """
896 _loadLibrary()
897 value = c_double()
898 ret = _clib.mbltmlGetExtraPmicPower(dev_no, byref(value))
899 _mbltmlThrowError(ret)
900 return value.value
901
902
903def mbltmlGetExtraPmicCurrent(dev_no: int) -> float:
904 """@brief Get the current of the extra PMIC rail currently selected
905 for the device (A).
906
907 @note Supported on MBLTML_DEVICE_ARIES only.
908
909 The firmware refreshes this reading once per second. After changing the
910 selected rail with mbltmlSetExtraPmicID(), allow up to 1 second for the
911 new rail's value to be reported.
912
913 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
914 @return The current reading.
915 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
916 @throws MBLTMLError on other failures.
917 """
918 _loadLibrary()
919 value = c_double()
920 ret = _clib.mbltmlGetExtraPmicCurrent(dev_no, byref(value))
921 _mbltmlThrowError(ret)
922 return value.value
923
924
925def mbltmlGetExtraPmicVoltage(dev_no: int) -> float:
926 """@brief Get the voltage of the extra PMIC rail currently selected
927 for the device (V).
928
929 @note Supported on MBLTML_DEVICE_ARIES only.
930
931 The firmware refreshes this reading once per second. After changing the
932 selected rail with mbltmlSetExtraPmicID(), allow up to 1 second for the
933 new rail's value to be reported.
934
935 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
936 @return The voltage reading.
937 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
938 @throws MBLTMLError on other failures.
939 """
940 _loadLibrary()
941 value = c_double()
942 ret = _clib.mbltmlGetExtraPmicVoltage(dev_no, byref(value))
943 _mbltmlThrowError(ret)
944 return value.value
945
946
947def mbltmlGetExtraPmicId(dev_no: int) -> mbltmlExtraPmicId_t:
948 """@brief Get the extra PMIC rail currently selected for the device.
949
950 @note Supported on MBLTML_DEVICE_ARIES only.
951
952 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
953 @return The selected mbltmlExtraPmicId_t value.
954 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
955 @throws MBLTMLError on other failures.
956 """
957 _loadLibrary()
958 value = c_uint()
959 ret = _clib.mbltmlGetExtraPmicId(dev_no, byref(value))
960 _mbltmlThrowError(ret)
961 return value.value
962
963
964def mbltmlGetTotalUtilization(dev_no: int) -> float:
965 """@brief Get the overall NPU utilization of a device.
966
967 @note Supported on all device types.
968
969 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
970 @return The utilization value (typically a ratio in [0.0, 1.0] or a percentage).
971 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
972 @throws MBLTMLError on other failures.
973 """
974 _loadLibrary()
975 value = c_double()
976 ret = _clib.mbltmlGetTotalUtilization(dev_no, byref(value))
977 _mbltmlThrowError(ret)
978 return value.value
979
980
981def mbltmlGetMemoryUsage(dev_no: int) -> int:
982 """@brief Get the amount of device memory currently in use.
983
984 @note Supported on all device types.
985
986 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
987 @return The in-use memory in bytes.
988 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
989 @throws MBLTMLError on other failures.
990 """
991 _loadLibrary()
992 value = c_int64()
993 ret = _clib.mbltmlGetMemoryUsage(dev_no, byref(value))
994 _mbltmlThrowError(ret)
995 return value.value
996
997
998def mbltmlGetMemoryTotal(dev_no: int) -> int:
999 """@brief Get the total amount of device memory available.
1000
1001 @note Supported on all device types.
1002
1003 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
1004 @return The total memory in bytes.
1005 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
1006 @throws MBLTMLError on other failures.
1007 """
1008 _loadLibrary()
1009 value = c_int64()
1010 ret = _clib.mbltmlGetMemoryTotal(dev_no, byref(value))
1011 _mbltmlThrowError(ret)
1012 return value.value
1013
1014
1015def mbltmlGetProcessInfos(dev_no: int) -> List[mbltmlProcessInfo_t]:
1016 """@brief Get per-process usage information for a device.
1017
1018 @note Supported on all device types.
1019
1020 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
1021 @return List of mbltmlProcessInfo_t records; empty if no process is running.
1022 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
1023 @throws MBLTMLError on other failures.
1024 """
1025 _loadLibrary()
1026 c_count = c_uint(0)
1027 ret = _clib.mbltmlGetProcessInfos(dev_no, None, byref(c_count))
1028 _mbltmlThrowError(ret)
1029 if c_count.value == 0: # No running process
1030 return []
1031 c_count.value = c_count.value * 2 # Padding to handle increased process number
1032 info_array = mbltmlProcessInfo_t * c_count.value
1033 infos = info_array()
1034 ret = _clib.mbltmlGetProcessInfos(dev_no, infos, byref(c_count))
1035 _mbltmlThrowError(ret)
1036 return [infos[i] for i in range(c_count.value)]
1037
1038
1039def mbltmlGetCoreInfos(dev_no: int) -> List[mbltmlCoreInfo_t]:
1040 """@brief Get per-core usage information for a device.
1041
1042 @note Supported on all device types.
1043
1044 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
1045 @return List of mbltmlCoreInfo_t records.
1046 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
1047 @throws MBLTMLError on other failures.
1048 """
1049 _loadLibrary()
1050 c_count = c_uint(0)
1051 ret = _clib.mbltmlGetCoreInfos(dev_no, None, byref(c_count))
1052 _mbltmlThrowError(ret)
1053 if c_count.value == 0: # No core
1054 return []
1055 c_count.value = c_count.value
1056 info_array = mbltmlCoreInfo_t * c_count.value
1057 infos = info_array()
1058 ret = _clib.mbltmlGetCoreInfos(dev_no, infos, byref(c_count))
1059 _mbltmlThrowError(ret)
1060 return [infos[i] for i in range(c_count.value)]
1061
1062
1063def mbltmlSetExtraPmicID(dev_no: int, pmic_id: mbltmlExtraPmicId_t) -> None:
1064 """@brief Select which extra PMIC rail subsequent mbltmlGetExtraPmic*() queries refer to.
1065
1066 @note Supported on aries-rb hardware (MBLTML_HARDWARE_VERSION_ARIES_RB) only.
1067
1068 The underlying readings are refreshed by firmware once per second; allow
1069 up to 1 second after this call before mbltmlGetExtraPmicPower(),
1070 mbltmlGetExtraPmicCurrent() and mbltmlGetExtraPmicVoltage() reflect the
1071 newly selected rail.
1072
1073 @param dev_no Device index. Total device count is obtained via mbltmlGetDeviceCount().
1074 @param pmic_id Identifier of the extra PMIC rail to select.
1075 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the device count.
1076 @throws MBLTMLError on other failures.
1077 """
1078 _loadLibrary()
1079 ret = _clib.mbltmlSetExtraPmicID(dev_no, pmic_id)
1080 _mbltmlThrowError(ret)
1081
1082
1083
Raised when the required driver cannot be located.
Definition mbltml.py:314
Raised when the output buffer is too small to hold the result.
Definition mbltml.py:351
Raised when the feature is not supported on the target device.
Definition mbltml.py:342
Raised when an API is called before initialization.
Definition mbltml.py:333
int mbltmlGetOnDeviceDriverRevision(int dev_no)
Get the on-device driver revision number of a device.
Definition mbltml.py:536
int mbltmlGetSubVendorId(int dev_no)
Get the PCIe subsystem vendor ID of a device.
Definition mbltml.py:725
None mbltmlShutdown()
Release all resources held by the mbltml library.
Definition mbltml.py:404
mbltmlHardwareVersion_t mbltmlGetHardwareVersion(int dev_no)
Get the hardware version of a device.
Definition mbltml.py:500
int mbltmlGetDeviceId(int dev_no)
Get the PCIe device ID of a device.
Definition mbltml.py:708
int mbltmlGetFanDuty(int dev_no)
Get the current cooling-fan duty cycle of a device.
Definition mbltml.py:674
int mbltmlGetPcieGen(int dev_no)
Get the negotiated PCIe link generation of a device.
Definition mbltml.py:759
int mbltmlGetPcieLanes(int dev_no)
Get the negotiated PCIe link width (in lanes) of a device.
Definition mbltml.py:776
float mbltmlGetExtraPmicVoltage(int dev_no)
Get the voltage of the extra PMIC rail currently selected for the device (V).
Definition mbltml.py:925
List[mbltmlCoreInfo_t] mbltmlGetCoreInfos(int dev_no)
Get per-core usage information for a device.
Definition mbltml.py:1039
float mbltmlGetExtraPmicCurrent(int dev_no)
Get the current of the extra PMIC rail currently selected for the device (A).
Definition mbltml.py:903
None mbltmlSetExtraPmicID(int dev_no, mbltmlExtraPmicId_t pmic_id)
Select which extra PMIC rail subsequent mbltmlGetExtraPmic*() queries refer to.
Definition mbltml.py:1063
None mbltmlInitDevices(Set[mbltmlDeviceType_t] device_types)
Initialize the mbltml library for a selected set of device types.
Definition mbltml.py:389
float mbltmlGetTotalPower(int dev_no)
Get the total instantaneous power consumption of a device (W).
Definition mbltml.py:827
int mbltmlGetFirmwareRevision(int dev_no)
Get the firmware revision number of a device.
Definition mbltml.py:572
str mbltmlGetNodeName(int dev_no)
Get the node name of a device.
Definition mbltml.py:466
int mbltmlGetFirmwareCRC(int dev_no)
Get the CRC of the currently-loaded firmware image.
Definition mbltml.py:589
str mbltmlGetFirmwareVersion(int dev_no)
Get the firmware version string of a device.
Definition mbltml.py:553
str mbltmlGetOnDeviceDriverVersion(int dev_no)
Get the on-device driver version string of a device.
Definition mbltml.py:517
float mbltmlGetTotalVoltage(int dev_no)
Get the total instantaneous supply voltage of a device (V).
Definition mbltml.py:861
int mbltmlGetMemoryUsage(int dev_no)
Get the amount of device memory currently in use.
Definition mbltml.py:981
int mbltmlGetSignalType(int dev_no)
Get the current signal-type indicator reported by the device.
Definition mbltml.py:623
int mbltmlGetSubDeviceId(int dev_no)
Get the PCIe subsystem device ID of a device.
Definition mbltml.py:742
mbltmlExtraPmicId_t mbltmlGetExtraPmicId(int dev_no)
Get the extra PMIC rail currently selected for the device.
Definition mbltml.py:947
int mbltmlGetPcieRev(int dev_no)
Get the PCIe configuration-space revision ID of a device.
Definition mbltml.py:793
int mbltmlGetPcieClassCode(int dev_no)
Get the PCIe configuration-space class code of a device.
Definition mbltml.py:810
str mbltmlGetDriverVersion(mbltmlDeviceType_t device_type)
Get the driver version string for a specific device family.
Definition mbltml.py:432
int mbltmlGetTemperature(int dev_no)
Get the current die temperature of a device.
Definition mbltml.py:606
List[mbltmlProcessInfo_t] mbltmlGetProcessInfos(int dev_no)
Get per-process usage information for a device.
Definition mbltml.py:1015
mbltmlDeviceType_t mbltmlGetDeviceType(int dev_no)
Get the device family type of a device.
Definition mbltml.py:483
int mbltmlGetNPUClock(int dev_no)
Get the current NPU clock frequency of a device.
Definition mbltml.py:640
int mbltmlGetVendorId(int dev_no)
Get the PCIe vendor ID of a device.
Definition mbltml.py:691
float mbltmlGetTotalCurrent(int dev_no)
Get the total instantaneous current draw of a device (A).
Definition mbltml.py:844
int mbltmlGetDriverRevision(mbltmlDeviceType_t device_type)
Get the driver revision number for a specific device family.
Definition mbltml.py:450
int mbltmlGetBusClock(int dev_no)
Get the current bus clock frequency of a device.
Definition mbltml.py:657
float mbltmlGetTotalUtilization(int dev_no)
Get the overall NPU utilization of a device.
Definition mbltml.py:964
int mbltmlGetMemoryTotal(int dev_no)
Get the total amount of device memory available.
Definition mbltml.py:998
float mbltmlGetExtraPmicPower(int dev_no)
Get the power consumption of the extra PMIC rail currently selected for the device (W).
Definition mbltml.py:878
int mbltmlGetDeviceCount()
Get the total number of devices detected by the library.
Definition mbltml.py:417
None mbltmlInit()
Initialize the mbltml library for all supported device types.
Definition mbltml.py:375
Composite identifier of an NPU core (cluster + core).
Definition type.h:93
Per-core usage record returned by mbltmlGetCoreInfos().
Definition type.h:104
Per-process usage record returned by mbltmlGetProcessInfos().
Definition type.h:117