9from pathlib
import Path
10from typing
import List
17MBLTML_DRIVER_VERSION_BUFFER_SIZE = 80
19MBLTML_ON_DEVICE_DRIVER_VERSION_BUFFER_SIZE = 80
21MBLTML_FIRMWARE_VERSION_BUFFER_SIZE = 80
23MBLTML_NODE_NAME_BUFFER_SIZE = 80
25MBLTML_PCIE_SLOT_BUFFER_SIZE = 80
31mbltmlDriverType_t = c_uint
32MBLTML_DRIVER_ERROR = 0x0
33MBLTML_DRIVER_ARIES = 0x1
34MBLTML_DRIVER_REGULUS = 0x2
35MBLTML_DRIVER_REGULUS_USB = 0x4
38mbltmlTargetDeviceType_t = c_uint
39MBLTML_TARGET_DEVICE_ARIES_RA = 0x00000001
40MBLTML_TARGET_DEVICE_REGULUS_RA = 0x00000002
41MBLTML_TARGET_DEVICE_ARIES_RB = 0x00000003
42MBLTML_TARGET_DEVICE_REGULUS_RB = 0x00000004
43MBLTML_TARGET_DEVICE_REGULUS_RA_USB = 0x00000005
44MBLTML_TARGET_DEVICE_REGULUS_RB_USB = 0x00000006
45MBLTML_TARGET_DEVICE_ERROR = 0x7FFFFFFF
50mbltmlStatusCode_t = c_uint
52MBLTML_DRIVER_NOT_FOUND = 2
53MBLTML_INVALID_ARGUMENT = 3
54MBLTML_UNINITIALIZED = 1
55MBLTML_NOT_SUPPORTED = 4
56MBLTML_INSUFFICIENT_LENGTH = 5
57MBLTML_DEVICE_NOT_FOUND = 6
63mbltmlExtraPmicId_t = c_uint
64MBLTML_EXTRA_PMIC_ID_NPU = 0
65MBLTML_EXTRA_PMIC_ID_DDR = 1
66MBLTML_EXTRA_PMIC_ID_PMIC = 2
67MBLTML_EXTRA_PMIC_ID_GOLDFINGER = 3
70mbltmlCluster_t = c_uint
71MBLTML_CLUSTER_0 = 0x00010000
72MBLTML_CLUSTER_1 = 0x00020000
73MBLTML_CLUSTER_ERROR = 0x7FFF0000
81MBLTML_CORE_GLOBAL = 0x0000FFFE
82MBLTML_CORE_ERROR = 0x0000FFFF
87 """@brief Composite identifier of an NPU core (cluster + core).
89 @var cluster Cluster to which the core belongs (mbltmlCluster_t).
90 @var core Core within the cluster (mbltmlCore_t).
93 cluster: mbltmlCluster_t
96 (
"cluster", mbltmlCluster_t),
97 (
"core", mbltmlCore_t),
101 d = {
"cluster": self.cluster,
"core": self.core}
102 return "{}({})".format(
103 self.__class__.__name__,
104 ", ".join(
"{}={}".format(k, v)
for k, v
in d.items()),
109 """@brief Per-core usage record returned by mbltmlGetCoreInfos().
111 Utilization for the core can be computed as @c npu_time / @c interval
112 when @c interval is non-zero.
114 @var core_id Identifier of the core (mbltmlCoreId_t).
115 @var npu_time Accumulated NPU active time on the core, in microseconds.
116 @var interval Sampling interval covered by @c npu_time, in microseconds.
119 core_id: mbltmlCoreId_t
123 (
"core_id", mbltmlCoreId_t),
124 (
"npu_time", c_int64),
125 (
"interval", c_int64),
130 "core_id": self.core_id,
131 "npu_time": self.npu_time,
132 "interval": self.interval,
134 return "{}({})".format(
135 self.__class__.__name__,
136 ", ".join(
"{}={}".format(k, v)
for k, v
in d.items()),
141 """@brief Per-process usage record returned by mbltmlGetProcessInfos().
143 Utilization for the process can be computed as
144 @c total_npu_time_us / @c total_interval_us when @c total_interval_us
148 @var counts Number of NPU samples attributed to the process.
149 @var npu_memory_usage Device memory currently used by the process, in bytes.
150 @var total_interval_us Total sampling interval, in microseconds.
151 @var total_npu_time_us Total NPU active time used by the process, in microseconds.
156 npu_memory_usage: c_int64
157 total_interval_us: c_int64
158 total_npu_time_us: c_int64
162 (
"npu_memory_usage", c_int64),
163 (
"total_interval_us", c_int64),
164 (
"total_npu_time_us", c_int64),
170 "counts": self.counts,
171 "npu_memory_usage": self.npu_memory_usage,
172 "total_interval_us": self.total_interval_us,
173 "total_npu_time_us": self.total_npu_time_us,
175 return "{}({})".format(
176 self.__class__.__name__,
177 ", ".join(
"{}={}".format(k, v)
for k, v
in d.items()),
184def _loadLibrary() -> None:
188 lib_fname =
"mbltml.dll" if platform.system() ==
"Windows" else f
"libmbltml.so*"
189 pattern = os.path.join(Path(__file__).resolve().parent, lib_fname)
190 candidates = glob.glob(pattern)
192 raise FileNotFoundError(f
"No library matching {pattern}")
193 candidates.sort(key=len, reverse=
True)
194 _clib = CDLL(str(candidates[0]))
196 _clib.mbltmlInit.argtypes = []
197 _clib.mbltmlInit.restype = mbltmlStatusCode_t
198 _clib.mbltmlShutdown.argtypes = []
199 _clib.mbltmlShutdown.restype = mbltmlStatusCode_t
200 _clib.mbltmlGetDeviceCount.argtypes = [POINTER(c_uint)]
201 _clib.mbltmlGetDeviceCount.restype = mbltmlStatusCode_t
202 _clib.mbltmlGetTargetDeviceCount.argtypes = [
203 mbltmlTargetDeviceType_t,
206 _clib.mbltmlGetTargetDeviceCount.restype = mbltmlStatusCode_t
207 _clib.mbltmlGetDriverVersion.argtypes = [mbltmlDriverType_t, POINTER(c_char), c_int]
208 _clib.mbltmlGetDriverVersion.restype = mbltmlStatusCode_t
209 _clib.mbltmlGetDriverRevision.argtypes = [mbltmlDriverType_t, POINTER(c_uint)]
210 _clib.mbltmlGetDriverRevision.restype = mbltmlStatusCode_t
211 _clib.mbltmlGetNodeName.argtypes = [
212 mbltmlTargetDeviceType_t,
217 _clib.mbltmlGetNodeName.restype = mbltmlStatusCode_t
218 _clib.mbltmlGetDriverType.argtypes = [
219 mbltmlTargetDeviceType_t,
221 POINTER(mbltmlDriverType_t),
223 _clib.mbltmlGetDriverType.restype = mbltmlStatusCode_t
224 _clib.mbltmlGetOnDeviceDriverVersion.argtypes = [
225 mbltmlTargetDeviceType_t,
230 _clib.mbltmlGetOnDeviceDriverVersion.restype = mbltmlStatusCode_t
231 _clib.mbltmlGetOnDeviceDriverRevision.argtypes = [
232 mbltmlTargetDeviceType_t,
236 _clib.mbltmlGetOnDeviceDriverRevision.restype = mbltmlStatusCode_t
237 _clib.mbltmlGetFirmwareVersion.argtypes = [
238 mbltmlTargetDeviceType_t,
243 _clib.mbltmlGetFirmwareVersion.restype = mbltmlStatusCode_t
244 _clib.mbltmlGetFirmwareRevision.argtypes = [
245 mbltmlTargetDeviceType_t,
249 _clib.mbltmlGetFirmwareRevision.restype = mbltmlStatusCode_t
250 _clib.mbltmlGetFirmwareCRC.argtypes = [
251 mbltmlTargetDeviceType_t,
255 _clib.mbltmlGetFirmwareCRC.restype = mbltmlStatusCode_t
256 _clib.mbltmlGetTemperature.argtypes = [
257 mbltmlTargetDeviceType_t,
261 _clib.mbltmlGetTemperature.restype = mbltmlStatusCode_t
262 _clib.mbltmlGetPcieSwitchTemperature.argtypes = [
263 mbltmlTargetDeviceType_t,
267 _clib.mbltmlGetPcieSwitchTemperature.restype = mbltmlStatusCode_t
268 _clib.mbltmlGetChipId.argtypes = [mbltmlTargetDeviceType_t, c_int, POINTER(c_int)]
269 _clib.mbltmlGetChipId.restype = mbltmlStatusCode_t
270 _clib.mbltmlGetSignalType.argtypes = [
271 mbltmlTargetDeviceType_t,
275 _clib.mbltmlGetSignalType.restype = mbltmlStatusCode_t
276 _clib.mbltmlGetNPUClock.argtypes = [
277 mbltmlTargetDeviceType_t,
281 _clib.mbltmlGetNPUClock.restype = mbltmlStatusCode_t
282 _clib.mbltmlGetBusClock.argtypes = [
283 mbltmlTargetDeviceType_t,
287 _clib.mbltmlGetBusClock.restype = mbltmlStatusCode_t
288 _clib.mbltmlGetFanDuty.argtypes = [mbltmlTargetDeviceType_t, c_int, POINTER(c_int)]
289 _clib.mbltmlGetFanDuty.restype = mbltmlStatusCode_t
290 _clib.mbltmlGetVendorId.argtypes = [
291 mbltmlTargetDeviceType_t,
295 _clib.mbltmlGetVendorId.restype = mbltmlStatusCode_t
296 _clib.mbltmlGetDeviceId.argtypes = [
297 mbltmlTargetDeviceType_t,
301 _clib.mbltmlGetDeviceId.restype = mbltmlStatusCode_t
302 _clib.mbltmlGetSubVendorId.argtypes = [
303 mbltmlTargetDeviceType_t,
307 _clib.mbltmlGetSubVendorId.restype = mbltmlStatusCode_t
308 _clib.mbltmlGetSubDeviceId.argtypes = [
309 mbltmlTargetDeviceType_t,
313 _clib.mbltmlGetSubDeviceId.restype = mbltmlStatusCode_t
314 _clib.mbltmlGetPcieGen.argtypes = [mbltmlTargetDeviceType_t, c_int, POINTER(c_uint)]
315 _clib.mbltmlGetPcieGen.restype = mbltmlStatusCode_t
316 _clib.mbltmlGetPcieLanes.argtypes = [
317 mbltmlTargetDeviceType_t,
321 _clib.mbltmlGetPcieLanes.restype = mbltmlStatusCode_t
322 _clib.mbltmlGetPcieRev.argtypes = [mbltmlTargetDeviceType_t, c_int, POINTER(c_uint)]
323 _clib.mbltmlGetPcieRev.restype = mbltmlStatusCode_t
324 _clib.mbltmlGetPcieClassCode.argtypes = [
325 mbltmlTargetDeviceType_t,
329 _clib.mbltmlGetPcieClassCode.restype = mbltmlStatusCode_t
330 _clib.mbltmlGetPcieSlot.argtypes = [
331 mbltmlTargetDeviceType_t,
336 _clib.mbltmlGetPcieSlot.restype = mbltmlStatusCode_t
337 _clib.mbltmlGetTotalPower.argtypes = [
338 mbltmlTargetDeviceType_t,
342 _clib.mbltmlGetTotalPower.restype = mbltmlStatusCode_t
343 _clib.mbltmlGetTotalCurrent.argtypes = [
344 mbltmlTargetDeviceType_t,
348 _clib.mbltmlGetTotalCurrent.restype = mbltmlStatusCode_t
349 _clib.mbltmlGetTotalVoltage.argtypes = [
350 mbltmlTargetDeviceType_t,
354 _clib.mbltmlGetTotalVoltage.restype = mbltmlStatusCode_t
355 _clib.mbltmlGetExtraPmicPower.argtypes = [
356 mbltmlTargetDeviceType_t,
360 _clib.mbltmlGetExtraPmicPower.restype = mbltmlStatusCode_t
361 _clib.mbltmlGetExtraPmicCurrent.argtypes = [
362 mbltmlTargetDeviceType_t,
366 _clib.mbltmlGetExtraPmicCurrent.restype = mbltmlStatusCode_t
367 _clib.mbltmlGetExtraPmicVoltage.argtypes = [
368 mbltmlTargetDeviceType_t,
372 _clib.mbltmlGetExtraPmicVoltage.restype = mbltmlStatusCode_t
373 _clib.mbltmlGetExtraPmicId.argtypes = [
374 mbltmlTargetDeviceType_t,
376 POINTER(mbltmlExtraPmicId_t),
378 _clib.mbltmlGetExtraPmicId.restype = mbltmlStatusCode_t
379 _clib.mbltmlGetTotalUtilization.argtypes = [
380 mbltmlTargetDeviceType_t,
384 _clib.mbltmlGetTotalUtilization.restype = mbltmlStatusCode_t
385 _clib.mbltmlGetMemoryUsage.argtypes = [
386 mbltmlTargetDeviceType_t,
390 _clib.mbltmlGetMemoryUsage.restype = mbltmlStatusCode_t
391 _clib.mbltmlGetMemoryTotal.argtypes = [
392 mbltmlTargetDeviceType_t,
396 _clib.mbltmlGetMemoryTotal.restype = mbltmlStatusCode_t
397 _clib.mbltmlGetProcessInfos.argtypes = [
398 mbltmlTargetDeviceType_t,
400 POINTER(mbltmlProcessInfo_t),
403 _clib.mbltmlGetProcessInfos.restype = mbltmlStatusCode_t
404 _clib.mbltmlGetCoreInfos.argtypes = [
405 mbltmlTargetDeviceType_t,
407 POINTER(mbltmlCoreInfo_t),
410 _clib.mbltmlGetCoreInfos.restype = mbltmlStatusCode_t
411 _clib.mbltmlSetExtraPmicID.argtypes = [
412 mbltmlTargetDeviceType_t,
416 _clib.mbltmlSetExtraPmicID.restype = mbltmlStatusCode_t
419class MBLTMLError(Exception):
420 """@brief Base exception raised by the mbltml Python binding.
422 Wraps a non-success mbltmlStatusCode_t returned by the underlying C
423 library. Instantiating MBLTMLError with a known status code yields the
424 matching subclass (e.g., MBLTMLInvalidArgumentError).
426 @var code The mbltmlStatusCode_t value associated with this exception.
430 _errcode_to_string = {
431 MBLTML_DRIVER_NOT_FOUND:
"Driver is not found",
432 MBLTML_INVALID_ARGUMENT:
"Invalid Argument",
433 MBLTML_UNINITIALIZED:
"Uninitilized mbltml.",
434 MBLTML_NOT_SUPPORTED:
"Unspported Function for Target Device",
435 MBLTML_INSUFFICIENT_LENGTH:
"Insufficient Length",
436 MBLTML_DEVICE_NOT_FOUND:
"Device is not found",
439 def __new__(cls, code: mbltmlStatusCode_t):
440 if cls
is MBLTMLError
and code
in MBLTMLError._code_to_class:
441 cls = MBLTMLError._code_to_class[code]
442 obj = Exception.__new__(cls)
447 return MBLTMLError._errcode_to_string[self.code]
449 def __eq__(self, other):
450 return self.code == other.code
454 """@brief Raised when the required driver cannot be located.
456 Wraps MBLTML_DRIVER_NOT_FOUND.
462class MBLTMLInvalidArgumentError(MBLTMLError):
463 """@brief Raised when one or more arguments are invalid.
465 Wraps MBLTML_INVALID_ARGUMENT. Typical causes include a NULL pointer or
466 a @c dev_no that is out of range of the target device type's device count.
473 """@brief Raised when an API is called before initialization.
475 Wraps MBLTML_UNINITIALIZED. Call mbltmlInit() first.
482 """@brief Raised when the feature is not supported on the target device.
484 Wraps MBLTML_NOT_SUPPORTED.
491 """@brief Raised when the output buffer is too small to hold the result.
493 Wraps MBLTML_INSUFFICIENT_LENGTH.
500 """@brief Raised when the requested device cannot be located.
502 Wraps MBLTML_DEVICE_NOT_FOUND.
508MBLTMLError._code_to_class = {
509 MBLTML_DRIVER_NOT_FOUND: MBLTMLDriverNotFoundError,
510 MBLTML_INVALID_ARGUMENT: MBLTMLInvalidArgumentError,
511 MBLTML_UNINITIALIZED: MBLTMLUninitializedError,
512 MBLTML_NOT_SUPPORTED: MBLTMLNotSupportedError,
513 MBLTML_INSUFFICIENT_LENGTH: MBLTMLInsufficientLengthError,
514 MBLTML_DEVICE_NOT_FOUND: MBLTMLDeviceNotFoundError,
518def _mbltmlThrowError(ret: mbltmlStatusCode_t) ->
None:
519 if ret != MBLTML_SUCCESS:
520 raise MBLTMLError(ret)
525 """@brief Initialize the mbltml library.
527 @throws MBLTMLError on failure.
530 ret = _clib.mbltmlInit()
531 _mbltmlThrowError(ret)
535 """@brief Release all resources held by the mbltml library.
537 After this call, any further API usage requires re-initialization via
540 @throws MBLTMLError on failure.
543 ret = _clib.mbltmlShutdown()
544 _mbltmlThrowError(ret)
548 """@brief Get the total number of devices detected by the library.
550 @note Supported on all driver types.
552 This returns the number of all detected devices regardless of their target
553 device type, including devices whose target device type could not be
556 @attention Do not confuse this with mbltmlGetTargetDeviceCount(). Since
557 unidentified devices are not addressable by any (target_device_type,
558 dev_no) pair, this count may exceed the sum over every
559 mbltmlTargetDeviceType_t.
561 @return The number of devices detected.
562 @throws MBLTMLError on failure.
566 ret = _clib.mbltmlGetDeviceCount(byref(value))
567 _mbltmlThrowError(ret)
572 """@brief Get the number of detected devices of a specific target device type.
574 @note Supported on all driver types.
576 @param target_device_type Target device type whose device count is queried.
577 @return The number of devices of @p target_device_type detected, or 0 if
579 @throws MBLTMLError on failure.
583 ret = _clib.mbltmlGetTargetDeviceCount(target_device_type, byref(value))
584 _mbltmlThrowError(ret)
589 """@brief Get the driver version string for a specific driver.
591 @note Supported on all driver types.
593 @param driver_type Driver type whose driver version is queried.
594 @return The driver version string.
595 @throws MBLTMLError on failure.
598 buf = create_string_buffer(MBLTML_DRIVER_VERSION_BUFFER_SIZE)
599 ret = _clib.mbltmlGetDriverVersion(
600 driver_type, buf, MBLTML_DRIVER_VERSION_BUFFER_SIZE
602 _mbltmlThrowError(ret)
603 return buf.value.decode()
607 """@brief Get the driver revision number for a specific driver.
609 @note Supported on all driver types.
611 @param driver_type Driver type whose driver revision is queried.
612 @return The driver revision number.
613 @throws MBLTMLError on failure.
617 ret = _clib.mbltmlGetDriverRevision(driver_type, byref(value))
618 _mbltmlThrowError(ret)
622def mbltmlGetNodeName(target_device_type: mbltmlTargetDeviceType_t, dev_no: int) -> str:
623 """@brief Get the node name of a device.
625 @note Supported on all driver types.
627 @param target_device_type Target device type of the device.
628 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
629 @return The node name string.
630 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
631 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
632 @throws MBLTMLError on other failures.
635 buf = create_string_buffer(MBLTML_NODE_NAME_BUFFER_SIZE)
636 ret = _clib.mbltmlGetNodeName(
637 target_device_type, dev_no, buf, MBLTML_NODE_NAME_BUFFER_SIZE
639 _mbltmlThrowError(ret)
640 return buf.value.decode()
644 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
645) -> mbltmlDriverType_t:
646 """@brief Get the driver type of a device.
648 @note Supported on all driver types.
650 @param target_device_type Target device type of the device.
651 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
652 @return The mbltmlDriverType_t of the device.
653 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
654 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
655 @throws MBLTMLError on other failures.
659 ret = _clib.mbltmlGetDriverType(target_device_type, dev_no, byref(value))
660 _mbltmlThrowError(ret)
665 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
667 """@brief Get the on-device driver version string of a device.
669 @note Supported on MBLTML_DRIVER_REGULUS_USB only.
671 @param target_device_type Target device type of the device.
672 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
673 @return The on-device driver version string.
674 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
675 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
676 @throws MBLTMLError on other failures.
679 buf = create_string_buffer(MBLTML_ON_DEVICE_DRIVER_VERSION_BUFFER_SIZE)
680 ret = _clib.mbltmlGetOnDeviceDriverVersion(
681 target_device_type, dev_no, buf, MBLTML_ON_DEVICE_DRIVER_VERSION_BUFFER_SIZE
683 _mbltmlThrowError(ret)
684 return buf.value.decode()
688 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
690 """@brief Get the on-device driver revision number of a device.
692 @note Supported on MBLTML_DRIVER_REGULUS_USB only.
694 @param target_device_type Target device type of the device.
695 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
696 @return The on-device driver revision.
697 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
698 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
699 @throws MBLTMLError on other failures.
703 ret = _clib.mbltmlGetOnDeviceDriverRevision(
704 target_device_type, dev_no, byref(value)
706 _mbltmlThrowError(ret)
711 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
713 """@brief Get the firmware version string of a device.
715 @note Supported on MBLTML_DRIVER_ARIES only.
717 @param target_device_type Target device type of the device.
718 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
719 @return The firmware version string.
720 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
721 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
722 @throws MBLTMLError on other failures.
725 buf = create_string_buffer(MBLTML_FIRMWARE_VERSION_BUFFER_SIZE)
726 ret = _clib.mbltmlGetFirmwareVersion(
727 target_device_type, dev_no, buf, MBLTML_FIRMWARE_VERSION_BUFFER_SIZE
729 _mbltmlThrowError(ret)
730 return buf.value.decode()
734 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
736 """@brief Get the firmware revision number of a device.
738 @note Supported on MBLTML_DRIVER_ARIES only.
740 @param target_device_type Target device type of the device.
741 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
742 @return The firmware revision.
743 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
744 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
745 @throws MBLTMLError on other failures.
749 ret = _clib.mbltmlGetFirmwareRevision(target_device_type, dev_no, byref(value))
750 _mbltmlThrowError(ret)
755 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
757 """@brief Get the CRC of the currently-loaded firmware image.
759 @note Supported on MBLTML_DRIVER_ARIES only.
761 @param target_device_type Target device type of the device.
762 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
763 @return The firmware CRC.
764 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
765 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
766 @throws MBLTMLError on other failures.
770 ret = _clib.mbltmlGetFirmwareCRC(target_device_type, dev_no, byref(value))
771 _mbltmlThrowError(ret)
776 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
778 """@brief Get the current die temperature of a device.
780 @note Supported on all driver types.
782 @param target_device_type Target device type of the device.
783 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
784 @return The temperature reading.
785 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
786 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
787 @throws MBLTMLError on other failures.
791 ret = _clib.mbltmlGetTemperature(target_device_type, dev_no, byref(value))
792 _mbltmlThrowError(ret)
797 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
799 """@brief Get the current temperature of the PCIe switch of a device.
801 @note Supported on MBLTML_DRIVER_ARIES only.
802 @note A valid reading is available only on the first aries-rb node of an MLA400 board. Any other ARIES device reports 0.
803 @note Requires ARIES firmware v1.2.5 or later. Earlier firmware reports 0.
805 @param target_device_type Target device type of the device.
806 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
807 @return The temperature reading.
808 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
809 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
810 @throws MBLTMLError on other failures.
814 ret = _clib.mbltmlGetPcieSwitchTemperature(target_device_type, dev_no, byref(value))
815 _mbltmlThrowError(ret)
819def mbltmlGetChipId(target_device_type: mbltmlTargetDeviceType_t, dev_no: int) -> int:
820 """@brief Get the chip ID of a device.
822 @note Supported on MBLTML_DRIVER_ARIES only.
823 @note Requires ARIES firmware v1.2.5 or later. Earlier firmware reports 0.
825 @param target_device_type Target device type of the device.
826 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
828 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
829 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
830 @throws MBLTMLError on other failures.
834 ret = _clib.mbltmlGetChipId(target_device_type, dev_no, byref(value))
835 _mbltmlThrowError(ret)
840 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
842 """@brief Get the current signal-type indicator reported by the device.
844 @note Supported on all driver types.
846 @param target_device_type Target device type of the device.
847 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
848 @return The signal-type value.
849 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
850 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
851 @throws MBLTMLError on other failures.
855 ret = _clib.mbltmlGetSignalType(target_device_type, dev_no, byref(value))
856 _mbltmlThrowError(ret)
860def mbltmlGetNPUClock(target_device_type: mbltmlTargetDeviceType_t, dev_no: int) -> int:
861 """@brief Get the current NPU clock frequency of a device.
863 @note Supported on all driver types.
865 @param target_device_type Target device type of the device.
866 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
867 @return The NPU clock value.
868 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
869 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
870 @throws MBLTMLError on other failures.
874 ret = _clib.mbltmlGetNPUClock(target_device_type, dev_no, byref(value))
875 _mbltmlThrowError(ret)
879def mbltmlGetBusClock(target_device_type: mbltmlTargetDeviceType_t, dev_no: int) -> int:
880 """@brief Get the current bus clock frequency of a device.
882 @note Supported on MBLTML_DRIVER_ARIES only.
884 @param target_device_type Target device type of the device.
885 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
886 @return The bus clock value.
887 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
888 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
889 @throws MBLTMLError on other failures.
893 ret = _clib.mbltmlGetBusClock(target_device_type, dev_no, byref(value))
894 _mbltmlThrowError(ret)
898def mbltmlGetFanDuty(target_device_type: mbltmlTargetDeviceType_t, dev_no: int) -> int:
899 """@brief Get the current cooling-fan duty cycle of a device.
901 @note Supported on MBLTML_DRIVER_ARIES only.
903 @param target_device_type Target device type of the device.
904 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
905 @return The fan duty value.
906 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
907 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
908 @throws MBLTMLError on other failures.
912 ret = _clib.mbltmlGetFanDuty(target_device_type, dev_no, byref(value))
913 _mbltmlThrowError(ret)
917def mbltmlGetVendorId(target_device_type: mbltmlTargetDeviceType_t, dev_no: int) -> int:
918 """@brief Get the PCIe vendor ID of a device.
920 @note Supported on MBLTML_DRIVER_ARIES only.
922 @param target_device_type Target device type of the device.
923 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
924 @return The vendor ID.
925 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
926 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
927 @throws MBLTMLError on other failures.
931 ret = _clib.mbltmlGetVendorId(target_device_type, dev_no, byref(value))
932 _mbltmlThrowError(ret)
936def mbltmlGetDeviceId(target_device_type: mbltmlTargetDeviceType_t, dev_no: int) -> int:
937 """@brief Get the PCIe device ID of a device.
939 @note Supported on MBLTML_DRIVER_ARIES only.
941 @param target_device_type Target device type of the device.
942 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
943 @return The device ID.
944 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
945 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
946 @throws MBLTMLError on other failures.
950 ret = _clib.mbltmlGetDeviceId(target_device_type, dev_no, byref(value))
951 _mbltmlThrowError(ret)
956 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
958 """@brief Get the PCIe subsystem vendor ID of a device.
960 @note Supported on MBLTML_DRIVER_ARIES only.
962 @param target_device_type Target device type of the device.
963 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
964 @return The subsystem vendor ID.
965 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
966 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
967 @throws MBLTMLError on other failures.
971 ret = _clib.mbltmlGetSubVendorId(target_device_type, dev_no, byref(value))
972 _mbltmlThrowError(ret)
977 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
979 """@brief Get the PCIe subsystem device ID of a device.
981 @note Supported on MBLTML_DRIVER_ARIES only.
983 @param target_device_type Target device type of the device.
984 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
985 @return The subsystem device ID.
986 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
987 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
988 @throws MBLTMLError on other failures.
992 ret = _clib.mbltmlGetSubDeviceId(target_device_type, dev_no, byref(value))
993 _mbltmlThrowError(ret)
997def mbltmlGetPcieGen(target_device_type: mbltmlTargetDeviceType_t, dev_no: int) -> int:
998 """@brief Get the negotiated PCIe link generation of a device.
1000 @note Supported on MBLTML_DRIVER_ARIES only.
1002 @param target_device_type Target device type of the device.
1003 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1004 @return The PCIe generation.
1005 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1006 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1007 @throws MBLTMLError on other failures.
1011 ret = _clib.mbltmlGetPcieGen(target_device_type, dev_no, byref(value))
1012 _mbltmlThrowError(ret)
1017 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1019 """@brief Get the negotiated PCIe link width (in lanes) of a device.
1021 @note Supported on MBLTML_DRIVER_ARIES only.
1023 @param target_device_type Target device type of the device.
1024 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1025 @return The lane count.
1026 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1027 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1028 @throws MBLTMLError on other failures.
1032 ret = _clib.mbltmlGetPcieLanes(target_device_type, dev_no, byref(value))
1033 _mbltmlThrowError(ret)
1037def mbltmlGetPcieRev(target_device_type: mbltmlTargetDeviceType_t, dev_no: int) -> int:
1038 """@brief Get the PCIe configuration-space revision ID of a device.
1040 @note Supported on MBLTML_DRIVER_ARIES only.
1042 @param target_device_type Target device type of the device.
1043 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1044 @return The revision value.
1045 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1046 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1047 @throws MBLTMLError on other failures.
1051 ret = _clib.mbltmlGetPcieRev(target_device_type, dev_no, byref(value))
1052 _mbltmlThrowError(ret)
1057 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1059 """@brief Get the PCIe configuration-space class code of a device.
1061 @note Supported on MBLTML_DRIVER_ARIES only.
1063 @param target_device_type Target device type of the device.
1064 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1065 @return The class code.
1066 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1067 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1068 @throws MBLTMLError on other failures.
1072 ret = _clib.mbltmlGetPcieClassCode(target_device_type, dev_no, byref(value))
1073 _mbltmlThrowError(ret)
1077def mbltmlGetPcieSlot(target_device_type: mbltmlTargetDeviceType_t, dev_no: int) -> str:
1078 """@brief Get the PCIe slot location of a device.
1080 @note Supported on MBLTML_DRIVER_ARIES only.
1082 @param target_device_type Target device type of the device.
1083 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1084 @return The slot location string, formatted either as an ACPI path (e.g. "0-1-2") or as a BDF address (e.g. "0000:01:00.0").
1085 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1086 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1087 @throws MBLTMLError on other failures.
1090 buf = create_string_buffer(MBLTML_PCIE_SLOT_BUFFER_SIZE)
1091 ret = _clib.mbltmlGetPcieSlot(
1092 target_device_type, dev_no, buf, MBLTML_PCIE_SLOT_BUFFER_SIZE
1094 _mbltmlThrowError(ret)
1095 return buf.value.decode()
1099 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1101 """@brief Get the total instantaneous power consumption of a device (W).
1103 @note Supported on MBLTML_DRIVER_ARIES only.
1105 @param target_device_type Target device type of the device.
1106 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1107 @return The power reading.
1108 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1109 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1110 @throws MBLTMLError on other failures.
1114 ret = _clib.mbltmlGetTotalPower(target_device_type, dev_no, byref(value))
1115 _mbltmlThrowError(ret)
1120 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1122 """@brief Get the total instantaneous current draw of a device (A).
1124 @note Supported on MBLTML_DRIVER_ARIES only.
1126 @param target_device_type Target device type of the device.
1127 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1128 @return The current reading.
1129 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1130 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1131 @throws MBLTMLError on other failures.
1135 ret = _clib.mbltmlGetTotalCurrent(target_device_type, dev_no, byref(value))
1136 _mbltmlThrowError(ret)
1141 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1143 """@brief Get the total instantaneous supply voltage of a device (V).
1145 @note Supported on MBLTML_DRIVER_ARIES only.
1147 @param target_device_type Target device type of the device.
1148 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1149 @return The voltage reading.
1150 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1151 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1152 @throws MBLTMLError on other failures.
1156 ret = _clib.mbltmlGetTotalVoltage(target_device_type, dev_no, byref(value))
1157 _mbltmlThrowError(ret)
1162 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1164 """@brief Get the power consumption of the extra PMIC rail currently
1165 selected for the device (W).
1167 @note Supported on MBLTML_DRIVER_ARIES only.
1169 The selected rail is controlled by mbltmlSetExtraPmicID() and can be
1170 queried via mbltmlGetExtraPmicId().
1172 The firmware refreshes this reading once per second. After changing the
1173 selected rail with mbltmlSetExtraPmicID(), allow up to 1 second for the
1174 new rail's value to be reported.
1176 @param target_device_type Target device type of the device.
1177 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1178 @return The power reading.
1179 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1180 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1181 @throws MBLTMLError on other failures.
1185 ret = _clib.mbltmlGetExtraPmicPower(target_device_type, dev_no, byref(value))
1186 _mbltmlThrowError(ret)
1191 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1193 """@brief Get the current of the extra PMIC rail currently selected
1196 @note Supported on MBLTML_DRIVER_ARIES only.
1198 The firmware refreshes this reading once per second. After changing the
1199 selected rail with mbltmlSetExtraPmicID(), allow up to 1 second for the
1200 new rail's value to be reported.
1202 @param target_device_type Target device type of the device.
1203 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1204 @return The current reading.
1205 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1206 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1207 @throws MBLTMLError on other failures.
1211 ret = _clib.mbltmlGetExtraPmicCurrent(target_device_type, dev_no, byref(value))
1212 _mbltmlThrowError(ret)
1217 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1219 """@brief Get the voltage of the extra PMIC rail currently selected
1222 @note Supported on MBLTML_DRIVER_ARIES only.
1224 The firmware refreshes this reading once per second. After changing the
1225 selected rail with mbltmlSetExtraPmicID(), allow up to 1 second for the
1226 new rail's value to be reported.
1228 @param target_device_type Target device type of the device.
1229 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1230 @return The voltage reading.
1231 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1232 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1233 @throws MBLTMLError on other failures.
1237 ret = _clib.mbltmlGetExtraPmicVoltage(target_device_type, dev_no, byref(value))
1238 _mbltmlThrowError(ret)
1243 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1244) -> mbltmlExtraPmicId_t:
1245 """@brief Get the extra PMIC rail currently selected for the device.
1247 @note Supported on MBLTML_DRIVER_ARIES only.
1249 @param target_device_type Target device type of the device.
1250 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1251 @return The selected mbltmlExtraPmicId_t value.
1252 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1253 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1254 @throws MBLTMLError on other failures.
1258 ret = _clib.mbltmlGetExtraPmicId(target_device_type, dev_no, byref(value))
1259 _mbltmlThrowError(ret)
1264 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1266 """@brief Get the overall NPU utilization of a device.
1268 @note Supported on all driver types.
1270 @param target_device_type Target device type of the device.
1271 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1272 @return The utilization value (typically a ratio in [0.0, 1.0] or a percentage).
1273 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1274 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1275 @throws MBLTMLError on other failures.
1279 ret = _clib.mbltmlGetTotalUtilization(target_device_type, dev_no, byref(value))
1280 _mbltmlThrowError(ret)
1285 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1287 """@brief Get the amount of device memory currently in use.
1289 @note Supported on all driver types.
1291 @param target_device_type Target device type of the device.
1292 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1293 @return The in-use memory in bytes.
1294 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1295 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1296 @throws MBLTMLError on other failures.
1300 ret = _clib.mbltmlGetMemoryUsage(target_device_type, dev_no, byref(value))
1301 _mbltmlThrowError(ret)
1306 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1308 """@brief Get the total amount of device memory available.
1310 @note Supported on all driver types.
1312 @param target_device_type Target device type of the device.
1313 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1314 @return The total memory in bytes.
1315 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1316 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1317 @throws MBLTMLError on other failures.
1321 ret = _clib.mbltmlGetMemoryTotal(target_device_type, dev_no, byref(value))
1322 _mbltmlThrowError(ret)
1327 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1328) -> List[mbltmlProcessInfo_t]:
1329 """@brief Get per-process usage information for a device.
1331 @note Supported on all driver types.
1333 @param target_device_type Target device type of the device.
1334 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1335 @return List of mbltmlProcessInfo_t records; empty if no process is running.
1336 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1337 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1338 @throws MBLTMLError on other failures.
1342 ret = _clib.mbltmlGetProcessInfos(target_device_type, dev_no,
None, byref(c_count))
1343 _mbltmlThrowError(ret)
1344 if c_count.value == 0:
1346 c_count.value = c_count.value * 2
1347 info_array = mbltmlProcessInfo_t * c_count.value
1348 infos = info_array()
1349 ret = _clib.mbltmlGetProcessInfos(target_device_type, dev_no, infos, byref(c_count))
1350 _mbltmlThrowError(ret)
1351 return [infos[i]
for i
in range(c_count.value)]
1355 target_device_type: mbltmlTargetDeviceType_t, dev_no: int
1356) -> List[mbltmlCoreInfo_t]:
1357 """@brief Get per-core usage information for a device.
1359 @note Supported on all driver types.
1361 @param target_device_type Target device type of the device.
1362 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1363 @return List of mbltmlCoreInfo_t records.
1364 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1365 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1366 @throws MBLTMLError on other failures.
1370 ret = _clib.mbltmlGetCoreInfos(target_device_type, dev_no,
None, byref(c_count))
1371 _mbltmlThrowError(ret)
1372 if c_count.value == 0:
1374 c_count.value = c_count.value
1375 info_array = mbltmlCoreInfo_t * c_count.value
1376 infos = info_array()
1377 ret = _clib.mbltmlGetCoreInfos(target_device_type, dev_no, infos, byref(c_count))
1378 _mbltmlThrowError(ret)
1379 return [infos[i]
for i
in range(c_count.value)]
1383 target_device_type: mbltmlTargetDeviceType_t,
1385 pmic_id: mbltmlExtraPmicId_t,
1387 """@brief Select which extra PMIC rail subsequent mbltmlGetExtraPmic*() queries refer to.
1389 @note Supported on aries-rb device (MBLTML_TARGET_DEVICE_ARIES_RB) only.
1391 The underlying readings are refreshed by firmware once per second; allow
1392 up to 1 second after this call before mbltmlGetExtraPmicPower(),
1393 mbltmlGetExtraPmicCurrent() and mbltmlGetExtraPmicVoltage() reflect the
1394 newly selected rail.
1396 @param target_device_type Target device type of the device.
1397 @param dev_no Device index within @p target_device_type. Device count is obtained via mbltmlGetTargetDeviceCount().
1398 @param pmic_id Identifier of the extra PMIC rail to select.
1399 @throws MBLTMLInvalidArgumentError if @p dev_no is out of range of the @p target_device_type device count.
1400 @throws MBLTMLDeviceNotFoundError if no device of @p target_device_type is detected.
1401 @throws MBLTMLError on other failures.
1404 ret = _clib.mbltmlSetExtraPmicID(target_device_type, dev_no, pmic_id)
1405 _mbltmlThrowError(ret)
Raised when the requested device cannot be located.
Raised when the required driver cannot be located.
Raised when the output buffer is too small to hold the result.
Raised when the feature is not supported on the target device.
Raised when an API is called before initialization.
None mbltmlShutdown()
Release all resources held by the mbltml library.
int mbltmlGetVendorId(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the PCIe vendor ID of a device.
int mbltmlGetFirmwareCRC(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the CRC of the currently-loaded firmware image.
List[mbltmlProcessInfo_t] mbltmlGetProcessInfos(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get per-process usage information for a device.
int mbltmlGetTemperature(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the current die temperature of a device.
List[mbltmlCoreInfo_t] mbltmlGetCoreInfos(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get per-core usage information for a device.
int mbltmlGetPcieGen(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the negotiated PCIe link generation of a device.
int mbltmlGetNPUClock(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the current NPU clock frequency of a device.
int mbltmlGetTargetDeviceCount(mbltmlTargetDeviceType_t target_device_type)
Get the number of detected devices of a specific target device type.
float mbltmlGetExtraPmicCurrent(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the current of the extra PMIC rail currently selected for the device (A).
int mbltmlGetFanDuty(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the current cooling-fan duty cycle of a device.
int mbltmlGetChipId(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the chip ID of a device.
float mbltmlGetTotalUtilization(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the overall NPU utilization of a device.
int mbltmlGetSubDeviceId(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the PCIe subsystem device ID of a device.
int mbltmlGetMemoryUsage(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the amount of device memory currently in use.
int mbltmlGetFirmwareRevision(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the firmware revision number of a device.
int mbltmlGetPcieSwitchTemperature(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the current temperature of the PCIe switch of a device.
int mbltmlGetBusClock(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the current bus clock frequency of a device.
float mbltmlGetExtraPmicVoltage(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the voltage of the extra PMIC rail currently selected for the device (V).
float mbltmlGetTotalCurrent(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the total instantaneous current draw of a device (A).
float mbltmlGetTotalPower(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the total instantaneous power consumption of a device (W).
mbltmlDriverType_t mbltmlGetDriverType(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the driver type of a device.
int mbltmlGetOnDeviceDriverRevision(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the on-device driver revision number of a device.
int mbltmlGetSignalType(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the current signal-type indicator reported by the device.
float mbltmlGetTotalVoltage(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the total instantaneous supply voltage of a device (V).
str mbltmlGetDriverVersion(mbltmlDriverType_t driver_type)
Get the driver version string for a specific driver.
str mbltmlGetNodeName(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the node name of a device.
str mbltmlGetFirmwareVersion(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the firmware version string of a device.
str mbltmlGetOnDeviceDriverVersion(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the on-device driver version string of a device.
int mbltmlGetPcieRev(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the PCIe configuration-space revision ID of a device.
int mbltmlGetSubVendorId(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the PCIe subsystem vendor ID of a device.
None mbltmlSetExtraPmicID(mbltmlTargetDeviceType_t target_device_type, int dev_no, mbltmlExtraPmicId_t pmic_id)
Select which extra PMIC rail subsequent mbltmlGetExtraPmic*() queries refer to.
int mbltmlGetMemoryTotal(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the total amount of device memory available.
mbltmlExtraPmicId_t mbltmlGetExtraPmicId(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the extra PMIC rail currently selected for the device.
int mbltmlGetDeviceId(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the PCIe device ID of a device.
str mbltmlGetPcieSlot(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the PCIe slot location of a device.
int mbltmlGetPcieLanes(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the negotiated PCIe link width (in lanes) of a device.
int mbltmlGetDriverRevision(mbltmlDriverType_t driver_type)
Get the driver revision number for a specific driver.
int mbltmlGetDeviceCount()
Get the total number of devices detected by the library.
None mbltmlInit()
Initialize the mbltml library.
int mbltmlGetPcieClassCode(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the PCIe configuration-space class code of a device.
float mbltmlGetExtraPmicPower(mbltmlTargetDeviceType_t target_device_type, int dev_no)
Get the power consumption of the extra PMIC rail currently selected for the device (W).
Composite identifier of an NPU core (cluster + core).
Per-core usage record returned by mbltmlGetCoreInfos().
Per-process usage record returned by mbltmlGetProcessInfos().