1"""
2 Copyright (C) 2019-2021 Intel Corporation
3
4 SPDX-License-Identifier: MIT
5
6 @file zes.py
7 @version v1.3-r1.3.7
8
9 """
10import platform
11from ctypes import *
12from enum import *
13
14###############################################################################
15__version__ = "1.0"
16
17###############################################################################
18## @brief Handle to a driver instance
19class zes_driver_handle_t(c_void_p):
20    pass
21
22###############################################################################
23## @brief Handle of device object
24class zes_device_handle_t(c_void_p):
25    pass
26
27###############################################################################
28## @brief Handle for a Sysman device scheduler queue
29class zes_sched_handle_t(c_void_p):
30    pass
31
32###############################################################################
33## @brief Handle for a Sysman device performance factors
34class zes_perf_handle_t(c_void_p):
35    pass
36
37###############################################################################
38## @brief Handle for a Sysman device power domain
39class zes_pwr_handle_t(c_void_p):
40    pass
41
42###############################################################################
43## @brief Handle for a Sysman device frequency domain
44class zes_freq_handle_t(c_void_p):
45    pass
46
47###############################################################################
48## @brief Handle for a Sysman device engine group
49class zes_engine_handle_t(c_void_p):
50    pass
51
52###############################################################################
53## @brief Handle for a Sysman device standby control
54class zes_standby_handle_t(c_void_p):
55    pass
56
57###############################################################################
58## @brief Handle for a Sysman device firmware
59class zes_firmware_handle_t(c_void_p):
60    pass
61
62###############################################################################
63## @brief Handle for a Sysman device memory module
64class zes_mem_handle_t(c_void_p):
65    pass
66
67###############################################################################
68## @brief Handle for a Sysman fabric port
69class zes_fabric_port_handle_t(c_void_p):
70    pass
71
72###############################################################################
73## @brief Handle for a Sysman device temperature sensor
74class zes_temp_handle_t(c_void_p):
75    pass
76
77###############################################################################
78## @brief Handle for a Sysman device power supply
79class zes_psu_handle_t(c_void_p):
80    pass
81
82###############################################################################
83## @brief Handle for a Sysman device fan
84class zes_fan_handle_t(c_void_p):
85    pass
86
87###############################################################################
88## @brief Handle for a Sysman device LED
89class zes_led_handle_t(c_void_p):
90    pass
91
92###############################################################################
93## @brief Handle for a Sysman device RAS error set
94class zes_ras_handle_t(c_void_p):
95    pass
96
97###############################################################################
98## @brief Handle for a Sysman device diagnostics test suite
99class zes_diag_handle_t(c_void_p):
100    pass
101
102###############################################################################
103## @brief Defines structure types
104class zes_structure_type_v(IntEnum):
105    DEVICE_PROPERTIES = 0x1                         ## ::zes_device_properties_t
106    PCI_PROPERTIES = 0x2                            ## ::zes_pci_properties_t
107    PCI_BAR_PROPERTIES = 0x3                        ## ::zes_pci_bar_properties_t
108    DIAG_PROPERTIES = 0x4                           ## ::zes_diag_properties_t
109    ENGINE_PROPERTIES = 0x5                         ## ::zes_engine_properties_t
110    FABRIC_PORT_PROPERTIES = 0x6                    ## ::zes_fabric_port_properties_t
111    FAN_PROPERTIES = 0x7                            ## ::zes_fan_properties_t
112    FIRMWARE_PROPERTIES = 0x8                       ## ::zes_firmware_properties_t
113    FREQ_PROPERTIES = 0x9                           ## ::zes_freq_properties_t
114    LED_PROPERTIES = 0xa                            ## ::zes_led_properties_t
115    MEM_PROPERTIES = 0xb                            ## ::zes_mem_properties_t
116    PERF_PROPERTIES = 0xc                           ## ::zes_perf_properties_t
117    POWER_PROPERTIES = 0xd                          ## ::zes_power_properties_t
118    PSU_PROPERTIES = 0xe                            ## ::zes_psu_properties_t
119    RAS_PROPERTIES = 0xf                            ## ::zes_ras_properties_t
120    SCHED_PROPERTIES = 0x10                         ## ::zes_sched_properties_t
121    SCHED_TIMEOUT_PROPERTIES = 0x11                 ## ::zes_sched_timeout_properties_t
122    SCHED_TIMESLICE_PROPERTIES = 0x12               ## ::zes_sched_timeslice_properties_t
123    STANDBY_PROPERTIES = 0x13                       ## ::zes_standby_properties_t
124    TEMP_PROPERTIES = 0x14                          ## ::zes_temp_properties_t
125    DEVICE_STATE = 0x15                             ## ::zes_device_state_t
126    PROCESS_STATE = 0x16                            ## ::zes_process_state_t
127    PCI_STATE = 0x17                                ## ::zes_pci_state_t
128    FABRIC_PORT_CONFIG = 0x18                       ## ::zes_fabric_port_config_t
129    FABRIC_PORT_STATE = 0x19                        ## ::zes_fabric_port_state_t
130    FAN_CONFIG = 0x1a                               ## ::zes_fan_config_t
131    FREQ_STATE = 0x1b                               ## ::zes_freq_state_t
132    OC_CAPABILITIES = 0x1c                          ## ::zes_oc_capabilities_t
133    LED_STATE = 0x1d                                ## ::zes_led_state_t
134    MEM_STATE = 0x1e                                ## ::zes_mem_state_t
135    PSU_STATE = 0x1f                                ## ::zes_psu_state_t
136    BASE_STATE = 0x20                               ## ::zes_base_state_t
137    RAS_CONFIG = 0x21                               ## ::zes_ras_config_t
138    RAS_STATE = 0x22                                ## ::zes_ras_state_t
139    TEMP_CONFIG = 0x23                              ## ::zes_temp_config_t
140    PCI_BAR_PROPERTIES_1_2 = 0x24                   ## ::zes_pci_bar_properties_1_2_t
141
142class zes_structure_type_t(c_int):
143    def __str__(self):
144        return str(zes_structure_type_v(self.value))
145
146
147###############################################################################
148## @brief Base for all properties types
149class zes_base_properties_t(Structure):
150    _fields_ = [
151        ("stype", zes_structure_type_t),                                ## [in] type of this structure
152        ("pNext", c_void_p)                                             ## [in,out][optional] pointer to extension-specific structure
153    ]
154
155###############################################################################
156## @brief Base for all descriptor types
157class zes_base_desc_t(Structure):
158    _fields_ = [
159        ("stype", zes_structure_type_t),                                ## [in] type of this structure
160        ("pNext", c_void_p)                                             ## [in][optional] pointer to extension-specific structure
161    ]
162
163###############################################################################
164## @brief Base for all state types
165class zes_base_state_t(Structure):
166    _fields_ = [
167        ("stype", zes_structure_type_t),                                ## [in] type of this structure
168        ("pNext", c_void_p)                                             ## [in][optional] pointer to extension-specific structure
169    ]
170
171###############################################################################
172## @brief Base for all config types
173class zes_base_config_t(Structure):
174    _fields_ = [
175        ("stype", zes_structure_type_t),                                ## [in] type of this structure
176        ("pNext", c_void_p)                                             ## [in][optional] pointer to extension-specific structure
177    ]
178
179###############################################################################
180## @brief Base for all capability types
181class zes_base_capability_t(Structure):
182    _fields_ = [
183        ("stype", zes_structure_type_t),                                ## [in] type of this structure
184        ("pNext", c_void_p)                                             ## [in][optional] pointer to extension-specific structure
185    ]
186
187###############################################################################
188## @brief Maximum number of characters in string properties.
189ZES_STRING_PROPERTY_SIZE = 64
190
191###############################################################################
192## @brief Types of accelerator engines
193class zes_engine_type_flags_v(IntEnum):
194    OTHER = ZE_BIT(0)                               ## Undefined types of accelerators.
195    COMPUTE = ZE_BIT(1)                             ## Engines that process compute kernels only (no 3D content).
196    _3D = ZE_BIT(2)                                 ## Engines that process 3D content only (no compute kernels).
197    MEDIA = ZE_BIT(3)                               ## Engines that process media workloads.
198    DMA = ZE_BIT(4)                                 ## Engines that copy blocks of data.
199    RENDER = ZE_BIT(5)                              ## Engines that can process both 3D content and compute kernels.
200
201class zes_engine_type_flags_t(c_int):
202    def __str__(self):
203        return hex(self.value)
204
205
206###############################################################################
207## @brief Device repair status
208class zes_repair_status_v(IntEnum):
209    UNSUPPORTED = 0                                 ## The device does not support in-field repairs.
210    NOT_PERFORMED = 1                               ## The device has never been repaired.
211    PERFORMED = 2                                   ## The device has been repaired.
212
213class zes_repair_status_t(c_int):
214    def __str__(self):
215        return str(zes_repair_status_v(self.value))
216
217
218###############################################################################
219## @brief Device reset reasons
220class zes_reset_reason_flags_v(IntEnum):
221    WEDGED = ZE_BIT(0)                              ## The device needs to be reset because one or more parts of the hardware
222                                                    ## is wedged
223    REPAIR = ZE_BIT(1)                              ## The device needs to be reset in order to complete in-field repairs
224
225class zes_reset_reason_flags_t(c_int):
226    def __str__(self):
227        return hex(self.value)
228
229
230###############################################################################
231## @brief Device state
232class zes_device_state_t(Structure):
233    _fields_ = [
234        ("stype", zes_structure_type_t),                                ## [in] type of this structure
235        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
236        ("reset", zes_reset_reason_flags_t),                            ## [out] Indicates if the device needs to be reset and for what reasons.
237                                                                        ## returns 0 (none) or combination of ::zes_reset_reason_flag_t
238        ("repaired", zes_repair_status_t)                               ## [out] Indicates if the device has been repaired
239    ]
240
241###############################################################################
242## @brief Device properties
243class zes_device_properties_t(Structure):
244    _fields_ = [
245        ("stype", zes_structure_type_t),                                ## [in] type of this structure
246        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
247        ("core", ze_device_properties_t),                               ## [out] Core device properties
248        ("numSubdevices", c_ulong),                                     ## [out] Number of sub-devices. A value of 0 indicates that this device
249                                                                        ## doesn't have sub-devices.
250        ("serialNumber", c_char * ZES_STRING_PROPERTY_SIZE),            ## [out] Manufacturing serial number (NULL terminated string value). Will
251                                                                        ## be set to the string "unkown" if this cannot be determined for the
252                                                                        ## device.
253        ("boardNumber", c_char * ZES_STRING_PROPERTY_SIZE),             ## [out] Manufacturing board number (NULL terminated string value). Will
254                                                                        ## be set to the string "unkown" if this cannot be determined for the
255                                                                        ## device.
256        ("brandName", c_char * ZES_STRING_PROPERTY_SIZE),               ## [out] Brand name of the device (NULL terminated string value). Will be
257                                                                        ## set to the string "unkown" if this cannot be determined for the
258                                                                        ## device.
259        ("modelName", c_char * ZES_STRING_PROPERTY_SIZE),               ## [out] Model name of the device (NULL terminated string value). Will be
260                                                                        ## set to the string "unkown" if this cannot be determined for the
261                                                                        ## device.
262        ("vendorName", c_char * ZES_STRING_PROPERTY_SIZE),              ## [out] Vendor name of the device (NULL terminated string value). Will
263                                                                        ## be set to the string "unkown" if this cannot be determined for the
264                                                                        ## device.
265        ("driverVersion", c_char * ZES_STRING_PROPERTY_SIZE)            ## [out] Installed driver version (NULL terminated string value). Will be
266                                                                        ## set to the string "unkown" if this cannot be determined for the
267                                                                        ## device.
268    ]
269
270###############################################################################
271## @brief Contains information about a process that has an open connection with
272##        this device
273##
274## @details
275##     - The application can use the process ID to query the OS for the owner
276##       and the path to the executable.
277class zes_process_state_t(Structure):
278    _fields_ = [
279        ("stype", zes_structure_type_t),                                ## [in] type of this structure
280        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
281        ("processId", c_ulong),                                         ## [out] Host OS process ID.
282        ("memSize", c_ulonglong),                                       ## [out] Device memory size in bytes allocated by this process (may not
283                                                                        ## necessarily be resident on the device at the time of reading).
284        ("sharedSize", c_ulonglong),                                    ## [out] The size of shared device memory mapped into this process (may
285                                                                        ## not necessarily be resident on the device at the time of reading).
286        ("engines", zes_engine_type_flags_t)                            ## [out] Bitfield of accelerator engine types being used by this process.
287    ]
288
289###############################################################################
290## @brief PCI address
291class zes_pci_address_t(Structure):
292    _fields_ = [
293        ("domain", c_ulong),                                            ## [out] BDF domain
294        ("bus", c_ulong),                                               ## [out] BDF bus
295        ("device", c_ulong),                                            ## [out] BDF device
296        ("function", c_ulong)                                           ## [out] BDF function
297    ]
298
299###############################################################################
300## @brief PCI speed
301class zes_pci_speed_t(Structure):
302    _fields_ = [
303        ("gen", c_int32_t),                                             ## [out] The link generation. A value of -1 means that this property is
304                                                                        ## unknown.
305        ("width", c_int32_t),                                           ## [out] The number of lanes. A value of -1 means that this property is
306                                                                        ## unknown.
307        ("maxBandwidth", c_int64_t)                                     ## [out] The maximum bandwidth in bytes/sec (sum of all lanes). A value
308                                                                        ## of -1 means that this property is unknown.
309    ]
310
311###############################################################################
312## @brief Static PCI properties
313class zes_pci_properties_t(Structure):
314    _fields_ = [
315        ("stype", zes_structure_type_t),                                ## [in] type of this structure
316        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
317        ("address", zes_pci_address_t),                                 ## [out] The BDF address
318        ("maxSpeed", zes_pci_speed_t),                                  ## [out] Fastest port configuration supported by the device (sum of all
319                                                                        ## lanes)
320        ("haveBandwidthCounters", ze_bool_t),                           ## [out] Indicates if ::zes_pci_stats_t.rxCounter and
321                                                                        ## ::zes_pci_stats_t.txCounter will have valid values
322        ("havePacketCounters", ze_bool_t),                              ## [out] Indicates if ::zes_pci_stats_t.packetCounter will have valid
323                                                                        ## values
324        ("haveReplayCounters", ze_bool_t)                               ## [out] Indicates if ::zes_pci_stats_t.replayCounter will have valid
325                                                                        ## values
326    ]
327
328###############################################################################
329## @brief PCI link status
330class zes_pci_link_status_v(IntEnum):
331    UNKNOWN = 0                                     ## The link status could not be determined
332    GOOD = 1                                        ## The link is up and operating as expected
333    QUALITY_ISSUES = 2                              ## The link is up but has quality and/or bandwidth degradation
334    STABILITY_ISSUES = 3                            ## The link has stability issues and preventing workloads making forward
335                                                    ## progress
336
337class zes_pci_link_status_t(c_int):
338    def __str__(self):
339        return str(zes_pci_link_status_v(self.value))
340
341
342###############################################################################
343## @brief PCI link quality degradation reasons
344class zes_pci_link_qual_issue_flags_v(IntEnum):
345    REPLAYS = ZE_BIT(0)                             ## A significant number of replays are occurring
346    SPEED = ZE_BIT(1)                               ## There is a degradation in the maximum bandwidth of the link
347
348class zes_pci_link_qual_issue_flags_t(c_int):
349    def __str__(self):
350        return hex(self.value)
351
352
353###############################################################################
354## @brief PCI link stability issues
355class zes_pci_link_stab_issue_flags_v(IntEnum):
356    RETRAINING = ZE_BIT(0)                          ## Link retraining has occurred to deal with quality issues
357
358class zes_pci_link_stab_issue_flags_t(c_int):
359    def __str__(self):
360        return hex(self.value)
361
362
363###############################################################################
364## @brief Dynamic PCI state
365class zes_pci_state_t(Structure):
366    _fields_ = [
367        ("stype", zes_structure_type_t),                                ## [in] type of this structure
368        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
369        ("status", zes_pci_link_status_t),                              ## [out] The current status of the port
370        ("qualityIssues", zes_pci_link_qual_issue_flags_t),             ## [out] If status is ::ZES_PCI_LINK_STATUS_QUALITY_ISSUES,
371                                                                        ## then this gives a combination of ::zes_pci_link_qual_issue_flag_t for
372                                                                        ## quality issues that have been detected;
373                                                                        ## otherwise, 0 indicates there are no quality issues with the link at
374                                                                        ## this time."
375        ("stabilityIssues", zes_pci_link_stab_issue_flags_t),           ## [out] If status is ::ZES_PCI_LINK_STATUS_STABILITY_ISSUES,
376                                                                        ## then this gives a combination of ::zes_pci_link_stab_issue_flag_t for
377                                                                        ## reasons for the connection instability;
378                                                                        ## otherwise, 0 indicates there are no connection stability issues at
379                                                                        ## this time."
380        ("speed", zes_pci_speed_t)                                      ## [out] The current port configure speed
381    ]
382
383###############################################################################
384## @brief PCI bar types
385class zes_pci_bar_type_v(IntEnum):
386    MMIO = 0                                        ## MMIO registers
387    ROM = 1                                         ## ROM aperture
388    MEM = 2                                         ## Device memory
389
390class zes_pci_bar_type_t(c_int):
391    def __str__(self):
392        return str(zes_pci_bar_type_v(self.value))
393
394
395###############################################################################
396## @brief Properties of a pci bar
397class zes_pci_bar_properties_t(Structure):
398    _fields_ = [
399        ("stype", zes_structure_type_t),                                ## [in] type of this structure
400        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
401        ("type", zes_pci_bar_type_t),                                   ## [out] The type of bar
402        ("index", c_ulong),                                             ## [out] The index of the bar
403        ("base", c_ulonglong),                                          ## [out] Base address of the bar.
404        ("size", c_ulonglong)                                           ## [out] Size of the bar.
405    ]
406
407###############################################################################
408## @brief Properties of a pci bar, including the resizable bar.
409class zes_pci_bar_properties_1_2_t(Structure):
410    _fields_ = [
411        ("stype", zes_structure_type_t),                                ## [in] type of this structure
412        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
413        ("type", zes_pci_bar_type_t),                                   ## [out] The type of bar
414        ("index", c_ulong),                                             ## [out] The index of the bar
415        ("base", c_ulonglong),                                          ## [out] Base address of the bar.
416        ("size", c_ulonglong),                                          ## [out] Size of the bar.
417        ("resizableBarSupported", ze_bool_t),                           ## [out] Support for Resizable Bar on this device.
418        ("resizableBarEnabled", ze_bool_t)                              ## [out] Resizable Bar enabled on this device
419    ]
420
421###############################################################################
422## @brief PCI stats counters
423##
424## @details
425##     - Percent replays is calculated by taking two snapshots (s1, s2) and
426##       using the equation: %replay = 10^6 * (s2.replayCounter -
427##       s1.replayCounter) / (s2.maxBandwidth * (s2.timestamp - s1.timestamp))
428##     - Percent throughput is calculated by taking two snapshots (s1, s2) and
429##       using the equation: %bw = 10^6 * ((s2.rxCounter - s1.rxCounter) +
430##       (s2.txCounter - s1.txCounter)) / (s2.maxBandwidth * (s2.timestamp -
431##       s1.timestamp))
432class zes_pci_stats_t(Structure):
433    _fields_ = [
434        ("timestamp", c_ulonglong),                                     ## [out] Monotonic timestamp counter in microseconds when the measurement
435                                                                        ## was made.
436                                                                        ## This timestamp should only be used to calculate delta time between
437                                                                        ## snapshots of this structure.
438                                                                        ## Never take the delta of this timestamp with the timestamp from a
439                                                                        ## different structure since they are not guaranteed to have the same base.
440                                                                        ## The absolute value of the timestamp is only valid during within the
441                                                                        ## application and may be different on the next execution.
442        ("replayCounter", c_ulonglong),                                 ## [out] Monotonic counter for the number of replay packets (sum of all
443                                                                        ## lanes). Will always be 0 if ::zes_pci_properties_t.haveReplayCounters
444                                                                        ## is FALSE.
445        ("packetCounter", c_ulonglong),                                 ## [out] Monotonic counter for the number of packets (sum of all lanes).
446                                                                        ## Will always be 0 if ::zes_pci_properties_t.havePacketCounters is
447                                                                        ## FALSE.
448        ("rxCounter", c_ulonglong),                                     ## [out] Monotonic counter for the number of bytes received (sum of all
449                                                                        ## lanes). Will always be 0 if
450                                                                        ## ::zes_pci_properties_t.haveBandwidthCounters is FALSE.
451        ("txCounter", c_ulonglong),                                     ## [out] Monotonic counter for the number of bytes transmitted (including
452                                                                        ## replays) (sum of all lanes). Will always be 0 if
453                                                                        ## ::zes_pci_properties_t.haveBandwidthCounters is FALSE.
454        ("speed", zes_pci_speed_t)                                      ## [out] The current speed of the link (sum of all lanes)
455    ]
456
457###############################################################################
458## @brief Diagnostic results
459class zes_diag_result_v(IntEnum):
460    NO_ERRORS = 0                                   ## Diagnostic completed without finding errors to repair
461    ABORT = 1                                       ## Diagnostic had problems running tests
462    FAIL_CANT_REPAIR = 2                            ## Diagnostic had problems setting up repairs
463    REBOOT_FOR_REPAIR = 3                           ## Diagnostics found errors, setup for repair and reboot is required to
464                                                    ## complete the process
465
466class zes_diag_result_t(c_int):
467    def __str__(self):
468        return str(zes_diag_result_v(self.value))
469
470
471###############################################################################
472## @brief Diagnostic test index to use for the very first test.
473ZES_DIAG_FIRST_TEST_INDEX = 0x0
474
475###############################################################################
476## @brief Diagnostic test index to use for the very last test.
477ZES_DIAG_LAST_TEST_INDEX = 0xFFFFFFFF
478
479###############################################################################
480## @brief Diagnostic test
481class zes_diag_test_t(Structure):
482    _fields_ = [
483        ("index", c_ulong),                                             ## [out] Index of the test
484        ("name", c_char * ZES_STRING_PROPERTY_SIZE)                     ## [out] Name of the test
485    ]
486
487###############################################################################
488## @brief Diagnostics test suite properties
489class zes_diag_properties_t(Structure):
490    _fields_ = [
491        ("stype", zes_structure_type_t),                                ## [in] type of this structure
492        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
493        ("onSubdevice", ze_bool_t),                                     ## [out] True if the resource is located on a sub-device; false means
494                                                                        ## that the resource is on the device of the calling Sysman handle
495        ("subdeviceId", c_ulong),                                       ## [out] If onSubdevice is true, this gives the ID of the sub-device
496        ("name", c_char * ZES_STRING_PROPERTY_SIZE),                    ## [out] Name of the diagnostics test suite
497        ("haveTests", ze_bool_t)                                        ## [out] Indicates if this test suite has individual tests which can be
498                                                                        ## run separately (use the function ::zesDiagnosticsGetTests() to get the
499                                                                        ## list of these tests)
500    ]
501
502###############################################################################
503## @brief Accelerator engine groups
504class zes_engine_group_v(IntEnum):
505    ALL = 0                                         ## Access information about all engines combined.
506    COMPUTE_ALL = 1                                 ## Access information about all compute engines combined. Compute engines
507                                                    ## can only process compute kernels (no 3D content).
508    MEDIA_ALL = 2                                   ## Access information about all media engines combined.
509    COPY_ALL = 3                                    ## Access information about all copy (blitter) engines combined.
510    COMPUTE_SINGLE = 4                              ## Access information about a single compute engine - this is an engine
511                                                    ## that can process compute kernels. Note that single engines may share
512                                                    ## the same underlying accelerator resources as other engines so activity
513                                                    ## of such an engine may not be indicative of the underlying resource
514                                                    ## utilization - use ::ZES_ENGINE_GROUP_3D_RENDER_COMPUTE_ALL for that.
515    RENDER_SINGLE = 5                               ## Access information about a single render engine - this is an engine
516                                                    ## that can process both 3D content and compute kernels. Note that single
517                                                    ## engines may share the same underlying accelerator resources as other
518                                                    ## engines so activity of such an engine may not be indicative of the
519                                                    ## underlying resource utilization - use
520                                                    ## ::ZES_ENGINE_GROUP_3D_RENDER_COMPUTE_ALL for that.
521    MEDIA_DECODE_SINGLE = 6                         ## Access information about a single media decode engine. Note that
522                                                    ## single engines may share the same underlying accelerator resources as
523                                                    ## other engines so activity of such an engine may not be indicative of
524                                                    ## the underlying resource utilization - use ::ZES_ENGINE_GROUP_MEDIA_ALL
525                                                    ## for that.
526    MEDIA_ENCODE_SINGLE = 7                         ## Access information about a single media encode engine. Note that
527                                                    ## single engines may share the same underlying accelerator resources as
528                                                    ## other engines so activity of such an engine may not be indicative of
529                                                    ## the underlying resource utilization - use ::ZES_ENGINE_GROUP_MEDIA_ALL
530                                                    ## for that.
531    COPY_SINGLE = 8                                 ## Access information about a single media encode engine. Note that
532                                                    ## single engines may share the same underlying accelerator resources as
533                                                    ## other engines so activity of such an engine may not be indicative of
534                                                    ## the underlying resource utilization - use ::ZES_ENGINE_GROUP_COPY_ALL
535                                                    ## for that.
536    MEDIA_ENHANCEMENT_SINGLE = 9                    ## Access information about a single media enhancement engine. Note that
537                                                    ## single engines may share the same underlying accelerator resources as
538                                                    ## other engines so activity of such an engine may not be indicative of
539                                                    ## the underlying resource utilization - use ::ZES_ENGINE_GROUP_MEDIA_ALL
540                                                    ## for that.
541    _3D_SINGLE = 10                                 ## Access information about a single 3D engine - this is an engine that
542                                                    ## can process 3D content only. Note that single engines may share the
543                                                    ## same underlying accelerator resources as other engines so activity of
544                                                    ## such an engine may not be indicative of the underlying resource
545                                                    ## utilization - use ::ZES_ENGINE_GROUP_3D_RENDER_COMPUTE_ALL for that.
546    _3D_RENDER_COMPUTE_ALL = 11                     ## Access information about all 3D/render/compute engines combined.
547    RENDER_ALL = 12                                 ## Access information about all render engines combined. Render engines
548                                                    ## are those than process both 3D content and compute kernels.
549    _3D_ALL = 13                                    ## Access information about all 3D engines combined. 3D engines can
550                                                    ## process 3D content only (no compute kernels).
551
552class zes_engine_group_t(c_int):
553    def __str__(self):
554        return str(zes_engine_group_v(self.value))
555
556
557###############################################################################
558## @brief Engine group properties
559class zes_engine_properties_t(Structure):
560    _fields_ = [
561        ("stype", zes_structure_type_t),                                ## [in] type of this structure
562        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
563        ("type", zes_engine_group_t),                                   ## [out] The engine group
564        ("onSubdevice", ze_bool_t),                                     ## [out] True if this resource is located on a sub-device; false means
565                                                                        ## that the resource is on the device of the calling Sysman handle
566        ("subdeviceId", c_ulong)                                        ## [out] If onSubdevice is true, this gives the ID of the sub-device
567    ]
568
569###############################################################################
570## @brief Engine activity counters
571##
572## @details
573##     - Percent utilization is calculated by taking two snapshots (s1, s2) and
574##       using the equation: %util = (s2.activeTime - s1.activeTime) /
575##       (s2.timestamp - s1.timestamp)
576class zes_engine_stats_t(Structure):
577    _fields_ = [
578        ("activeTime", c_ulonglong),                                    ## [out] Monotonic counter for time in microseconds that this resource is
579                                                                        ## actively running workloads.
580        ("timestamp", c_ulonglong)                                      ## [out] Monotonic timestamp counter in microseconds when activeTime
581                                                                        ## counter was sampled.
582                                                                        ## This timestamp should only be used to calculate delta time between
583                                                                        ## snapshots of this structure.
584                                                                        ## Never take the delta of this timestamp with the timestamp from a
585                                                                        ## different structure since they are not guaranteed to have the same base.
586                                                                        ## The absolute value of the timestamp is only valid during within the
587                                                                        ## application and may be different on the next execution.
588    ]
589
590###############################################################################
591## @brief Event types
592class zes_event_type_flags_v(IntEnum):
593    DEVICE_DETACH = ZE_BIT(0)                       ## Event is triggered when the device is no longer available (due to a
594                                                    ## reset or being disabled).
595    DEVICE_ATTACH = ZE_BIT(1)                       ## Event is triggered after the device is available again.
596    DEVICE_SLEEP_STATE_ENTER = ZE_BIT(2)            ## Event is triggered when the driver is about to put the device into a
597                                                    ## deep sleep state
598    DEVICE_SLEEP_STATE_EXIT = ZE_BIT(3)             ## Event is triggered when the driver is waking the device up from a deep
599                                                    ## sleep state
600    FREQ_THROTTLED = ZE_BIT(4)                      ## Event is triggered when the frequency starts being throttled
601    ENERGY_THRESHOLD_CROSSED = ZE_BIT(5)            ## Event is triggered when the energy consumption threshold is reached
602                                                    ## (use ::zesPowerSetEnergyThreshold() to configure).
603    TEMP_CRITICAL = ZE_BIT(6)                       ## Event is triggered when the critical temperature is reached (use
604                                                    ## ::zesTemperatureSetConfig() to configure - disabled by default).
605    TEMP_THRESHOLD1 = ZE_BIT(7)                     ## Event is triggered when the temperature crosses threshold 1 (use
606                                                    ## ::zesTemperatureSetConfig() to configure - disabled by default).
607    TEMP_THRESHOLD2 = ZE_BIT(8)                     ## Event is triggered when the temperature crosses threshold 2 (use
608                                                    ## ::zesTemperatureSetConfig() to configure - disabled by default).
609    MEM_HEALTH = ZE_BIT(9)                          ## Event is triggered when the health of device memory changes.
610    FABRIC_PORT_HEALTH = ZE_BIT(10)                 ## Event is triggered when the health of fabric ports change.
611    PCI_LINK_HEALTH = ZE_BIT(11)                    ## Event is triggered when the health of the PCI link changes.
612    RAS_CORRECTABLE_ERRORS = ZE_BIT(12)             ## Event is triggered when accelerator RAS correctable errors cross
613                                                    ## thresholds (use ::zesRasSetConfig() to configure - disabled by
614                                                    ## default).
615    RAS_UNCORRECTABLE_ERRORS = ZE_BIT(13)           ## Event is triggered when accelerator RAS uncorrectable errors cross
616                                                    ## thresholds (use ::zesRasSetConfig() to configure - disabled by
617                                                    ## default).
618    DEVICE_RESET_REQUIRED = ZE_BIT(14)              ## Event is triggered when the device needs to be reset (use
619                                                    ## ::zesDeviceGetState() to determine the reasons for the reset).
620
621class zes_event_type_flags_t(c_int):
622    def __str__(self):
623        return hex(self.value)
624
625
626###############################################################################
627## @brief Maximum Fabric port model string size
628ZES_MAX_FABRIC_PORT_MODEL_SIZE = 256
629
630###############################################################################
631## @brief Maximum size of the buffer that will return information about link
632##        types
633ZES_MAX_FABRIC_LINK_TYPE_SIZE = 256
634
635###############################################################################
636## @brief Fabric port status
637class zes_fabric_port_status_v(IntEnum):
638    UNKNOWN = 0                                     ## The port status cannot be determined
639    HEALTHY = 1                                     ## The port is up and operating as expected
640    DEGRADED = 2                                    ## The port is up but has quality and/or speed degradation
641    FAILED = 3                                      ## Port connection instabilities are preventing workloads making forward
642                                                    ## progress
643    DISABLED = 4                                    ## The port is configured down
644
645class zes_fabric_port_status_t(c_int):
646    def __str__(self):
647        return str(zes_fabric_port_status_v(self.value))
648
649
650###############################################################################
651## @brief Fabric port quality degradation reasons
652class zes_fabric_port_qual_issue_flags_v(IntEnum):
653    LINK_ERRORS = ZE_BIT(0)                         ## Excessive link errors are occurring
654    SPEED = ZE_BIT(1)                               ## There is a degradation in the bitrate and/or width of the link
655
656class zes_fabric_port_qual_issue_flags_t(c_int):
657    def __str__(self):
658        return hex(self.value)
659
660
661###############################################################################
662## @brief Fabric port failure reasons
663class zes_fabric_port_failure_flags_v(IntEnum):
664    FAILED = ZE_BIT(0)                              ## A previously operating link has failed. Hardware will automatically
665                                                    ## retrain this port. This state will persist until either the physical
666                                                    ## connection is removed or the link trains successfully.
667    TRAINING_TIMEOUT = ZE_BIT(1)                    ## A connection has not been established within an expected time.
668                                                    ## Hardware will continue to attempt port training. This status will
669                                                    ## persist until either the physical connection is removed or the link
670                                                    ## successfully trains.
671    FLAPPING = ZE_BIT(2)                            ## Port has excessively trained and then transitioned down for some
672                                                    ## period of time. Driver will allow port to continue to train, but will
673                                                    ## not enable the port for use until the port has been disabled and
674                                                    ## subsequently re-enabled using ::zesFabricPortSetConfig().
675
676class zes_fabric_port_failure_flags_t(c_int):
677    def __str__(self):
678        return hex(self.value)
679
680
681###############################################################################
682## @brief Unique identifier for a fabric port
683##
684## @details
685##     - This not a universal identifier. The identified is garanteed to be
686##       unique for the current hardware configuration of the system. Changes
687##       in the hardware may result in a different identifier for a given port.
688##     - The main purpose of this identifier to build up an instantaneous
689##       topology map of system connectivity. An application should enumerate
690##       all fabric ports and match ::zes_fabric_port_state_t.remotePortId to
691##       ::zes_fabric_port_properties_t.portId.
692class zes_fabric_port_id_t(Structure):
693    _fields_ = [
694        ("fabricId", c_ulong),                                          ## [out] Unique identifier for the fabric end-point
695        ("attachId", c_ulong),                                          ## [out] Unique identifier for the device attachment point
696        ("portNumber", c_ubyte)                                         ## [out] The logical port number (this is typically marked somewhere on
697                                                                        ## the physical device)
698    ]
699
700###############################################################################
701## @brief Fabric port speed in one direction
702class zes_fabric_port_speed_t(Structure):
703    _fields_ = [
704        ("bitRate", c_int64_t),                                         ## [out] Bits/sec that the link is operating at. A value of -1 means that
705                                                                        ## this property is unknown.
706        ("width", c_int32_t)                                            ## [out] The number of lanes. A value of -1 means that this property is
707                                                                        ## unknown.
708    ]
709
710###############################################################################
711## @brief Fabric port properties
712class zes_fabric_port_properties_t(Structure):
713    _fields_ = [
714        ("stype", zes_structure_type_t),                                ## [in] type of this structure
715        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
716        ("model", c_char * ZES_MAX_FABRIC_PORT_MODEL_SIZE),             ## [out] Description of port technology. Will be set to the string
717                                                                        ## "unkown" if this cannot be determined for this port.
718        ("onSubdevice", ze_bool_t),                                     ## [out] True if the port is located on a sub-device; false means that
719                                                                        ## the port is on the device of the calling Sysman handle
720        ("subdeviceId", c_ulong),                                       ## [out] If onSubdevice is true, this gives the ID of the sub-device
721        ("portId", zes_fabric_port_id_t),                               ## [out] The unique port identifier
722        ("maxRxSpeed", zes_fabric_port_speed_t),                        ## [out] Maximum speed supported by the receive side of the port (sum of
723                                                                        ## all lanes)
724        ("maxTxSpeed", zes_fabric_port_speed_t)                         ## [out] Maximum speed supported by the transmit side of the port (sum of
725                                                                        ## all lanes)
726    ]
727
728###############################################################################
729## @brief Provides information about the fabric link attached to a port
730class zes_fabric_link_type_t(Structure):
731    _fields_ = [
732        ("desc", c_char * ZES_MAX_FABRIC_LINK_TYPE_SIZE)                ## [out] This provides a static textural description of the physic
733                                                                        ## attachment type. Will be set to the string "unkown" if this cannot be
734                                                                        ## determined for this port.
735    ]
736
737###############################################################################
738## @brief Fabric port configuration
739class zes_fabric_port_config_t(Structure):
740    _fields_ = [
741        ("stype", zes_structure_type_t),                                ## [in] type of this structure
742        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
743        ("enabled", ze_bool_t),                                         ## [in,out] Port is configured up/down
744        ("beaconing", ze_bool_t)                                        ## [in,out] Beaconing is configured on/off
745    ]
746
747###############################################################################
748## @brief Fabric port state
749class zes_fabric_port_state_t(Structure):
750    _fields_ = [
751        ("stype", zes_structure_type_t),                                ## [in] type of this structure
752        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
753        ("status", zes_fabric_port_status_t),                           ## [out] The current status of the port
754        ("qualityIssues", zes_fabric_port_qual_issue_flags_t),          ## [out] If status is ::ZES_FABRIC_PORT_STATUS_DEGRADED,
755                                                                        ## then this gives a combination of ::zes_fabric_port_qual_issue_flag_t
756                                                                        ## for quality issues that have been detected;
757                                                                        ## otherwise, 0 indicates there are no quality issues with the link at
758                                                                        ## this time.
759        ("failureReasons", zes_fabric_port_failure_flags_t),            ## [out] If status is ::ZES_FABRIC_PORT_STATUS_FAILED,
760                                                                        ## then this gives a combination of ::zes_fabric_port_failure_flag_t for
761                                                                        ## reasons for the connection instability;
762                                                                        ## otherwise, 0 indicates there are no connection stability issues at
763                                                                        ## this time.
764        ("remotePortId", zes_fabric_port_id_t),                         ## [out] The unique port identifier for the remote connection point if
765                                                                        ## status is ::ZES_FABRIC_PORT_STATUS_HEALTHY,
766                                                                        ## ::ZES_FABRIC_PORT_STATUS_DEGRADED or ::ZES_FABRIC_PORT_STATUS_FAILED
767        ("rxSpeed", zes_fabric_port_speed_t),                           ## [out] Current maximum receive speed (sum of all lanes)
768        ("txSpeed", zes_fabric_port_speed_t)                            ## [out] Current maximum transmit speed (sum of all lanes)
769    ]
770
771###############################################################################
772## @brief Fabric port throughput.
773class zes_fabric_port_throughput_t(Structure):
774    _fields_ = [
775        ("timestamp", c_ulonglong),                                     ## [out] Monotonic timestamp counter in microseconds when the measurement
776                                                                        ## was made.
777                                                                        ## This timestamp should only be used to calculate delta time between
778                                                                        ## snapshots of this structure.
779                                                                        ## Never take the delta of this timestamp with the timestamp from a
780                                                                        ## different structure since they are not guaranteed to have the same base.
781                                                                        ## The absolute value of the timestamp is only valid during within the
782                                                                        ## application and may be different on the next execution.
783        ("rxCounter", c_ulonglong),                                     ## [out] Monotonic counter for the number of bytes received (sum of all
784                                                                        ## lanes). This includes all protocol overhead, not only the GPU traffic.
785        ("txCounter", c_ulonglong)                                      ## [out] Monotonic counter for the number of bytes transmitted (sum of
786                                                                        ## all lanes). This includes all protocol overhead, not only the GPU
787                                                                        ## traffic.
788    ]
789
790###############################################################################
791## @brief Fan resource speed mode
792class zes_fan_speed_mode_v(IntEnum):
793    DEFAULT = 0                                     ## The fan speed is operating using the hardware default settings
794    FIXED = 1                                       ## The fan speed is currently set to a fixed value
795    TABLE = 2                                       ## The fan speed is currently controlled dynamically by hardware based on
796                                                    ## a temp/speed table
797
798class zes_fan_speed_mode_t(c_int):
799    def __str__(self):
800        return str(zes_fan_speed_mode_v(self.value))
801
802
803###############################################################################
804## @brief Fan speed units
805class zes_fan_speed_units_v(IntEnum):
806    RPM = 0                                         ## The fan speed is in units of revolutions per minute (rpm)
807    PERCENT = 1                                     ## The fan speed is a percentage of the maximum speed of the fan
808
809class zes_fan_speed_units_t(c_int):
810    def __str__(self):
811        return str(zes_fan_speed_units_v(self.value))
812
813
814###############################################################################
815## @brief Fan speed
816class zes_fan_speed_t(Structure):
817    _fields_ = [
818        ("speed", c_int32_t),                                           ## [in,out] The speed of the fan. On output, a value of -1 indicates that
819                                                                        ## there is no fixed fan speed setting.
820        ("units", zes_fan_speed_units_t)                                ## [in,out] The units that the fan speed is expressed in. On output, if
821                                                                        ## fan speed is -1 then units should be ignored.
822    ]
823
824###############################################################################
825## @brief Fan temperature/speed pair
826class zes_fan_temp_speed_t(Structure):
827    _fields_ = [
828        ("temperature", c_ulong),                                       ## [in,out] Temperature in degrees Celsius.
829        ("speed", zes_fan_speed_t)                                      ## [in,out] The speed of the fan
830    ]
831
832###############################################################################
833## @brief Maximum number of fan temperature/speed pairs in the fan speed table.
834ZES_FAN_TEMP_SPEED_PAIR_COUNT = 32
835
836###############################################################################
837## @brief Fan speed table
838class zes_fan_speed_table_t(Structure):
839    _fields_ = [
840        ("numPoints", c_int32_t),                                       ## [in,out] The number of valid points in the fan speed table. 0 means
841                                                                        ## that there is no fan speed table configured. -1 means that a fan speed
842                                                                        ## table is not supported by the hardware.
843        ("table", zes_fan_temp_speed_t * ZES_FAN_TEMP_SPEED_PAIR_COUNT) ## [in,out] Array of temperature/fan speed pairs. The table is ordered
844                                                                        ## based on temperature from lowest to highest.
845    ]
846
847###############################################################################
848## @brief Fan properties
849class zes_fan_properties_t(Structure):
850    _fields_ = [
851        ("stype", zes_structure_type_t),                                ## [in] type of this structure
852        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
853        ("onSubdevice", ze_bool_t),                                     ## [out] True if the resource is located on a sub-device; false means
854                                                                        ## that the resource is on the device of the calling Sysman handle
855        ("subdeviceId", c_ulong),                                       ## [out] If onSubdevice is true, this gives the ID of the sub-device
856        ("canControl", ze_bool_t),                                      ## [out] Indicates if software can control the fan speed assuming the
857                                                                        ## user has permissions
858        ("supportedModes", c_ulong),                                    ## [out] Bitfield of supported fan configuration modes
859                                                                        ## (1<<::zes_fan_speed_mode_t)
860        ("supportedUnits", c_ulong),                                    ## [out] Bitfield of supported fan speed units
861                                                                        ## (1<<::zes_fan_speed_units_t)
862        ("maxRPM", c_int32_t),                                          ## [out] The maximum RPM of the fan. A value of -1 means that this
863                                                                        ## property is unknown.
864        ("maxPoints", c_int32_t)                                        ## [out] The maximum number of points in the fan temp/speed table. A
865                                                                        ## value of -1 means that this fan doesn't support providing a temp/speed
866                                                                        ## table.
867    ]
868
869###############################################################################
870## @brief Fan configuration
871class zes_fan_config_t(Structure):
872    _fields_ = [
873        ("stype", zes_structure_type_t),                                ## [in] type of this structure
874        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
875        ("mode", zes_fan_speed_mode_t),                                 ## [in,out] The fan speed mode (fixed, temp-speed table)
876        ("speedFixed", zes_fan_speed_t),                                ## [in,out] The current fixed fan speed setting
877        ("speedTable", zes_fan_speed_table_t)                           ## [out] A table containing temperature/speed pairs
878    ]
879
880###############################################################################
881## @brief Firmware properties
882class zes_firmware_properties_t(Structure):
883    _fields_ = [
884        ("stype", zes_structure_type_t),                                ## [in] type of this structure
885        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
886        ("onSubdevice", ze_bool_t),                                     ## [out] True if the resource is located on a sub-device; false means
887                                                                        ## that the resource is on the device of the calling Sysman handle
888        ("subdeviceId", c_ulong),                                       ## [out] If onSubdevice is true, this gives the ID of the sub-device
889        ("canControl", ze_bool_t),                                      ## [out] Indicates if software can flash the firmware assuming the user
890                                                                        ## has permissions
891        ("name", c_char * ZES_STRING_PROPERTY_SIZE),                    ## [out] NULL terminated string value. The string "unknown" will be
892                                                                        ## returned if this property cannot be determined.
893        ("version", c_char * ZES_STRING_PROPERTY_SIZE)                  ## [out] NULL terminated string value. The string "unknown" will be
894                                                                        ## returned if this property cannot be determined.
895    ]
896
897###############################################################################
898## @brief Frequency domains.
899class zes_freq_domain_v(IntEnum):
900    GPU = 0                                         ## GPU Core Domain.
901    MEMORY = 1                                      ## Local Memory Domain.
902
903class zes_freq_domain_t(c_int):
904    def __str__(self):
905        return str(zes_freq_domain_v(self.value))
906
907
908###############################################################################
909## @brief Frequency properties
910##
911## @details
912##     - Indicates if this frequency domain can be overclocked (if true,
913##       functions such as ::zesFrequencyOcSetFrequencyTarget() are supported).
914##     - The min/max hardware frequencies are specified for non-overclock
915##       configurations. For overclock configurations, use
916##       ::zesFrequencyOcGetFrequencyTarget() to determine the maximum
917##       frequency that can be requested.
918class zes_freq_properties_t(Structure):
919    _fields_ = [
920        ("stype", zes_structure_type_t),                                ## [in] type of this structure
921        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
922        ("type", zes_freq_domain_t),                                    ## [out] The hardware block that this frequency domain controls (GPU,
923                                                                        ## memory, ...)
924        ("onSubdevice", ze_bool_t),                                     ## [out] True if this resource is located on a sub-device; false means
925                                                                        ## that the resource is on the device of the calling Sysman handle
926        ("subdeviceId", c_ulong),                                       ## [out] If onSubdevice is true, this gives the ID of the sub-device
927        ("canControl", ze_bool_t),                                      ## [out] Indicates if software can control the frequency of this domain
928                                                                        ## assuming the user has permissions
929        ("isThrottleEventSupported", ze_bool_t),                        ## [out] Indicates if software can register to receive event
930                                                                        ## ::ZES_EVENT_TYPE_FLAG_FREQ_THROTTLED
931        ("min", c_double),                                              ## [out] The minimum hardware clock frequency in units of MHz.
932        ("max", c_double)                                               ## [out] The maximum non-overclock hardware clock frequency in units of
933                                                                        ## MHz.
934    ]
935
936###############################################################################
937## @brief Frequency range between which the hardware can operate. The limits can
938##        be above or below the hardware limits - the hardware will clamp
939##        appropriately.
940class zes_freq_range_t(Structure):
941    _fields_ = [
942        ("min", c_double),                                              ## [in,out] The min frequency in MHz below which hardware frequency
943                                                                        ## management will not request frequencies. On input, setting to 0 will
944                                                                        ## permit the frequency to go down to the hardware minimum. On output, a
945                                                                        ## negative value indicates that no external minimum frequency limit is
946                                                                        ## in effect.
947        ("max", c_double)                                               ## [in,out] The max frequency in MHz above which hardware frequency
948                                                                        ## management will not request frequencies. On input, setting to 0 or a
949                                                                        ## very big number will permit the frequency to go all the way up to the
950                                                                        ## hardware maximum. On output, a negative number indicates that no
951                                                                        ## external maximum frequency limit is in effect.
952    ]
953
954###############################################################################
955## @brief Frequency throttle reasons
956class zes_freq_throttle_reason_flags_v(IntEnum):
957    AVE_PWR_CAP = ZE_BIT(0)                         ## frequency throttled due to average power excursion (PL1)
958    BURST_PWR_CAP = ZE_BIT(1)                       ## frequency throttled due to burst power excursion (PL2)
959    CURRENT_LIMIT = ZE_BIT(2)                       ## frequency throttled due to current excursion (PL4)
960    THERMAL_LIMIT = ZE_BIT(3)                       ## frequency throttled due to thermal excursion (T > TjMax)
961    PSU_ALERT = ZE_BIT(4)                           ## frequency throttled due to power supply assertion
962    SW_RANGE = ZE_BIT(5)                            ## frequency throttled due to software supplied frequency range
963    HW_RANGE = ZE_BIT(6)                            ## frequency throttled due to a sub block that has a lower frequency
964                                                    ## range when it receives clocks
965
966class zes_freq_throttle_reason_flags_t(c_int):
967    def __str__(self):
968        return hex(self.value)
969
970
971###############################################################################
972## @brief Frequency state
973class zes_freq_state_t(Structure):
974    _fields_ = [
975        ("stype", zes_structure_type_t),                                ## [in] type of this structure
976        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
977        ("currentVoltage", c_double),                                   ## [out] Current voltage in Volts. A negative value indicates that this
978                                                                        ## property is not known.
979        ("request", c_double),                                          ## [out] The current frequency request in MHz. A negative value indicates
980                                                                        ## that this property is not known.
981        ("tdp", c_double),                                              ## [out] The maximum frequency in MHz supported under the current TDP
982                                                                        ## conditions. This fluctuates dynamically based on the power and thermal
983                                                                        ## limits of the part. A negative value indicates that this property is
984                                                                        ## not known.
985        ("efficient", c_double),                                        ## [out] The efficient minimum frequency in MHz. A negative value
986                                                                        ## indicates that this property is not known.
987        ("actual", c_double),                                           ## [out] The resolved frequency in MHz. A negative value indicates that
988                                                                        ## this property is not known.
989        ("throttleReasons", zes_freq_throttle_reason_flags_t)           ## [out] The reasons that the frequency is being limited by the hardware.
990                                                                        ## Returns 0 (frequency not throttled) or a combination of ::zes_freq_throttle_reason_flag_t.
991    ]
992
993###############################################################################
994## @brief Frequency throttle time snapshot
995##
996## @details
997##     - Percent time throttled is calculated by taking two snapshots (s1, s2)
998##       and using the equation: %throttled = (s2.throttleTime -
999##       s1.throttleTime) / (s2.timestamp - s1.timestamp)
1000class zes_freq_throttle_time_t(Structure):
1001    _fields_ = [
1002        ("throttleTime", c_ulonglong),                                  ## [out] The monotonic counter of time in microseconds that the frequency
1003                                                                        ## has been limited by the hardware.
1004        ("timestamp", c_ulonglong)                                      ## [out] Microsecond timestamp when throttleTime was captured.
1005                                                                        ## This timestamp should only be used to calculate delta time between
1006                                                                        ## snapshots of this structure.
1007                                                                        ## Never take the delta of this timestamp with the timestamp from a
1008                                                                        ## different structure since they are not guaranteed to have the same base.
1009                                                                        ## The absolute value of the timestamp is only valid during within the
1010                                                                        ## application and may be different on the next execution.
1011    ]
1012
1013###############################################################################
1014## @brief Overclocking modes
1015class zes_oc_mode_v(IntEnum):
1016    OFF = 0                                         ## Overclocking if off - hardware is running using factory default
1017                                                    ## voltages/frequencies.
1018    OVERRIDE = 1                                    ## Overclock override mode - In this mode, a fixed user-supplied voltage
1019                                                    ## is applied independent of the frequency request. The maximum permitted
1020                                                    ## frequency can also be increased. This mode disables INTERPOLATIVE and
1021                                                    ## FIXED modes.
1022    INTERPOLATIVE = 2                               ## Overclock interpolative mode - In this mode, the voltage/frequency
1023                                                    ## curve can be extended with a new voltage/frequency point that will be
1024                                                    ## interpolated. The existing voltage/frequency points can also be offset
1025                                                    ## (up or down) by a fixed voltage. This mode disables FIXED and OVERRIDE
1026                                                    ## modes.
1027    FIXED = 3                                       ## Overclocking fixed Mode - In this mode, hardware will disable most
1028                                                    ## frequency throttling and lock the frequency and voltage at the
1029                                                    ## specified overclock values. This mode disables OVERRIDE and
1030                                                    ## INTERPOLATIVE modes. This mode can damage the part, most of the
1031                                                    ## protections are disabled on this mode.
1032
1033class zes_oc_mode_t(c_int):
1034    def __str__(self):
1035        return str(zes_oc_mode_v(self.value))
1036
1037
1038###############################################################################
1039## @brief Overclocking properties
1040##
1041## @details
1042##     - Provides all the overclocking capabilities and properties supported by
1043##       the device for the frequency domain.
1044class zes_oc_capabilities_t(Structure):
1045    _fields_ = [
1046        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1047        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
1048        ("isOcSupported", ze_bool_t),                                   ## [out] Indicates if any overclocking features are supported on this
1049                                                                        ## frequency domain.
1050        ("maxFactoryDefaultFrequency", c_double),                       ## [out] Factory default non-overclock maximum frequency in Mhz.
1051        ("maxFactoryDefaultVoltage", c_double),                         ## [out] Factory default voltage used for the non-overclock maximum
1052                                                                        ## frequency in MHz.
1053        ("maxOcFrequency", c_double),                                   ## [out] Maximum hardware overclocking frequency limit in Mhz.
1054        ("minOcVoltageOffset", c_double),                               ## [out] The minimum voltage offset that can be applied to the
1055                                                                        ## voltage/frequency curve. Note that this number can be negative.
1056        ("maxOcVoltageOffset", c_double),                               ## [out] The maximum voltage offset that can be applied to the
1057                                                                        ## voltage/frequency curve.
1058        ("maxOcVoltage", c_double),                                     ## [out] The maximum overclock voltage that hardware supports.
1059        ("isTjMaxSupported", ze_bool_t),                                ## [out] Indicates if the maximum temperature limit (TjMax) can be
1060                                                                        ## changed for this frequency domain.
1061        ("isIccMaxSupported", ze_bool_t),                               ## [out] Indicates if the maximum current (IccMax) can be changed for
1062                                                                        ## this frequency domain.
1063        ("isHighVoltModeCapable", ze_bool_t),                           ## [out] Indicates if this frequency domains supports a feature to set
1064                                                                        ## very high voltages.
1065        ("isHighVoltModeEnabled", ze_bool_t),                           ## [out] Indicates if very high voltages are permitted on this frequency
1066                                                                        ## domain.
1067        ("isExtendedModeSupported", ze_bool_t),                         ## [out] Indicates if the extended overclocking features are supported.
1068                                                                        ## If this is supported, increments are on 1 Mhz basis.
1069        ("isFixedModeSupported", ze_bool_t)                             ## [out] Indicates if the fixed mode is supported. In this mode, hardware
1070                                                                        ## will disable most frequency throttling and lock the frequency and
1071                                                                        ## voltage at the specified overclock values.
1072    ]
1073
1074###############################################################################
1075## @brief LED properties
1076class zes_led_properties_t(Structure):
1077    _fields_ = [
1078        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1079        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
1080        ("onSubdevice", ze_bool_t),                                     ## [out] True if the resource is located on a sub-device; false means
1081                                                                        ## that the resource is on the device of the calling Sysman handle
1082        ("subdeviceId", c_ulong),                                       ## [out] If onSubdevice is true, this gives the ID of the sub-device
1083        ("canControl", ze_bool_t),                                      ## [out] Indicates if software can control the LED assuming the user has
1084                                                                        ## permissions
1085        ("haveRGB", ze_bool_t)                                          ## [out] Indicates if the LED is RGB capable
1086    ]
1087
1088###############################################################################
1089## @brief LED color
1090class zes_led_color_t(Structure):
1091    _fields_ = [
1092        ("red", c_double),                                              ## [in,out][range(0.0, 1.0)] The LED red value. On output, a value less
1093                                                                        ## than 0.0 indicates that the color is not known.
1094        ("green", c_double),                                            ## [in,out][range(0.0, 1.0)] The LED green value. On output, a value less
1095                                                                        ## than 0.0 indicates that the color is not known.
1096        ("blue", c_double)                                              ## [in,out][range(0.0, 1.0)] The LED blue value. On output, a value less
1097                                                                        ## than 0.0 indicates that the color is not known.
1098    ]
1099
1100###############################################################################
1101## @brief LED state
1102class zes_led_state_t(Structure):
1103    _fields_ = [
1104        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1105        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
1106        ("isOn", ze_bool_t),                                            ## [out] Indicates if the LED is on or off
1107        ("color", zes_led_color_t)                                      ## [out] Color of the LED
1108    ]
1109
1110###############################################################################
1111## @brief Memory module types
1112class zes_mem_type_v(IntEnum):
1113    HBM = 0                                         ## HBM memory
1114    DDR = 1                                         ## DDR memory
1115    DDR3 = 2                                        ## DDR3 memory
1116    DDR4 = 3                                        ## DDR4 memory
1117    DDR5 = 4                                        ## DDR5 memory
1118    LPDDR = 5                                       ## LPDDR memory
1119    LPDDR3 = 6                                      ## LPDDR3 memory
1120    LPDDR4 = 7                                      ## LPDDR4 memory
1121    LPDDR5 = 8                                      ## LPDDR5 memory
1122    SRAM = 9                                        ## SRAM memory
1123    L1 = 10                                         ## L1 cache
1124    L3 = 11                                         ## L3 cache
1125    GRF = 12                                        ## Execution unit register file
1126    SLM = 13                                        ## Execution unit shared local memory
1127    GDDR4 = 14                                      ## GDDR4 memory
1128    GDDR5 = 15                                      ## GDDR5 memory
1129    GDDR5X = 16                                     ## GDDR5X memory
1130    GDDR6 = 17                                      ## GDDR6 memory
1131    GDDR6X = 18                                     ## GDDR6X memory
1132    GDDR7 = 19                                      ## GDDR7 memory
1133
1134class zes_mem_type_t(c_int):
1135    def __str__(self):
1136        return str(zes_mem_type_v(self.value))
1137
1138
1139###############################################################################
1140## @brief Memory module location
1141class zes_mem_loc_v(IntEnum):
1142    SYSTEM = 0                                      ## System memory
1143    DEVICE = 1                                      ## On board local device memory
1144
1145class zes_mem_loc_t(c_int):
1146    def __str__(self):
1147        return str(zes_mem_loc_v(self.value))
1148
1149
1150###############################################################################
1151## @brief Memory health
1152class zes_mem_health_v(IntEnum):
1153    UNKNOWN = 0                                     ## The memory health cannot be determined.
1154    OK = 1                                          ## All memory channels are healthy.
1155    DEGRADED = 2                                    ## Excessive correctable errors have been detected on one or more
1156                                                    ## channels. Device should be reset.
1157    CRITICAL = 3                                    ## Operating with reduced memory to cover banks with too many
1158                                                    ## uncorrectable errors.
1159    REPLACE = 4                                     ## Device should be replaced due to excessive uncorrectable errors.
1160
1161class zes_mem_health_t(c_int):
1162    def __str__(self):
1163        return str(zes_mem_health_v(self.value))
1164
1165
1166###############################################################################
1167## @brief Memory properties
1168class zes_mem_properties_t(Structure):
1169    _fields_ = [
1170        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1171        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
1172        ("type", zes_mem_type_t),                                       ## [out] The memory type
1173        ("onSubdevice", ze_bool_t),                                     ## [out] True if this resource is located on a sub-device; false means
1174                                                                        ## that the resource is on the device of the calling Sysman handle
1175        ("subdeviceId", c_ulong),                                       ## [out] If onSubdevice is true, this gives the ID of the sub-device
1176        ("location", zes_mem_loc_t),                                    ## [out] Location of this memory (system, device)
1177        ("physicalSize", c_ulonglong),                                  ## [out] Physical memory size in bytes. A value of 0 indicates that this
1178                                                                        ## property is not known. However, a call to ::zesMemoryGetState() will
1179                                                                        ## correctly return the total size of usable memory.
1180        ("busWidth", c_int32_t),                                        ## [out] Width of the memory bus. A value of -1 means that this property
1181                                                                        ## is unknown.
1182        ("numChannels", c_int32_t)                                      ## [out] The number of memory channels. A value of -1 means that this
1183                                                                        ## property is unknown.
1184    ]
1185
1186###############################################################################
1187## @brief Memory state - health, allocated
1188##
1189## @details
1190##     - Percent allocation is given by 100 * (size - free / size.
1191##     - Percent free is given by 100 * free / size.
1192class zes_mem_state_t(Structure):
1193    _fields_ = [
1194        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1195        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
1196        ("health", zes_mem_health_t),                                   ## [out] Indicates the health of the memory
1197        ("free", c_ulonglong),                                          ## [out] The free memory in bytes
1198        ("size", c_ulonglong)                                           ## [out] The total allocatable memory in bytes (can be less than
1199                                                                        ## ::zes_mem_properties_t.physicalSize)
1200    ]
1201
1202###############################################################################
1203## @brief Memory bandwidth
1204##
1205## @details
1206##     - Percent bandwidth is calculated by taking two snapshots (s1, s2) and
1207##       using the equation: %bw = 10^6 * ((s2.readCounter - s1.readCounter) +
1208##       (s2.writeCounter - s1.writeCounter)) / (s2.maxBandwidth *
1209##       (s2.timestamp - s1.timestamp))
1210class zes_mem_bandwidth_t(Structure):
1211    _fields_ = [
1212        ("readCounter", c_ulonglong),                                   ## [out] Total bytes read from memory
1213        ("writeCounter", c_ulonglong),                                  ## [out] Total bytes written to memory
1214        ("maxBandwidth", c_ulonglong),                                  ## [out] Current maximum bandwidth in units of bytes/sec
1215        ("timestamp", c_ulonglong)                                      ## [out] The timestamp when these measurements were sampled.
1216                                                                        ## This timestamp should only be used to calculate delta time between
1217                                                                        ## snapshots of this structure.
1218                                                                        ## Never take the delta of this timestamp with the timestamp from a
1219                                                                        ## different structure since they are not guaranteed to have the same base.
1220                                                                        ## The absolute value of the timestamp is only valid during within the
1221                                                                        ## application and may be different on the next execution.
1222    ]
1223
1224###############################################################################
1225## @brief Static information about a Performance Factor domain
1226class zes_perf_properties_t(Structure):
1227    _fields_ = [
1228        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1229        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
1230        ("onSubdevice", ze_bool_t),                                     ## [out] True if this Performance Factor affects accelerators located on
1231                                                                        ## a sub-device
1232        ("subdeviceId", c_ulong),                                       ## [out] If onSubdevice is true, this gives the ID of the sub-device
1233        ("engines", zes_engine_type_flags_t)                            ## [out] Bitfield of accelerator engine types that are affected by this
1234                                                                        ## Performance Factor.
1235    ]
1236
1237###############################################################################
1238## @brief Properties related to device power settings
1239class zes_power_properties_t(Structure):
1240    _fields_ = [
1241        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1242        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
1243        ("onSubdevice", ze_bool_t),                                     ## [out] True if this resource is located on a sub-device; false means
1244                                                                        ## that the resource is on the device of the calling Sysman handle
1245        ("subdeviceId", c_ulong),                                       ## [out] If onSubdevice is true, this gives the ID of the sub-device
1246        ("canControl", ze_bool_t),                                      ## [out] Software can change the power limits of this domain assuming the
1247                                                                        ## user has permissions.
1248        ("isEnergyThresholdSupported", ze_bool_t),                      ## [out] Indicates if this power domain supports the energy threshold
1249                                                                        ## event (::ZES_EVENT_TYPE_FLAG_ENERGY_THRESHOLD_CROSSED).
1250        ("defaultLimit", c_int32_t),                                    ## [out] The factory default TDP power limit of the part in milliwatts. A
1251                                                                        ## value of -1 means that this is not known.
1252        ("minLimit", c_int32_t),                                        ## [out] The minimum power limit in milliwatts that can be requested.
1253        ("maxLimit", c_int32_t)                                         ## [out] The maximum power limit in milliwatts that can be requested.
1254    ]
1255
1256###############################################################################
1257## @brief Energy counter snapshot
1258##
1259## @details
1260##     - Average power is calculated by taking two snapshots (s1, s2) and using
1261##       the equation: PowerWatts = (s2.energy - s1.energy) / (s2.timestamp -
1262##       s1.timestamp)
1263class zes_power_energy_counter_t(Structure):
1264    _fields_ = [
1265        ("energy", c_ulonglong),                                        ## [out] The monotonic energy counter in microjoules.
1266        ("timestamp", c_ulonglong)                                      ## [out] Microsecond timestamp when energy was captured.
1267                                                                        ## This timestamp should only be used to calculate delta time between
1268                                                                        ## snapshots of this structure.
1269                                                                        ## Never take the delta of this timestamp with the timestamp from a
1270                                                                        ## different structure since they are not guaranteed to have the same base.
1271                                                                        ## The absolute value of the timestamp is only valid during within the
1272                                                                        ## application and may be different on the next execution.
1273    ]
1274
1275###############################################################################
1276## @brief Sustained power limits
1277##
1278## @details
1279##     - The power controller (Punit) will throttle the operating frequency if
1280##       the power averaged over a window (typically seconds) exceeds this
1281##       limit.
1282class zes_power_sustained_limit_t(Structure):
1283    _fields_ = [
1284        ("enabled", ze_bool_t),                                         ## [in,out] indicates if the limit is enabled (true) or ignored (false)
1285        ("power", c_int32_t),                                           ## [in,out] power limit in milliwatts
1286        ("interval", c_int32_t)                                         ## [in,out] power averaging window (Tau) in milliseconds
1287    ]
1288
1289###############################################################################
1290## @brief Burst power limit
1291##
1292## @details
1293##     - The power controller (Punit) will throttle the operating frequency of
1294##       the device if the power averaged over a few milliseconds exceeds a
1295##       limit known as PL2. Typically PL2 > PL1 so that it permits the
1296##       frequency to burst higher for short periods than would be otherwise
1297##       permitted by PL1.
1298class zes_power_burst_limit_t(Structure):
1299    _fields_ = [
1300        ("enabled", ze_bool_t),                                         ## [in,out] indicates if the limit is enabled (true) or ignored (false)
1301        ("power", c_int32_t)                                            ## [in,out] power limit in milliwatts
1302    ]
1303
1304###############################################################################
1305## @brief Peak power limit
1306##
1307## @details
1308##     - The power controller (Punit) will reactively/proactively throttle the
1309##       operating frequency of the device when the instantaneous/100usec power
1310##       exceeds this limit. The limit is known as PL4 or Psys. It expresses
1311##       the maximum power that can be drawn from the power supply.
1312##     - If this power limit is removed or set too high, the power supply will
1313##       generate an interrupt when it detects an overcurrent condition and the
1314##       power controller will throttle the device frequencies down to min. It
1315##       is thus better to tune the PL4 value in order to avoid such
1316##       excursions.
1317class zes_power_peak_limit_t(Structure):
1318    _fields_ = [
1319        ("powerAC", c_int32_t),                                         ## [in,out] power limit in milliwatts for the AC power source.
1320        ("powerDC", c_int32_t)                                          ## [in,out] power limit in milliwatts for the DC power source. On input,
1321                                                                        ## this is ignored if the product does not have a battery. On output,
1322                                                                        ## this will be -1 if the product does not have a battery.
1323    ]
1324
1325###############################################################################
1326## @brief Energy threshold
1327##
1328## @details
1329##     - .
1330class zes_energy_threshold_t(Structure):
1331    _fields_ = [
1332        ("enable", ze_bool_t),                                          ## [in,out] Indicates if the energy threshold is enabled.
1333        ("threshold", c_double),                                        ## [in,out] The energy threshold in Joules. Will be 0.0 if no threshold
1334                                                                        ## has been set.
1335        ("processId", c_ulong)                                          ## [in,out] The host process ID that set the energy threshold. Will be
1336                                                                        ## 0xFFFFFFFF if no threshold has been set.
1337    ]
1338
1339###############################################################################
1340## @brief PSU voltage status
1341class zes_psu_voltage_status_v(IntEnum):
1342    UNKNOWN = 0                                     ## The status of the power supply voltage controllers cannot be
1343                                                    ## determined
1344    NORMAL = 1                                      ## No unusual voltages have been detected
1345    OVER = 2                                        ## Over-voltage has occurred
1346    UNDER = 3                                       ## Under-voltage has occurred
1347
1348class zes_psu_voltage_status_t(c_int):
1349    def __str__(self):
1350        return str(zes_psu_voltage_status_v(self.value))
1351
1352
1353###############################################################################
1354## @brief Static properties of the power supply
1355class zes_psu_properties_t(Structure):
1356    _fields_ = [
1357        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1358        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
1359        ("onSubdevice", ze_bool_t),                                     ## [out] True if the resource is located on a sub-device; false means
1360                                                                        ## that the resource is on the device of the calling Sysman handle
1361        ("subdeviceId", c_ulong),                                       ## [out] If onSubdevice is true, this gives the ID of the sub-device
1362        ("haveFan", ze_bool_t),                                         ## [out] True if the power supply has a fan
1363        ("ampLimit", c_int32_t)                                         ## [out] The maximum electrical current in milliamperes that can be
1364                                                                        ## drawn. A value of -1 indicates that this property cannot be
1365                                                                        ## determined.
1366    ]
1367
1368###############################################################################
1369## @brief Dynamic state of the power supply
1370class zes_psu_state_t(Structure):
1371    _fields_ = [
1372        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1373        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
1374        ("voltStatus", zes_psu_voltage_status_t),                       ## [out] The current PSU voltage status
1375        ("fanFailed", ze_bool_t),                                       ## [out] Indicates if the fan has failed
1376        ("temperature", c_int32_t),                                     ## [out] Read the current heatsink temperature in degrees Celsius. A
1377                                                                        ## value of -1 indicates that this property cannot be determined.
1378        ("current", c_int32_t)                                          ## [out] The amps being drawn in milliamperes. A value of -1 indicates
1379                                                                        ## that this property cannot be determined.
1380    ]
1381
1382###############################################################################
1383## @brief RAS error type
1384class zes_ras_error_type_v(IntEnum):
1385    CORRECTABLE = 0                                 ## Errors were corrected by hardware
1386    UNCORRECTABLE = 1                               ## Error were not corrected
1387
1388class zes_ras_error_type_t(c_int):
1389    def __str__(self):
1390        return str(zes_ras_error_type_v(self.value))
1391
1392
1393###############################################################################
1394## @brief RAS error categories
1395class zes_ras_error_cat_v(IntEnum):
1396    RESET = 0                                       ## The number of accelerator engine resets attempted by the driver
1397    PROGRAMMING_ERRORS = 1                          ## The number of hardware exceptions generated by the way workloads have
1398                                                    ## programmed the hardware
1399    DRIVER_ERRORS = 2                               ## The number of low level driver communication errors have occurred
1400    COMPUTE_ERRORS = 3                              ## The number of errors that have occurred in the compute accelerator
1401                                                    ## hardware
1402    NON_COMPUTE_ERRORS = 4                          ## The number of errors that have occurred in the fixed-function
1403                                                    ## accelerator hardware
1404    CACHE_ERRORS = 5                                ## The number of errors that have occurred in caches (L1/L3/register
1405                                                    ## file/shared local memory/sampler)
1406    DISPLAY_ERRORS = 6                              ## The number of errors that have occurred in the display
1407
1408class zes_ras_error_cat_t(c_int):
1409    def __str__(self):
1410        return str(zes_ras_error_cat_v(self.value))
1411
1412
1413###############################################################################
1414## @brief The maximum number of categories
1415ZES_MAX_RAS_ERROR_CATEGORY_COUNT = 7
1416
1417###############################################################################
1418## @brief RAS properties
1419class zes_ras_properties_t(Structure):
1420    _fields_ = [
1421        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1422        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
1423        ("type", zes_ras_error_type_t),                                 ## [out] The type of RAS error
1424        ("onSubdevice", ze_bool_t),                                     ## [out] True if the resource is located on a sub-device; false means
1425                                                                        ## that the resource is on the device of the calling Sysman handle
1426        ("subdeviceId", c_ulong)                                        ## [out] If onSubdevice is true, this gives the ID of the sub-device
1427    ]
1428
1429###############################################################################
1430## @brief RAS error details
1431class zes_ras_state_t(Structure):
1432    _fields_ = [
1433        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1434        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
1435        ("category", c_ulonglong * ZES_MAX_RAS_ERROR_CATEGORY_COUNT)    ## [in][out] Breakdown of error by category
1436    ]
1437
1438###############################################################################
1439## @brief RAS error configuration - thresholds used for triggering RAS events
1440##        (::ZES_EVENT_TYPE_FLAG_RAS_CORRECTABLE_ERRORS,
1441##        ::ZES_EVENT_TYPE_FLAG_RAS_UNCORRECTABLE_ERRORS)
1442##
1443## @details
1444##     - The driver maintains a total counter which is updated every time a
1445##       hardware block covered by the corresponding RAS error set notifies
1446##       that an error has occurred. When this total count goes above the
1447##       totalThreshold specified below, a RAS event is triggered.
1448##     - The driver also maintains a counter for each category of RAS error
1449##       (see ::zes_ras_state_t for a breakdown). Each time a hardware block of
1450##       that category notifies that an error has occurred, that corresponding
1451##       category counter is updated. When it goes above the threshold
1452##       specified in detailedThresholds, a RAS event is triggered.
1453class zes_ras_config_t(Structure):
1454    _fields_ = [
1455        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1456        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
1457        ("totalThreshold", c_ulonglong),                                ## [in,out] If the total RAS errors exceeds this threshold, the event
1458                                                                        ## will be triggered. A value of 0ULL disables triggering the event based
1459                                                                        ## on the total counter.
1460        ("detailedThresholds", zes_ras_state_t)                         ## [in,out] If the RAS errors for each category exceed the threshold for
1461                                                                        ## that category, the event will be triggered. A value of 0ULL will
1462                                                                        ## disable an event being triggered for that category.
1463    ]
1464
1465###############################################################################
1466## @brief Scheduler mode
1467class zes_sched_mode_v(IntEnum):
1468    TIMEOUT = 0                                     ## Multiple applications or contexts are submitting work to the hardware.
1469                                                    ## When higher priority work arrives, the scheduler attempts to pause the
1470                                                    ## current executing work within some timeout interval, then submits the
1471                                                    ## other work.
1472    TIMESLICE = 1                                   ## The scheduler attempts to fairly timeslice hardware execution time
1473                                                    ## between multiple contexts submitting work to the hardware
1474                                                    ## concurrently.
1475    EXCLUSIVE = 2                                   ## Any application or context can run indefinitely on the hardware
1476                                                    ## without being preempted or terminated. All pending work for other
1477                                                    ## contexts must wait until the running context completes with no further
1478                                                    ## submitted work.
1479    COMPUTE_UNIT_DEBUG = 3                          ## This is a special mode that must ben enabled when debugging an
1480                                                    ## application that uses this device e.g. using the Level0 Debug API. It
1481                                                    ## has the effect of disabling any timeouts on workload execution time
1482                                                    ## and will change workload scheduling to ensure debug accuracy.
1483
1484class zes_sched_mode_t(c_int):
1485    def __str__(self):
1486        return str(zes_sched_mode_v(self.value))
1487
1488
1489###############################################################################
1490## @brief Properties related to scheduler component
1491class zes_sched_properties_t(Structure):
1492    _fields_ = [
1493        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1494        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
1495        ("onSubdevice", ze_bool_t),                                     ## [out] True if this resource is located on a sub-device; false means
1496                                                                        ## that the resource is on the device of the calling Sysman handle
1497        ("subdeviceId", c_ulong),                                       ## [out] If onSubdevice is true, this gives the ID of the sub-device
1498        ("canControl", ze_bool_t),                                      ## [out] Software can change the scheduler component configuration
1499                                                                        ## assuming the user has permissions.
1500        ("engines", zes_engine_type_flags_t),                           ## [out] Bitfield of accelerator engine types that are managed by this
1501                                                                        ## scheduler component. Note that there can be more than one scheduler
1502                                                                        ## component for the same type of accelerator engine.
1503        ("supportedModes", c_ulong)                                     ## [out] Bitfield of scheduler modes that can be configured for this
1504                                                                        ## scheduler component (bitfield of 1<<::zes_sched_mode_t).
1505    ]
1506
1507###############################################################################
1508## @brief Disable forward progress guard timeout.
1509ZES_SCHED_WATCHDOG_DISABLE = (~(0ULL))
1510
1511###############################################################################
1512## @brief Configuration for timeout scheduler mode (::ZES_SCHED_MODE_TIMEOUT)
1513class zes_sched_timeout_properties_t(Structure):
1514    _fields_ = [
1515        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1516        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
1517        ("watchdogTimeout", c_ulonglong)                                ## [in,out] The maximum time in microseconds that the scheduler will wait
1518                                                                        ## for a batch of work submitted to a hardware engine to complete or to
1519                                                                        ## be preempted so as to run another context.
1520                                                                        ## If this time is exceeded, the hardware engine is reset and the context terminated.
1521                                                                        ## If set to ::ZES_SCHED_WATCHDOG_DISABLE, a running workload can run as
1522                                                                        ## long as it wants without being terminated, but preemption attempts to
1523                                                                        ## run other contexts are permitted but not enforced.
1524    ]
1525
1526###############################################################################
1527## @brief Configuration for timeslice scheduler mode
1528##        (::ZES_SCHED_MODE_TIMESLICE)
1529class zes_sched_timeslice_properties_t(Structure):
1530    _fields_ = [
1531        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1532        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
1533        ("interval", c_ulonglong),                                      ## [in,out] The average interval in microseconds that a submission for a
1534                                                                        ## context will run on a hardware engine before being preempted out to
1535                                                                        ## run a pending submission for another context.
1536        ("yieldTimeout", c_ulonglong)                                   ## [in,out] The maximum time in microseconds that the scheduler will wait
1537                                                                        ## to preempt a workload running on an engine before deciding to reset
1538                                                                        ## the hardware engine and terminating the associated context.
1539    ]
1540
1541###############################################################################
1542## @brief Standby hardware components
1543class zes_standby_type_v(IntEnum):
1544    GLOBAL = 0                                      ## Control the overall standby policy of the device/sub-device
1545
1546class zes_standby_type_t(c_int):
1547    def __str__(self):
1548        return str(zes_standby_type_v(self.value))
1549
1550
1551###############################################################################
1552## @brief Standby hardware component properties
1553class zes_standby_properties_t(Structure):
1554    _fields_ = [
1555        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1556        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
1557        ("type", zes_standby_type_t),                                   ## [out] Which standby hardware component this controls
1558        ("onSubdevice", ze_bool_t),                                     ## [out] True if the resource is located on a sub-device; false means
1559                                                                        ## that the resource is on the device of the calling Sysman handle
1560        ("subdeviceId", c_ulong)                                        ## [out] If onSubdevice is true, this gives the ID of the sub-device
1561    ]
1562
1563###############################################################################
1564## @brief Standby promotion modes
1565class zes_standby_promo_mode_v(IntEnum):
1566    DEFAULT = 0                                     ## Best compromise between performance and energy savings.
1567    NEVER = 1                                       ## The device/component will never shutdown. This can improve performance
1568                                                    ## but uses more energy.
1569
1570class zes_standby_promo_mode_t(c_int):
1571    def __str__(self):
1572        return str(zes_standby_promo_mode_v(self.value))
1573
1574
1575###############################################################################
1576## @brief Temperature sensors
1577class zes_temp_sensors_v(IntEnum):
1578    GLOBAL = 0                                      ## The maximum temperature across all device sensors
1579    GPU = 1                                         ## The maximum temperature across all sensors in the GPU
1580    MEMORY = 2                                      ## The maximum temperature across all sensors in the local memory
1581    GLOBAL_MIN = 3                                  ## The minimum temperature across all device sensors
1582    GPU_MIN = 4                                     ## The minimum temperature across all sensors in the GPU
1583    MEMORY_MIN = 5                                  ## The minimum temperature across all sensors in the local device memory
1584
1585class zes_temp_sensors_t(c_int):
1586    def __str__(self):
1587        return str(zes_temp_sensors_v(self.value))
1588
1589
1590###############################################################################
1591## @brief Temperature sensor properties
1592class zes_temp_properties_t(Structure):
1593    _fields_ = [
1594        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1595        ("pNext", c_void_p),                                            ## [in,out][optional] pointer to extension-specific structure
1596        ("type", zes_temp_sensors_t),                                   ## [out] Which part of the device the temperature sensor measures
1597        ("onSubdevice", ze_bool_t),                                     ## [out] True if the resource is located on a sub-device; false means
1598                                                                        ## that the resource is on the device of the calling Sysman handle
1599        ("subdeviceId", c_ulong),                                       ## [out] If onSubdevice is true, this gives the ID of the sub-device
1600        ("maxTemperature", c_double),                                   ## [out] Will contain the maximum temperature for the specific device in
1601                                                                        ## degrees Celsius.
1602        ("isCriticalTempSupported", ze_bool_t),                         ## [out] Indicates if the critical temperature event
1603                                                                        ## ::ZES_EVENT_TYPE_FLAG_TEMP_CRITICAL is supported
1604        ("isThreshold1Supported", ze_bool_t),                           ## [out] Indicates if the temperature threshold 1 event
1605                                                                        ## ::ZES_EVENT_TYPE_FLAG_TEMP_THRESHOLD1 is supported
1606        ("isThreshold2Supported", ze_bool_t)                            ## [out] Indicates if the temperature threshold 2 event
1607                                                                        ## ::ZES_EVENT_TYPE_FLAG_TEMP_THRESHOLD2 is supported
1608    ]
1609
1610###############################################################################
1611## @brief Temperature sensor threshold
1612class zes_temp_threshold_t(Structure):
1613    _fields_ = [
1614        ("enableLowToHigh", ze_bool_t),                                 ## [in,out] Trigger an event when the temperature crosses from below the
1615                                                                        ## threshold to above.
1616        ("enableHighToLow", ze_bool_t),                                 ## [in,out] Trigger an event when the temperature crosses from above the
1617                                                                        ## threshold to below.
1618        ("threshold", c_double)                                         ## [in,out] The threshold in degrees Celsius.
1619    ]
1620
1621###############################################################################
1622## @brief Temperature configuration - which events should be triggered and the
1623##        trigger conditions.
1624class zes_temp_config_t(Structure):
1625    _fields_ = [
1626        ("stype", zes_structure_type_t),                                ## [in] type of this structure
1627        ("pNext", c_void_p),                                            ## [in][optional] pointer to extension-specific structure
1628        ("enableCritical", ze_bool_t),                                  ## [in,out] Indicates if event ::ZES_EVENT_TYPE_FLAG_TEMP_CRITICAL should
1629                                                                        ## be triggered by the driver.
1630        ("threshold1", zes_temp_threshold_t),                           ## [in,out] Configuration controlling if and when event
1631                                                                        ## ::ZES_EVENT_TYPE_FLAG_TEMP_THRESHOLD1 should be triggered by the
1632                                                                        ## driver.
1633        ("threshold2", zes_temp_threshold_t)                            ## [in,out] Configuration controlling if and when event
1634                                                                        ## ::ZES_EVENT_TYPE_FLAG_TEMP_THRESHOLD2 should be triggered by the
1635                                                                        ## driver.
1636    ]
1637
1638###############################################################################
1639__use_win_types = "Windows" == platform.uname()[0]
1640
1641###############################################################################
1642## @brief Function-pointer for zesDriverEventListen
1643if __use_win_types:
1644    _zesDriverEventListen_t = WINFUNCTYPE( ze_result_t, ze_driver_handle_t, c_ulong, c_ulong, POINTER(zes_device_handle_t), POINTER(c_ulong), POINTER(zes_event_type_flags_t) )
1645else:
1646    _zesDriverEventListen_t = CFUNCTYPE( ze_result_t, ze_driver_handle_t, c_ulong, c_ulong, POINTER(zes_device_handle_t), POINTER(c_ulong), POINTER(zes_event_type_flags_t) )
1647
1648###############################################################################
1649## @brief Function-pointer for zesDriverEventListenEx
1650if __use_win_types:
1651    _zesDriverEventListenEx_t = WINFUNCTYPE( ze_result_t, ze_driver_handle_t, c_ulonglong, c_ulong, POINTER(zes_device_handle_t), POINTER(c_ulong), POINTER(zes_event_type_flags_t) )
1652else:
1653    _zesDriverEventListenEx_t = CFUNCTYPE( ze_result_t, ze_driver_handle_t, c_ulonglong, c_ulong, POINTER(zes_device_handle_t), POINTER(c_ulong), POINTER(zes_event_type_flags_t) )
1654
1655
1656###############################################################################
1657## @brief Table of Driver functions pointers
1658class _zes_driver_dditable_t(Structure):
1659    _fields_ = [
1660        ("pfnEventListen", c_void_p),                                   ## _zesDriverEventListen_t
1661        ("pfnEventListenEx", c_void_p)                                  ## _zesDriverEventListenEx_t
1662    ]
1663
1664###############################################################################
1665## @brief Function-pointer for zesDeviceGetProperties
1666if __use_win_types:
1667    _zesDeviceGetProperties_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(zes_device_properties_t) )
1668else:
1669    _zesDeviceGetProperties_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(zes_device_properties_t) )
1670
1671###############################################################################
1672## @brief Function-pointer for zesDeviceGetState
1673if __use_win_types:
1674    _zesDeviceGetState_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(zes_device_state_t) )
1675else:
1676    _zesDeviceGetState_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(zes_device_state_t) )
1677
1678###############################################################################
1679## @brief Function-pointer for zesDeviceReset
1680if __use_win_types:
1681    _zesDeviceReset_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, ze_bool_t )
1682else:
1683    _zesDeviceReset_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, ze_bool_t )
1684
1685###############################################################################
1686## @brief Function-pointer for zesDeviceProcessesGetState
1687if __use_win_types:
1688    _zesDeviceProcessesGetState_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_process_state_t) )
1689else:
1690    _zesDeviceProcessesGetState_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_process_state_t) )
1691
1692###############################################################################
1693## @brief Function-pointer for zesDevicePciGetProperties
1694if __use_win_types:
1695    _zesDevicePciGetProperties_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(zes_pci_properties_t) )
1696else:
1697    _zesDevicePciGetProperties_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(zes_pci_properties_t) )
1698
1699###############################################################################
1700## @brief Function-pointer for zesDevicePciGetState
1701if __use_win_types:
1702    _zesDevicePciGetState_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(zes_pci_state_t) )
1703else:
1704    _zesDevicePciGetState_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(zes_pci_state_t) )
1705
1706###############################################################################
1707## @brief Function-pointer for zesDevicePciGetBars
1708if __use_win_types:
1709    _zesDevicePciGetBars_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_pci_bar_properties_t) )
1710else:
1711    _zesDevicePciGetBars_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_pci_bar_properties_t) )
1712
1713###############################################################################
1714## @brief Function-pointer for zesDevicePciGetStats
1715if __use_win_types:
1716    _zesDevicePciGetStats_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(zes_pci_stats_t) )
1717else:
1718    _zesDevicePciGetStats_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(zes_pci_stats_t) )
1719
1720###############################################################################
1721## @brief Function-pointer for zesDeviceEnumDiagnosticTestSuites
1722if __use_win_types:
1723    _zesDeviceEnumDiagnosticTestSuites_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_diag_handle_t) )
1724else:
1725    _zesDeviceEnumDiagnosticTestSuites_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_diag_handle_t) )
1726
1727###############################################################################
1728## @brief Function-pointer for zesDeviceEnumEngineGroups
1729if __use_win_types:
1730    _zesDeviceEnumEngineGroups_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_engine_handle_t) )
1731else:
1732    _zesDeviceEnumEngineGroups_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_engine_handle_t) )
1733
1734###############################################################################
1735## @brief Function-pointer for zesDeviceEventRegister
1736if __use_win_types:
1737    _zesDeviceEventRegister_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, zes_event_type_flags_t )
1738else:
1739    _zesDeviceEventRegister_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, zes_event_type_flags_t )
1740
1741###############################################################################
1742## @brief Function-pointer for zesDeviceEnumFabricPorts
1743if __use_win_types:
1744    _zesDeviceEnumFabricPorts_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_fabric_port_handle_t) )
1745else:
1746    _zesDeviceEnumFabricPorts_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_fabric_port_handle_t) )
1747
1748###############################################################################
1749## @brief Function-pointer for zesDeviceEnumFans
1750if __use_win_types:
1751    _zesDeviceEnumFans_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_fan_handle_t) )
1752else:
1753    _zesDeviceEnumFans_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_fan_handle_t) )
1754
1755###############################################################################
1756## @brief Function-pointer for zesDeviceEnumFirmwares
1757if __use_win_types:
1758    _zesDeviceEnumFirmwares_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_firmware_handle_t) )
1759else:
1760    _zesDeviceEnumFirmwares_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_firmware_handle_t) )
1761
1762###############################################################################
1763## @brief Function-pointer for zesDeviceEnumFrequencyDomains
1764if __use_win_types:
1765    _zesDeviceEnumFrequencyDomains_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_freq_handle_t) )
1766else:
1767    _zesDeviceEnumFrequencyDomains_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_freq_handle_t) )
1768
1769###############################################################################
1770## @brief Function-pointer for zesDeviceEnumLeds
1771if __use_win_types:
1772    _zesDeviceEnumLeds_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_led_handle_t) )
1773else:
1774    _zesDeviceEnumLeds_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_led_handle_t) )
1775
1776###############################################################################
1777## @brief Function-pointer for zesDeviceEnumMemoryModules
1778if __use_win_types:
1779    _zesDeviceEnumMemoryModules_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_mem_handle_t) )
1780else:
1781    _zesDeviceEnumMemoryModules_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_mem_handle_t) )
1782
1783###############################################################################
1784## @brief Function-pointer for zesDeviceEnumPerformanceFactorDomains
1785if __use_win_types:
1786    _zesDeviceEnumPerformanceFactorDomains_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_perf_handle_t) )
1787else:
1788    _zesDeviceEnumPerformanceFactorDomains_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_perf_handle_t) )
1789
1790###############################################################################
1791## @brief Function-pointer for zesDeviceEnumPowerDomains
1792if __use_win_types:
1793    _zesDeviceEnumPowerDomains_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_pwr_handle_t) )
1794else:
1795    _zesDeviceEnumPowerDomains_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_pwr_handle_t) )
1796
1797###############################################################################
1798## @brief Function-pointer for zesDeviceGetCardPowerDomain
1799if __use_win_types:
1800    _zesDeviceGetCardPowerDomain_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(zes_pwr_handle_t) )
1801else:
1802    _zesDeviceGetCardPowerDomain_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(zes_pwr_handle_t) )
1803
1804###############################################################################
1805## @brief Function-pointer for zesDeviceEnumPsus
1806if __use_win_types:
1807    _zesDeviceEnumPsus_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_psu_handle_t) )
1808else:
1809    _zesDeviceEnumPsus_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_psu_handle_t) )
1810
1811###############################################################################
1812## @brief Function-pointer for zesDeviceEnumRasErrorSets
1813if __use_win_types:
1814    _zesDeviceEnumRasErrorSets_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_ras_handle_t) )
1815else:
1816    _zesDeviceEnumRasErrorSets_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_ras_handle_t) )
1817
1818###############################################################################
1819## @brief Function-pointer for zesDeviceEnumSchedulers
1820if __use_win_types:
1821    _zesDeviceEnumSchedulers_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_sched_handle_t) )
1822else:
1823    _zesDeviceEnumSchedulers_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_sched_handle_t) )
1824
1825###############################################################################
1826## @brief Function-pointer for zesDeviceEnumStandbyDomains
1827if __use_win_types:
1828    _zesDeviceEnumStandbyDomains_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_standby_handle_t) )
1829else:
1830    _zesDeviceEnumStandbyDomains_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_standby_handle_t) )
1831
1832###############################################################################
1833## @brief Function-pointer for zesDeviceEnumTemperatureSensors
1834if __use_win_types:
1835    _zesDeviceEnumTemperatureSensors_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_temp_handle_t) )
1836else:
1837    _zesDeviceEnumTemperatureSensors_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_temp_handle_t) )
1838
1839
1840###############################################################################
1841## @brief Table of Device functions pointers
1842class _zes_device_dditable_t(Structure):
1843    _fields_ = [
1844        ("pfnGetProperties", c_void_p),                                 ## _zesDeviceGetProperties_t
1845        ("pfnGetState", c_void_p),                                      ## _zesDeviceGetState_t
1846        ("pfnReset", c_void_p),                                         ## _zesDeviceReset_t
1847        ("pfnProcessesGetState", c_void_p),                             ## _zesDeviceProcessesGetState_t
1848        ("pfnPciGetProperties", c_void_p),                              ## _zesDevicePciGetProperties_t
1849        ("pfnPciGetState", c_void_p),                                   ## _zesDevicePciGetState_t
1850        ("pfnPciGetBars", c_void_p),                                    ## _zesDevicePciGetBars_t
1851        ("pfnPciGetStats", c_void_p),                                   ## _zesDevicePciGetStats_t
1852        ("pfnEnumDiagnosticTestSuites", c_void_p),                      ## _zesDeviceEnumDiagnosticTestSuites_t
1853        ("pfnEnumEngineGroups", c_void_p),                              ## _zesDeviceEnumEngineGroups_t
1854        ("pfnEventRegister", c_void_p),                                 ## _zesDeviceEventRegister_t
1855        ("pfnEnumFabricPorts", c_void_p),                               ## _zesDeviceEnumFabricPorts_t
1856        ("pfnEnumFans", c_void_p),                                      ## _zesDeviceEnumFans_t
1857        ("pfnEnumFirmwares", c_void_p),                                 ## _zesDeviceEnumFirmwares_t
1858        ("pfnEnumFrequencyDomains", c_void_p),                          ## _zesDeviceEnumFrequencyDomains_t
1859        ("pfnEnumLeds", c_void_p),                                      ## _zesDeviceEnumLeds_t
1860        ("pfnEnumMemoryModules", c_void_p),                             ## _zesDeviceEnumMemoryModules_t
1861        ("pfnEnumPerformanceFactorDomains", c_void_p),                  ## _zesDeviceEnumPerformanceFactorDomains_t
1862        ("pfnEnumPowerDomains", c_void_p),                              ## _zesDeviceEnumPowerDomains_t
1863        ("pfnGetCardPowerDomain", c_void_p),                            ## _zesDeviceGetCardPowerDomain_t
1864        ("pfnEnumPsus", c_void_p),                                      ## _zesDeviceEnumPsus_t
1865        ("pfnEnumRasErrorSets", c_void_p),                              ## _zesDeviceEnumRasErrorSets_t
1866        ("pfnEnumSchedulers", c_void_p),                                ## _zesDeviceEnumSchedulers_t
1867        ("pfnEnumStandbyDomains", c_void_p),                            ## _zesDeviceEnumStandbyDomains_t
1868        ("pfnEnumTemperatureSensors", c_void_p)                         ## _zesDeviceEnumTemperatureSensors_t
1869    ]
1870
1871###############################################################################
1872## @brief Function-pointer for zesSchedulerGetProperties
1873if __use_win_types:
1874    _zesSchedulerGetProperties_t = WINFUNCTYPE( ze_result_t, zes_sched_handle_t, POINTER(zes_sched_properties_t) )
1875else:
1876    _zesSchedulerGetProperties_t = CFUNCTYPE( ze_result_t, zes_sched_handle_t, POINTER(zes_sched_properties_t) )
1877
1878###############################################################################
1879## @brief Function-pointer for zesSchedulerGetCurrentMode
1880if __use_win_types:
1881    _zesSchedulerGetCurrentMode_t = WINFUNCTYPE( ze_result_t, zes_sched_handle_t, POINTER(zes_sched_mode_t) )
1882else:
1883    _zesSchedulerGetCurrentMode_t = CFUNCTYPE( ze_result_t, zes_sched_handle_t, POINTER(zes_sched_mode_t) )
1884
1885###############################################################################
1886## @brief Function-pointer for zesSchedulerGetTimeoutModeProperties
1887if __use_win_types:
1888    _zesSchedulerGetTimeoutModeProperties_t = WINFUNCTYPE( ze_result_t, zes_sched_handle_t, ze_bool_t, POINTER(zes_sched_timeout_properties_t) )
1889else:
1890    _zesSchedulerGetTimeoutModeProperties_t = CFUNCTYPE( ze_result_t, zes_sched_handle_t, ze_bool_t, POINTER(zes_sched_timeout_properties_t) )
1891
1892###############################################################################
1893## @brief Function-pointer for zesSchedulerGetTimesliceModeProperties
1894if __use_win_types:
1895    _zesSchedulerGetTimesliceModeProperties_t = WINFUNCTYPE( ze_result_t, zes_sched_handle_t, ze_bool_t, POINTER(zes_sched_timeslice_properties_t) )
1896else:
1897    _zesSchedulerGetTimesliceModeProperties_t = CFUNCTYPE( ze_result_t, zes_sched_handle_t, ze_bool_t, POINTER(zes_sched_timeslice_properties_t) )
1898
1899###############################################################################
1900## @brief Function-pointer for zesSchedulerSetTimeoutMode
1901if __use_win_types:
1902    _zesSchedulerSetTimeoutMode_t = WINFUNCTYPE( ze_result_t, zes_sched_handle_t, POINTER(zes_sched_timeout_properties_t), POINTER(ze_bool_t) )
1903else:
1904    _zesSchedulerSetTimeoutMode_t = CFUNCTYPE( ze_result_t, zes_sched_handle_t, POINTER(zes_sched_timeout_properties_t), POINTER(ze_bool_t) )
1905
1906###############################################################################
1907## @brief Function-pointer for zesSchedulerSetTimesliceMode
1908if __use_win_types:
1909    _zesSchedulerSetTimesliceMode_t = WINFUNCTYPE( ze_result_t, zes_sched_handle_t, POINTER(zes_sched_timeslice_properties_t), POINTER(ze_bool_t) )
1910else:
1911    _zesSchedulerSetTimesliceMode_t = CFUNCTYPE( ze_result_t, zes_sched_handle_t, POINTER(zes_sched_timeslice_properties_t), POINTER(ze_bool_t) )
1912
1913###############################################################################
1914## @brief Function-pointer for zesSchedulerSetExclusiveMode
1915if __use_win_types:
1916    _zesSchedulerSetExclusiveMode_t = WINFUNCTYPE( ze_result_t, zes_sched_handle_t, POINTER(ze_bool_t) )
1917else:
1918    _zesSchedulerSetExclusiveMode_t = CFUNCTYPE( ze_result_t, zes_sched_handle_t, POINTER(ze_bool_t) )
1919
1920###############################################################################
1921## @brief Function-pointer for zesSchedulerSetComputeUnitDebugMode
1922if __use_win_types:
1923    _zesSchedulerSetComputeUnitDebugMode_t = WINFUNCTYPE( ze_result_t, zes_sched_handle_t, POINTER(ze_bool_t) )
1924else:
1925    _zesSchedulerSetComputeUnitDebugMode_t = CFUNCTYPE( ze_result_t, zes_sched_handle_t, POINTER(ze_bool_t) )
1926
1927
1928###############################################################################
1929## @brief Table of Scheduler functions pointers
1930class _zes_scheduler_dditable_t(Structure):
1931    _fields_ = [
1932        ("pfnGetProperties", c_void_p),                                 ## _zesSchedulerGetProperties_t
1933        ("pfnGetCurrentMode", c_void_p),                                ## _zesSchedulerGetCurrentMode_t
1934        ("pfnGetTimeoutModeProperties", c_void_p),                      ## _zesSchedulerGetTimeoutModeProperties_t
1935        ("pfnGetTimesliceModeProperties", c_void_p),                    ## _zesSchedulerGetTimesliceModeProperties_t
1936        ("pfnSetTimeoutMode", c_void_p),                                ## _zesSchedulerSetTimeoutMode_t
1937        ("pfnSetTimesliceMode", c_void_p),                              ## _zesSchedulerSetTimesliceMode_t
1938        ("pfnSetExclusiveMode", c_void_p),                              ## _zesSchedulerSetExclusiveMode_t
1939        ("pfnSetComputeUnitDebugMode", c_void_p)                        ## _zesSchedulerSetComputeUnitDebugMode_t
1940    ]
1941
1942###############################################################################
1943## @brief Function-pointer for zesPerformanceFactorGetProperties
1944if __use_win_types:
1945    _zesPerformanceFactorGetProperties_t = WINFUNCTYPE( ze_result_t, zes_perf_handle_t, POINTER(zes_perf_properties_t) )
1946else:
1947    _zesPerformanceFactorGetProperties_t = CFUNCTYPE( ze_result_t, zes_perf_handle_t, POINTER(zes_perf_properties_t) )
1948
1949###############################################################################
1950## @brief Function-pointer for zesPerformanceFactorGetConfig
1951if __use_win_types:
1952    _zesPerformanceFactorGetConfig_t = WINFUNCTYPE( ze_result_t, zes_perf_handle_t, POINTER(c_double) )
1953else:
1954    _zesPerformanceFactorGetConfig_t = CFUNCTYPE( ze_result_t, zes_perf_handle_t, POINTER(c_double) )
1955
1956###############################################################################
1957## @brief Function-pointer for zesPerformanceFactorSetConfig
1958if __use_win_types:
1959    _zesPerformanceFactorSetConfig_t = WINFUNCTYPE( ze_result_t, zes_perf_handle_t, c_double )
1960else:
1961    _zesPerformanceFactorSetConfig_t = CFUNCTYPE( ze_result_t, zes_perf_handle_t, c_double )
1962
1963
1964###############################################################################
1965## @brief Table of PerformanceFactor functions pointers
1966class _zes_performance_factor_dditable_t(Structure):
1967    _fields_ = [
1968        ("pfnGetProperties", c_void_p),                                 ## _zesPerformanceFactorGetProperties_t
1969        ("pfnGetConfig", c_void_p),                                     ## _zesPerformanceFactorGetConfig_t
1970        ("pfnSetConfig", c_void_p)                                      ## _zesPerformanceFactorSetConfig_t
1971    ]
1972
1973###############################################################################
1974## @brief Function-pointer for zesPowerGetProperties
1975if __use_win_types:
1976    _zesPowerGetProperties_t = WINFUNCTYPE( ze_result_t, zes_pwr_handle_t, POINTER(zes_power_properties_t) )
1977else:
1978    _zesPowerGetProperties_t = CFUNCTYPE( ze_result_t, zes_pwr_handle_t, POINTER(zes_power_properties_t) )
1979
1980###############################################################################
1981## @brief Function-pointer for zesPowerGetEnergyCounter
1982if __use_win_types:
1983    _zesPowerGetEnergyCounter_t = WINFUNCTYPE( ze_result_t, zes_pwr_handle_t, POINTER(zes_power_energy_counter_t) )
1984else:
1985    _zesPowerGetEnergyCounter_t = CFUNCTYPE( ze_result_t, zes_pwr_handle_t, POINTER(zes_power_energy_counter_t) )
1986
1987###############################################################################
1988## @brief Function-pointer for zesPowerGetLimits
1989if __use_win_types:
1990    _zesPowerGetLimits_t = WINFUNCTYPE( ze_result_t, zes_pwr_handle_t, POINTER(zes_power_sustained_limit_t), POINTER(zes_power_burst_limit_t), POINTER(zes_power_peak_limit_t) )
1991else:
1992    _zesPowerGetLimits_t = CFUNCTYPE( ze_result_t, zes_pwr_handle_t, POINTER(zes_power_sustained_limit_t), POINTER(zes_power_burst_limit_t), POINTER(zes_power_peak_limit_t) )
1993
1994###############################################################################
1995## @brief Function-pointer for zesPowerSetLimits
1996if __use_win_types:
1997    _zesPowerSetLimits_t = WINFUNCTYPE( ze_result_t, zes_pwr_handle_t, POINTER(zes_power_sustained_limit_t), POINTER(zes_power_burst_limit_t), POINTER(zes_power_peak_limit_t) )
1998else:
1999    _zesPowerSetLimits_t = CFUNCTYPE( ze_result_t, zes_pwr_handle_t, POINTER(zes_power_sustained_limit_t), POINTER(zes_power_burst_limit_t), POINTER(zes_power_peak_limit_t) )
2000
2001###############################################################################
2002## @brief Function-pointer for zesPowerGetEnergyThreshold
2003if __use_win_types:
2004    _zesPowerGetEnergyThreshold_t = WINFUNCTYPE( ze_result_t, zes_pwr_handle_t, POINTER(zes_energy_threshold_t) )
2005else:
2006    _zesPowerGetEnergyThreshold_t = CFUNCTYPE( ze_result_t, zes_pwr_handle_t, POINTER(zes_energy_threshold_t) )
2007
2008###############################################################################
2009## @brief Function-pointer for zesPowerSetEnergyThreshold
2010if __use_win_types:
2011    _zesPowerSetEnergyThreshold_t = WINFUNCTYPE( ze_result_t, zes_pwr_handle_t, c_double )
2012else:
2013    _zesPowerSetEnergyThreshold_t = CFUNCTYPE( ze_result_t, zes_pwr_handle_t, c_double )
2014
2015
2016###############################################################################
2017## @brief Table of Power functions pointers
2018class _zes_power_dditable_t(Structure):
2019    _fields_ = [
2020        ("pfnGetProperties", c_void_p),                                 ## _zesPowerGetProperties_t
2021        ("pfnGetEnergyCounter", c_void_p),                              ## _zesPowerGetEnergyCounter_t
2022        ("pfnGetLimits", c_void_p),                                     ## _zesPowerGetLimits_t
2023        ("pfnSetLimits", c_void_p),                                     ## _zesPowerSetLimits_t
2024        ("pfnGetEnergyThreshold", c_void_p),                            ## _zesPowerGetEnergyThreshold_t
2025        ("pfnSetEnergyThreshold", c_void_p)                             ## _zesPowerSetEnergyThreshold_t
2026    ]
2027
2028###############################################################################
2029## @brief Function-pointer for zesFrequencyGetProperties
2030if __use_win_types:
2031    _zesFrequencyGetProperties_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_freq_properties_t) )
2032else:
2033    _zesFrequencyGetProperties_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_freq_properties_t) )
2034
2035###############################################################################
2036## @brief Function-pointer for zesFrequencyGetAvailableClocks
2037if __use_win_types:
2038    _zesFrequencyGetAvailableClocks_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(c_ulong), POINTER(c_double) )
2039else:
2040    _zesFrequencyGetAvailableClocks_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(c_ulong), POINTER(c_double) )
2041
2042###############################################################################
2043## @brief Function-pointer for zesFrequencyGetRange
2044if __use_win_types:
2045    _zesFrequencyGetRange_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_freq_range_t) )
2046else:
2047    _zesFrequencyGetRange_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_freq_range_t) )
2048
2049###############################################################################
2050## @brief Function-pointer for zesFrequencySetRange
2051if __use_win_types:
2052    _zesFrequencySetRange_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_freq_range_t) )
2053else:
2054    _zesFrequencySetRange_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_freq_range_t) )
2055
2056###############################################################################
2057## @brief Function-pointer for zesFrequencyGetState
2058if __use_win_types:
2059    _zesFrequencyGetState_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_freq_state_t) )
2060else:
2061    _zesFrequencyGetState_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_freq_state_t) )
2062
2063###############################################################################
2064## @brief Function-pointer for zesFrequencyGetThrottleTime
2065if __use_win_types:
2066    _zesFrequencyGetThrottleTime_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_freq_throttle_time_t) )
2067else:
2068    _zesFrequencyGetThrottleTime_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_freq_throttle_time_t) )
2069
2070###############################################################################
2071## @brief Function-pointer for zesFrequencyOcGetCapabilities
2072if __use_win_types:
2073    _zesFrequencyOcGetCapabilities_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_oc_capabilities_t) )
2074else:
2075    _zesFrequencyOcGetCapabilities_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_oc_capabilities_t) )
2076
2077###############################################################################
2078## @brief Function-pointer for zesFrequencyOcGetFrequencyTarget
2079if __use_win_types:
2080    _zesFrequencyOcGetFrequencyTarget_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(c_double) )
2081else:
2082    _zesFrequencyOcGetFrequencyTarget_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(c_double) )
2083
2084###############################################################################
2085## @brief Function-pointer for zesFrequencyOcSetFrequencyTarget
2086if __use_win_types:
2087    _zesFrequencyOcSetFrequencyTarget_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, c_double )
2088else:
2089    _zesFrequencyOcSetFrequencyTarget_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, c_double )
2090
2091###############################################################################
2092## @brief Function-pointer for zesFrequencyOcGetVoltageTarget
2093if __use_win_types:
2094    _zesFrequencyOcGetVoltageTarget_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(c_double), POINTER(c_double) )
2095else:
2096    _zesFrequencyOcGetVoltageTarget_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(c_double), POINTER(c_double) )
2097
2098###############################################################################
2099## @brief Function-pointer for zesFrequencyOcSetVoltageTarget
2100if __use_win_types:
2101    _zesFrequencyOcSetVoltageTarget_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, c_double, c_double )
2102else:
2103    _zesFrequencyOcSetVoltageTarget_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, c_double, c_double )
2104
2105###############################################################################
2106## @brief Function-pointer for zesFrequencyOcSetMode
2107if __use_win_types:
2108    _zesFrequencyOcSetMode_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, zes_oc_mode_t )
2109else:
2110    _zesFrequencyOcSetMode_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, zes_oc_mode_t )
2111
2112###############################################################################
2113## @brief Function-pointer for zesFrequencyOcGetMode
2114if __use_win_types:
2115    _zesFrequencyOcGetMode_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_oc_mode_t) )
2116else:
2117    _zesFrequencyOcGetMode_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(zes_oc_mode_t) )
2118
2119###############################################################################
2120## @brief Function-pointer for zesFrequencyOcGetIccMax
2121if __use_win_types:
2122    _zesFrequencyOcGetIccMax_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(c_double) )
2123else:
2124    _zesFrequencyOcGetIccMax_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(c_double) )
2125
2126###############################################################################
2127## @brief Function-pointer for zesFrequencyOcSetIccMax
2128if __use_win_types:
2129    _zesFrequencyOcSetIccMax_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, c_double )
2130else:
2131    _zesFrequencyOcSetIccMax_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, c_double )
2132
2133###############################################################################
2134## @brief Function-pointer for zesFrequencyOcGetTjMax
2135if __use_win_types:
2136    _zesFrequencyOcGetTjMax_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(c_double) )
2137else:
2138    _zesFrequencyOcGetTjMax_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, POINTER(c_double) )
2139
2140###############################################################################
2141## @brief Function-pointer for zesFrequencyOcSetTjMax
2142if __use_win_types:
2143    _zesFrequencyOcSetTjMax_t = WINFUNCTYPE( ze_result_t, zes_freq_handle_t, c_double )
2144else:
2145    _zesFrequencyOcSetTjMax_t = CFUNCTYPE( ze_result_t, zes_freq_handle_t, c_double )
2146
2147
2148###############################################################################
2149## @brief Table of Frequency functions pointers
2150class _zes_frequency_dditable_t(Structure):
2151    _fields_ = [
2152        ("pfnGetProperties", c_void_p),                                 ## _zesFrequencyGetProperties_t
2153        ("pfnGetAvailableClocks", c_void_p),                            ## _zesFrequencyGetAvailableClocks_t
2154        ("pfnGetRange", c_void_p),                                      ## _zesFrequencyGetRange_t
2155        ("pfnSetRange", c_void_p),                                      ## _zesFrequencySetRange_t
2156        ("pfnGetState", c_void_p),                                      ## _zesFrequencyGetState_t
2157        ("pfnGetThrottleTime", c_void_p),                               ## _zesFrequencyGetThrottleTime_t
2158        ("pfnOcGetCapabilities", c_void_p),                             ## _zesFrequencyOcGetCapabilities_t
2159        ("pfnOcGetFrequencyTarget", c_void_p),                          ## _zesFrequencyOcGetFrequencyTarget_t
2160        ("pfnOcSetFrequencyTarget", c_void_p),                          ## _zesFrequencyOcSetFrequencyTarget_t
2161        ("pfnOcGetVoltageTarget", c_void_p),                            ## _zesFrequencyOcGetVoltageTarget_t
2162        ("pfnOcSetVoltageTarget", c_void_p),                            ## _zesFrequencyOcSetVoltageTarget_t
2163        ("pfnOcSetMode", c_void_p),                                     ## _zesFrequencyOcSetMode_t
2164        ("pfnOcGetMode", c_void_p),                                     ## _zesFrequencyOcGetMode_t
2165        ("pfnOcGetIccMax", c_void_p),                                   ## _zesFrequencyOcGetIccMax_t
2166        ("pfnOcSetIccMax", c_void_p),                                   ## _zesFrequencyOcSetIccMax_t
2167        ("pfnOcGetTjMax", c_void_p),                                    ## _zesFrequencyOcGetTjMax_t
2168        ("pfnOcSetTjMax", c_void_p)                                     ## _zesFrequencyOcSetTjMax_t
2169    ]
2170
2171###############################################################################
2172## @brief Function-pointer for zesEngineGetProperties
2173if __use_win_types:
2174    _zesEngineGetProperties_t = WINFUNCTYPE( ze_result_t, zes_engine_handle_t, POINTER(zes_engine_properties_t) )
2175else:
2176    _zesEngineGetProperties_t = CFUNCTYPE( ze_result_t, zes_engine_handle_t, POINTER(zes_engine_properties_t) )
2177
2178###############################################################################
2179## @brief Function-pointer for zesEngineGetActivity
2180if __use_win_types:
2181    _zesEngineGetActivity_t = WINFUNCTYPE( ze_result_t, zes_engine_handle_t, POINTER(zes_engine_stats_t) )
2182else:
2183    _zesEngineGetActivity_t = CFUNCTYPE( ze_result_t, zes_engine_handle_t, POINTER(zes_engine_stats_t) )
2184
2185
2186###############################################################################
2187## @brief Table of Engine functions pointers
2188class _zes_engine_dditable_t(Structure):
2189    _fields_ = [
2190        ("pfnGetProperties", c_void_p),                                 ## _zesEngineGetProperties_t
2191        ("pfnGetActivity", c_void_p)                                    ## _zesEngineGetActivity_t
2192    ]
2193
2194###############################################################################
2195## @brief Function-pointer for zesStandbyGetProperties
2196if __use_win_types:
2197    _zesStandbyGetProperties_t = WINFUNCTYPE( ze_result_t, zes_standby_handle_t, POINTER(zes_standby_properties_t) )
2198else:
2199    _zesStandbyGetProperties_t = CFUNCTYPE( ze_result_t, zes_standby_handle_t, POINTER(zes_standby_properties_t) )
2200
2201###############################################################################
2202## @brief Function-pointer for zesStandbyGetMode
2203if __use_win_types:
2204    _zesStandbyGetMode_t = WINFUNCTYPE( ze_result_t, zes_standby_handle_t, POINTER(zes_standby_promo_mode_t) )
2205else:
2206    _zesStandbyGetMode_t = CFUNCTYPE( ze_result_t, zes_standby_handle_t, POINTER(zes_standby_promo_mode_t) )
2207
2208###############################################################################
2209## @brief Function-pointer for zesStandbySetMode
2210if __use_win_types:
2211    _zesStandbySetMode_t = WINFUNCTYPE( ze_result_t, zes_standby_handle_t, zes_standby_promo_mode_t )
2212else:
2213    _zesStandbySetMode_t = CFUNCTYPE( ze_result_t, zes_standby_handle_t, zes_standby_promo_mode_t )
2214
2215
2216###############################################################################
2217## @brief Table of Standby functions pointers
2218class _zes_standby_dditable_t(Structure):
2219    _fields_ = [
2220        ("pfnGetProperties", c_void_p),                                 ## _zesStandbyGetProperties_t
2221        ("pfnGetMode", c_void_p),                                       ## _zesStandbyGetMode_t
2222        ("pfnSetMode", c_void_p)                                        ## _zesStandbySetMode_t
2223    ]
2224
2225###############################################################################
2226## @brief Function-pointer for zesFirmwareGetProperties
2227if __use_win_types:
2228    _zesFirmwareGetProperties_t = WINFUNCTYPE( ze_result_t, zes_firmware_handle_t, POINTER(zes_firmware_properties_t) )
2229else:
2230    _zesFirmwareGetProperties_t = CFUNCTYPE( ze_result_t, zes_firmware_handle_t, POINTER(zes_firmware_properties_t) )
2231
2232###############################################################################
2233## @brief Function-pointer for zesFirmwareFlash
2234if __use_win_types:
2235    _zesFirmwareFlash_t = WINFUNCTYPE( ze_result_t, zes_firmware_handle_t, c_void_p, c_ulong )
2236else:
2237    _zesFirmwareFlash_t = CFUNCTYPE( ze_result_t, zes_firmware_handle_t, c_void_p, c_ulong )
2238
2239
2240###############################################################################
2241## @brief Table of Firmware functions pointers
2242class _zes_firmware_dditable_t(Structure):
2243    _fields_ = [
2244        ("pfnGetProperties", c_void_p),                                 ## _zesFirmwareGetProperties_t
2245        ("pfnFlash", c_void_p)                                          ## _zesFirmwareFlash_t
2246    ]
2247
2248###############################################################################
2249## @brief Function-pointer for zesMemoryGetProperties
2250if __use_win_types:
2251    _zesMemoryGetProperties_t = WINFUNCTYPE( ze_result_t, zes_mem_handle_t, POINTER(zes_mem_properties_t) )
2252else:
2253    _zesMemoryGetProperties_t = CFUNCTYPE( ze_result_t, zes_mem_handle_t, POINTER(zes_mem_properties_t) )
2254
2255###############################################################################
2256## @brief Function-pointer for zesMemoryGetState
2257if __use_win_types:
2258    _zesMemoryGetState_t = WINFUNCTYPE( ze_result_t, zes_mem_handle_t, POINTER(zes_mem_state_t) )
2259else:
2260    _zesMemoryGetState_t = CFUNCTYPE( ze_result_t, zes_mem_handle_t, POINTER(zes_mem_state_t) )
2261
2262###############################################################################
2263## @brief Function-pointer for zesMemoryGetBandwidth
2264if __use_win_types:
2265    _zesMemoryGetBandwidth_t = WINFUNCTYPE( ze_result_t, zes_mem_handle_t, POINTER(zes_mem_bandwidth_t) )
2266else:
2267    _zesMemoryGetBandwidth_t = CFUNCTYPE( ze_result_t, zes_mem_handle_t, POINTER(zes_mem_bandwidth_t) )
2268
2269
2270###############################################################################
2271## @brief Table of Memory functions pointers
2272class _zes_memory_dditable_t(Structure):
2273    _fields_ = [
2274        ("pfnGetProperties", c_void_p),                                 ## _zesMemoryGetProperties_t
2275        ("pfnGetState", c_void_p),                                      ## _zesMemoryGetState_t
2276        ("pfnGetBandwidth", c_void_p)                                   ## _zesMemoryGetBandwidth_t
2277    ]
2278
2279###############################################################################
2280## @brief Function-pointer for zesFabricPortGetProperties
2281if __use_win_types:
2282    _zesFabricPortGetProperties_t = WINFUNCTYPE( ze_result_t, zes_fabric_port_handle_t, POINTER(zes_fabric_port_properties_t) )
2283else:
2284    _zesFabricPortGetProperties_t = CFUNCTYPE( ze_result_t, zes_fabric_port_handle_t, POINTER(zes_fabric_port_properties_t) )
2285
2286###############################################################################
2287## @brief Function-pointer for zesFabricPortGetLinkType
2288if __use_win_types:
2289    _zesFabricPortGetLinkType_t = WINFUNCTYPE( ze_result_t, zes_fabric_port_handle_t, POINTER(zes_fabric_link_type_t) )
2290else:
2291    _zesFabricPortGetLinkType_t = CFUNCTYPE( ze_result_t, zes_fabric_port_handle_t, POINTER(zes_fabric_link_type_t) )
2292
2293###############################################################################
2294## @brief Function-pointer for zesFabricPortGetConfig
2295if __use_win_types:
2296    _zesFabricPortGetConfig_t = WINFUNCTYPE( ze_result_t, zes_fabric_port_handle_t, POINTER(zes_fabric_port_config_t) )
2297else:
2298    _zesFabricPortGetConfig_t = CFUNCTYPE( ze_result_t, zes_fabric_port_handle_t, POINTER(zes_fabric_port_config_t) )
2299
2300###############################################################################
2301## @brief Function-pointer for zesFabricPortSetConfig
2302if __use_win_types:
2303    _zesFabricPortSetConfig_t = WINFUNCTYPE( ze_result_t, zes_fabric_port_handle_t, POINTER(zes_fabric_port_config_t) )
2304else:
2305    _zesFabricPortSetConfig_t = CFUNCTYPE( ze_result_t, zes_fabric_port_handle_t, POINTER(zes_fabric_port_config_t) )
2306
2307###############################################################################
2308## @brief Function-pointer for zesFabricPortGetState
2309if __use_win_types:
2310    _zesFabricPortGetState_t = WINFUNCTYPE( ze_result_t, zes_fabric_port_handle_t, POINTER(zes_fabric_port_state_t) )
2311else:
2312    _zesFabricPortGetState_t = CFUNCTYPE( ze_result_t, zes_fabric_port_handle_t, POINTER(zes_fabric_port_state_t) )
2313
2314###############################################################################
2315## @brief Function-pointer for zesFabricPortGetThroughput
2316if __use_win_types:
2317    _zesFabricPortGetThroughput_t = WINFUNCTYPE( ze_result_t, zes_fabric_port_handle_t, POINTER(zes_fabric_port_throughput_t) )
2318else:
2319    _zesFabricPortGetThroughput_t = CFUNCTYPE( ze_result_t, zes_fabric_port_handle_t, POINTER(zes_fabric_port_throughput_t) )
2320
2321
2322###############################################################################
2323## @brief Table of FabricPort functions pointers
2324class _zes_fabric_port_dditable_t(Structure):
2325    _fields_ = [
2326        ("pfnGetProperties", c_void_p),                                 ## _zesFabricPortGetProperties_t
2327        ("pfnGetLinkType", c_void_p),                                   ## _zesFabricPortGetLinkType_t
2328        ("pfnGetConfig", c_void_p),                                     ## _zesFabricPortGetConfig_t
2329        ("pfnSetConfig", c_void_p),                                     ## _zesFabricPortSetConfig_t
2330        ("pfnGetState", c_void_p),                                      ## _zesFabricPortGetState_t
2331        ("pfnGetThroughput", c_void_p)                                  ## _zesFabricPortGetThroughput_t
2332    ]
2333
2334###############################################################################
2335## @brief Function-pointer for zesTemperatureGetProperties
2336if __use_win_types:
2337    _zesTemperatureGetProperties_t = WINFUNCTYPE( ze_result_t, zes_temp_handle_t, POINTER(zes_temp_properties_t) )
2338else:
2339    _zesTemperatureGetProperties_t = CFUNCTYPE( ze_result_t, zes_temp_handle_t, POINTER(zes_temp_properties_t) )
2340
2341###############################################################################
2342## @brief Function-pointer for zesTemperatureGetConfig
2343if __use_win_types:
2344    _zesTemperatureGetConfig_t = WINFUNCTYPE( ze_result_t, zes_temp_handle_t, POINTER(zes_temp_config_t) )
2345else:
2346    _zesTemperatureGetConfig_t = CFUNCTYPE( ze_result_t, zes_temp_handle_t, POINTER(zes_temp_config_t) )
2347
2348###############################################################################
2349## @brief Function-pointer for zesTemperatureSetConfig
2350if __use_win_types:
2351    _zesTemperatureSetConfig_t = WINFUNCTYPE( ze_result_t, zes_temp_handle_t, POINTER(zes_temp_config_t) )
2352else:
2353    _zesTemperatureSetConfig_t = CFUNCTYPE( ze_result_t, zes_temp_handle_t, POINTER(zes_temp_config_t) )
2354
2355###############################################################################
2356## @brief Function-pointer for zesTemperatureGetState
2357if __use_win_types:
2358    _zesTemperatureGetState_t = WINFUNCTYPE( ze_result_t, zes_temp_handle_t, POINTER(c_double) )
2359else:
2360    _zesTemperatureGetState_t = CFUNCTYPE( ze_result_t, zes_temp_handle_t, POINTER(c_double) )
2361
2362
2363###############################################################################
2364## @brief Table of Temperature functions pointers
2365class _zes_temperature_dditable_t(Structure):
2366    _fields_ = [
2367        ("pfnGetProperties", c_void_p),                                 ## _zesTemperatureGetProperties_t
2368        ("pfnGetConfig", c_void_p),                                     ## _zesTemperatureGetConfig_t
2369        ("pfnSetConfig", c_void_p),                                     ## _zesTemperatureSetConfig_t
2370        ("pfnGetState", c_void_p)                                       ## _zesTemperatureGetState_t
2371    ]
2372
2373###############################################################################
2374## @brief Function-pointer for zesPsuGetProperties
2375if __use_win_types:
2376    _zesPsuGetProperties_t = WINFUNCTYPE( ze_result_t, zes_psu_handle_t, POINTER(zes_psu_properties_t) )
2377else:
2378    _zesPsuGetProperties_t = CFUNCTYPE( ze_result_t, zes_psu_handle_t, POINTER(zes_psu_properties_t) )
2379
2380###############################################################################
2381## @brief Function-pointer for zesPsuGetState
2382if __use_win_types:
2383    _zesPsuGetState_t = WINFUNCTYPE( ze_result_t, zes_psu_handle_t, POINTER(zes_psu_state_t) )
2384else:
2385    _zesPsuGetState_t = CFUNCTYPE( ze_result_t, zes_psu_handle_t, POINTER(zes_psu_state_t) )
2386
2387
2388###############################################################################
2389## @brief Table of Psu functions pointers
2390class _zes_psu_dditable_t(Structure):
2391    _fields_ = [
2392        ("pfnGetProperties", c_void_p),                                 ## _zesPsuGetProperties_t
2393        ("pfnGetState", c_void_p)                                       ## _zesPsuGetState_t
2394    ]
2395
2396###############################################################################
2397## @brief Function-pointer for zesFanGetProperties
2398if __use_win_types:
2399    _zesFanGetProperties_t = WINFUNCTYPE( ze_result_t, zes_fan_handle_t, POINTER(zes_fan_properties_t) )
2400else:
2401    _zesFanGetProperties_t = CFUNCTYPE( ze_result_t, zes_fan_handle_t, POINTER(zes_fan_properties_t) )
2402
2403###############################################################################
2404## @brief Function-pointer for zesFanGetConfig
2405if __use_win_types:
2406    _zesFanGetConfig_t = WINFUNCTYPE( ze_result_t, zes_fan_handle_t, POINTER(zes_fan_config_t) )
2407else:
2408    _zesFanGetConfig_t = CFUNCTYPE( ze_result_t, zes_fan_handle_t, POINTER(zes_fan_config_t) )
2409
2410###############################################################################
2411## @brief Function-pointer for zesFanSetDefaultMode
2412if __use_win_types:
2413    _zesFanSetDefaultMode_t = WINFUNCTYPE( ze_result_t, zes_fan_handle_t )
2414else:
2415    _zesFanSetDefaultMode_t = CFUNCTYPE( ze_result_t, zes_fan_handle_t )
2416
2417###############################################################################
2418## @brief Function-pointer for zesFanSetFixedSpeedMode
2419if __use_win_types:
2420    _zesFanSetFixedSpeedMode_t = WINFUNCTYPE( ze_result_t, zes_fan_handle_t, POINTER(zes_fan_speed_t) )
2421else:
2422    _zesFanSetFixedSpeedMode_t = CFUNCTYPE( ze_result_t, zes_fan_handle_t, POINTER(zes_fan_speed_t) )
2423
2424###############################################################################
2425## @brief Function-pointer for zesFanSetSpeedTableMode
2426if __use_win_types:
2427    _zesFanSetSpeedTableMode_t = WINFUNCTYPE( ze_result_t, zes_fan_handle_t, POINTER(zes_fan_speed_table_t) )
2428else:
2429    _zesFanSetSpeedTableMode_t = CFUNCTYPE( ze_result_t, zes_fan_handle_t, POINTER(zes_fan_speed_table_t) )
2430
2431###############################################################################
2432## @brief Function-pointer for zesFanGetState
2433if __use_win_types:
2434    _zesFanGetState_t = WINFUNCTYPE( ze_result_t, zes_fan_handle_t, zes_fan_speed_units_t, POINTER(c_int32_t) )
2435else:
2436    _zesFanGetState_t = CFUNCTYPE( ze_result_t, zes_fan_handle_t, zes_fan_speed_units_t, POINTER(c_int32_t) )
2437
2438
2439###############################################################################
2440## @brief Table of Fan functions pointers
2441class _zes_fan_dditable_t(Structure):
2442    _fields_ = [
2443        ("pfnGetProperties", c_void_p),                                 ## _zesFanGetProperties_t
2444        ("pfnGetConfig", c_void_p),                                     ## _zesFanGetConfig_t
2445        ("pfnSetDefaultMode", c_void_p),                                ## _zesFanSetDefaultMode_t
2446        ("pfnSetFixedSpeedMode", c_void_p),                             ## _zesFanSetFixedSpeedMode_t
2447        ("pfnSetSpeedTableMode", c_void_p),                             ## _zesFanSetSpeedTableMode_t
2448        ("pfnGetState", c_void_p)                                       ## _zesFanGetState_t
2449    ]
2450
2451###############################################################################
2452## @brief Function-pointer for zesLedGetProperties
2453if __use_win_types:
2454    _zesLedGetProperties_t = WINFUNCTYPE( ze_result_t, zes_led_handle_t, POINTER(zes_led_properties_t) )
2455else:
2456    _zesLedGetProperties_t = CFUNCTYPE( ze_result_t, zes_led_handle_t, POINTER(zes_led_properties_t) )
2457
2458###############################################################################
2459## @brief Function-pointer for zesLedGetState
2460if __use_win_types:
2461    _zesLedGetState_t = WINFUNCTYPE( ze_result_t, zes_led_handle_t, POINTER(zes_led_state_t) )
2462else:
2463    _zesLedGetState_t = CFUNCTYPE( ze_result_t, zes_led_handle_t, POINTER(zes_led_state_t) )
2464
2465###############################################################################
2466## @brief Function-pointer for zesLedSetState
2467if __use_win_types:
2468    _zesLedSetState_t = WINFUNCTYPE( ze_result_t, zes_led_handle_t, ze_bool_t )
2469else:
2470    _zesLedSetState_t = CFUNCTYPE( ze_result_t, zes_led_handle_t, ze_bool_t )
2471
2472###############################################################################
2473## @brief Function-pointer for zesLedSetColor
2474if __use_win_types:
2475    _zesLedSetColor_t = WINFUNCTYPE( ze_result_t, zes_led_handle_t, POINTER(zes_led_color_t) )
2476else:
2477    _zesLedSetColor_t = CFUNCTYPE( ze_result_t, zes_led_handle_t, POINTER(zes_led_color_t) )
2478
2479
2480###############################################################################
2481## @brief Table of Led functions pointers
2482class _zes_led_dditable_t(Structure):
2483    _fields_ = [
2484        ("pfnGetProperties", c_void_p),                                 ## _zesLedGetProperties_t
2485        ("pfnGetState", c_void_p),                                      ## _zesLedGetState_t
2486        ("pfnSetState", c_void_p),                                      ## _zesLedSetState_t
2487        ("pfnSetColor", c_void_p)                                       ## _zesLedSetColor_t
2488    ]
2489
2490###############################################################################
2491## @brief Function-pointer for zesRasGetProperties
2492if __use_win_types:
2493    _zesRasGetProperties_t = WINFUNCTYPE( ze_result_t, zes_ras_handle_t, POINTER(zes_ras_properties_t) )
2494else:
2495    _zesRasGetProperties_t = CFUNCTYPE( ze_result_t, zes_ras_handle_t, POINTER(zes_ras_properties_t) )
2496
2497###############################################################################
2498## @brief Function-pointer for zesRasGetConfig
2499if __use_win_types:
2500    _zesRasGetConfig_t = WINFUNCTYPE( ze_result_t, zes_ras_handle_t, POINTER(zes_ras_config_t) )
2501else:
2502    _zesRasGetConfig_t = CFUNCTYPE( ze_result_t, zes_ras_handle_t, POINTER(zes_ras_config_t) )
2503
2504###############################################################################
2505## @brief Function-pointer for zesRasSetConfig
2506if __use_win_types:
2507    _zesRasSetConfig_t = WINFUNCTYPE( ze_result_t, zes_ras_handle_t, POINTER(zes_ras_config_t) )
2508else:
2509    _zesRasSetConfig_t = CFUNCTYPE( ze_result_t, zes_ras_handle_t, POINTER(zes_ras_config_t) )
2510
2511###############################################################################
2512## @brief Function-pointer for zesRasGetState
2513if __use_win_types:
2514    _zesRasGetState_t = WINFUNCTYPE( ze_result_t, zes_ras_handle_t, ze_bool_t, POINTER(zes_ras_state_t) )
2515else:
2516    _zesRasGetState_t = CFUNCTYPE( ze_result_t, zes_ras_handle_t, ze_bool_t, POINTER(zes_ras_state_t) )
2517
2518
2519###############################################################################
2520## @brief Table of Ras functions pointers
2521class _zes_ras_dditable_t(Structure):
2522    _fields_ = [
2523        ("pfnGetProperties", c_void_p),                                 ## _zesRasGetProperties_t
2524        ("pfnGetConfig", c_void_p),                                     ## _zesRasGetConfig_t
2525        ("pfnSetConfig", c_void_p),                                     ## _zesRasSetConfig_t
2526        ("pfnGetState", c_void_p)                                       ## _zesRasGetState_t
2527    ]
2528
2529###############################################################################
2530## @brief Function-pointer for zesDiagnosticsGetProperties
2531if __use_win_types:
2532    _zesDiagnosticsGetProperties_t = WINFUNCTYPE( ze_result_t, zes_diag_handle_t, POINTER(zes_diag_properties_t) )
2533else:
2534    _zesDiagnosticsGetProperties_t = CFUNCTYPE( ze_result_t, zes_diag_handle_t, POINTER(zes_diag_properties_t) )
2535
2536###############################################################################
2537## @brief Function-pointer for zesDiagnosticsGetTests
2538if __use_win_types:
2539    _zesDiagnosticsGetTests_t = WINFUNCTYPE( ze_result_t, zes_diag_handle_t, POINTER(c_ulong), POINTER(zes_diag_test_t) )
2540else:
2541    _zesDiagnosticsGetTests_t = CFUNCTYPE( ze_result_t, zes_diag_handle_t, POINTER(c_ulong), POINTER(zes_diag_test_t) )
2542
2543###############################################################################
2544## @brief Function-pointer for zesDiagnosticsRunTests
2545if __use_win_types:
2546    _zesDiagnosticsRunTests_t = WINFUNCTYPE( ze_result_t, zes_diag_handle_t, c_ulong, c_ulong, POINTER(zes_diag_result_t) )
2547else:
2548    _zesDiagnosticsRunTests_t = CFUNCTYPE( ze_result_t, zes_diag_handle_t, c_ulong, c_ulong, POINTER(zes_diag_result_t) )
2549
2550
2551###############################################################################
2552## @brief Table of Diagnostics functions pointers
2553class _zes_diagnostics_dditable_t(Structure):
2554    _fields_ = [
2555        ("pfnGetProperties", c_void_p),                                 ## _zesDiagnosticsGetProperties_t
2556        ("pfnGetTests", c_void_p),                                      ## _zesDiagnosticsGetTests_t
2557        ("pfnRunTests", c_void_p)                                       ## _zesDiagnosticsRunTests_t
2558    ]
2559
2560###############################################################################
2561class _zes_dditable_t(Structure):
2562    _fields_ = [
2563        ("Driver", _zes_driver_dditable_t),
2564        ("Device", _zes_device_dditable_t),
2565        ("Scheduler", _zes_scheduler_dditable_t),
2566        ("PerformanceFactor", _zes_performance_factor_dditable_t),
2567        ("Power", _zes_power_dditable_t),
2568        ("Frequency", _zes_frequency_dditable_t),
2569        ("Engine", _zes_engine_dditable_t),
2570        ("Standby", _zes_standby_dditable_t),
2571        ("Firmware", _zes_firmware_dditable_t),
2572        ("Memory", _zes_memory_dditable_t),
2573        ("FabricPort", _zes_fabric_port_dditable_t),
2574        ("Temperature", _zes_temperature_dditable_t),
2575        ("Psu", _zes_psu_dditable_t),
2576        ("Fan", _zes_fan_dditable_t),
2577        ("Led", _zes_led_dditable_t),
2578        ("Ras", _zes_ras_dditable_t),
2579        ("Diagnostics", _zes_diagnostics_dditable_t)
2580    ]
2581
2582###############################################################################
2583## @brief zes device-driver interfaces
2584class ZES_DDI:
2585    def __init__(self, version : ze_api_version_t):
2586        # load the ze_loader library
2587        if "Windows" == platform.uname()[0]:
2588            self.__dll = WinDLL("ze_loader.dll")
2589        else:
2590            self.__dll = CDLL("ze_loader.so")
2591
2592        # fill the ddi tables
2593        self.__dditable = _zes_dditable_t()
2594
2595        # call driver to get function pointers
2596        _Driver = _zes_driver_dditable_t()
2597        r = ze_result_v(self.__dll.zesGetDriverProcAddrTable(version, byref(_Driver)))
2598        if r != ze_result_v.SUCCESS:
2599            raise Exception(r)
2600        self.__dditable.Driver = _Driver
2601
2602        # attach function interface to function address
2603        self.zesDriverEventListen = _zesDriverEventListen_t(self.__dditable.Driver.pfnEventListen)
2604        self.zesDriverEventListenEx = _zesDriverEventListenEx_t(self.__dditable.Driver.pfnEventListenEx)
2605
2606        # call driver to get function pointers
2607        _Device = _zes_device_dditable_t()
2608        r = ze_result_v(self.__dll.zesGetDeviceProcAddrTable(version, byref(_Device)))
2609        if r != ze_result_v.SUCCESS:
2610            raise Exception(r)
2611        self.__dditable.Device = _Device
2612
2613        # attach function interface to function address
2614        self.zesDeviceGetProperties = _zesDeviceGetProperties_t(self.__dditable.Device.pfnGetProperties)
2615        self.zesDeviceGetState = _zesDeviceGetState_t(self.__dditable.Device.pfnGetState)
2616        self.zesDeviceReset = _zesDeviceReset_t(self.__dditable.Device.pfnReset)
2617        self.zesDeviceProcessesGetState = _zesDeviceProcessesGetState_t(self.__dditable.Device.pfnProcessesGetState)
2618        self.zesDevicePciGetProperties = _zesDevicePciGetProperties_t(self.__dditable.Device.pfnPciGetProperties)
2619        self.zesDevicePciGetState = _zesDevicePciGetState_t(self.__dditable.Device.pfnPciGetState)
2620        self.zesDevicePciGetBars = _zesDevicePciGetBars_t(self.__dditable.Device.pfnPciGetBars)
2621        self.zesDevicePciGetStats = _zesDevicePciGetStats_t(self.__dditable.Device.pfnPciGetStats)
2622        self.zesDeviceEnumDiagnosticTestSuites = _zesDeviceEnumDiagnosticTestSuites_t(self.__dditable.Device.pfnEnumDiagnosticTestSuites)
2623        self.zesDeviceEnumEngineGroups = _zesDeviceEnumEngineGroups_t(self.__dditable.Device.pfnEnumEngineGroups)
2624        self.zesDeviceEventRegister = _zesDeviceEventRegister_t(self.__dditable.Device.pfnEventRegister)
2625        self.zesDeviceEnumFabricPorts = _zesDeviceEnumFabricPorts_t(self.__dditable.Device.pfnEnumFabricPorts)
2626        self.zesDeviceEnumFans = _zesDeviceEnumFans_t(self.__dditable.Device.pfnEnumFans)
2627        self.zesDeviceEnumFirmwares = _zesDeviceEnumFirmwares_t(self.__dditable.Device.pfnEnumFirmwares)
2628        self.zesDeviceEnumFrequencyDomains = _zesDeviceEnumFrequencyDomains_t(self.__dditable.Device.pfnEnumFrequencyDomains)
2629        self.zesDeviceEnumLeds = _zesDeviceEnumLeds_t(self.__dditable.Device.pfnEnumLeds)
2630        self.zesDeviceEnumMemoryModules = _zesDeviceEnumMemoryModules_t(self.__dditable.Device.pfnEnumMemoryModules)
2631        self.zesDeviceEnumPerformanceFactorDomains = _zesDeviceEnumPerformanceFactorDomains_t(self.__dditable.Device.pfnEnumPerformanceFactorDomains)
2632        self.zesDeviceEnumPowerDomains = _zesDeviceEnumPowerDomains_t(self.__dditable.Device.pfnEnumPowerDomains)
2633        self.zesDeviceGetCardPowerDomain = _zesDeviceGetCardPowerDomain_t(self.__dditable.Device.pfnGetCardPowerDomain)
2634        self.zesDeviceEnumPsus = _zesDeviceEnumPsus_t(self.__dditable.Device.pfnEnumPsus)
2635        self.zesDeviceEnumRasErrorSets = _zesDeviceEnumRasErrorSets_t(self.__dditable.Device.pfnEnumRasErrorSets)
2636        self.zesDeviceEnumSchedulers = _zesDeviceEnumSchedulers_t(self.__dditable.Device.pfnEnumSchedulers)
2637        self.zesDeviceEnumStandbyDomains = _zesDeviceEnumStandbyDomains_t(self.__dditable.Device.pfnEnumStandbyDomains)
2638        self.zesDeviceEnumTemperatureSensors = _zesDeviceEnumTemperatureSensors_t(self.__dditable.Device.pfnEnumTemperatureSensors)
2639
2640        # call driver to get function pointers
2641        _Scheduler = _zes_scheduler_dditable_t()
2642        r = ze_result_v(self.__dll.zesGetSchedulerProcAddrTable(version, byref(_Scheduler)))
2643        if r != ze_result_v.SUCCESS:
2644            raise Exception(r)
2645        self.__dditable.Scheduler = _Scheduler
2646
2647        # attach function interface to function address
2648        self.zesSchedulerGetProperties = _zesSchedulerGetProperties_t(self.__dditable.Scheduler.pfnGetProperties)
2649        self.zesSchedulerGetCurrentMode = _zesSchedulerGetCurrentMode_t(self.__dditable.Scheduler.pfnGetCurrentMode)
2650        self.zesSchedulerGetTimeoutModeProperties = _zesSchedulerGetTimeoutModeProperties_t(self.__dditable.Scheduler.pfnGetTimeoutModeProperties)
2651        self.zesSchedulerGetTimesliceModeProperties = _zesSchedulerGetTimesliceModeProperties_t(self.__dditable.Scheduler.pfnGetTimesliceModeProperties)
2652        self.zesSchedulerSetTimeoutMode = _zesSchedulerSetTimeoutMode_t(self.__dditable.Scheduler.pfnSetTimeoutMode)
2653        self.zesSchedulerSetTimesliceMode = _zesSchedulerSetTimesliceMode_t(self.__dditable.Scheduler.pfnSetTimesliceMode)
2654        self.zesSchedulerSetExclusiveMode = _zesSchedulerSetExclusiveMode_t(self.__dditable.Scheduler.pfnSetExclusiveMode)
2655        self.zesSchedulerSetComputeUnitDebugMode = _zesSchedulerSetComputeUnitDebugMode_t(self.__dditable.Scheduler.pfnSetComputeUnitDebugMode)
2656
2657        # call driver to get function pointers
2658        _PerformanceFactor = _zes_performance_factor_dditable_t()
2659        r = ze_result_v(self.__dll.zesGetPerformanceFactorProcAddrTable(version, byref(_PerformanceFactor)))
2660        if r != ze_result_v.SUCCESS:
2661            raise Exception(r)
2662        self.__dditable.PerformanceFactor = _PerformanceFactor
2663
2664        # attach function interface to function address
2665        self.zesPerformanceFactorGetProperties = _zesPerformanceFactorGetProperties_t(self.__dditable.PerformanceFactor.pfnGetProperties)
2666        self.zesPerformanceFactorGetConfig = _zesPerformanceFactorGetConfig_t(self.__dditable.PerformanceFactor.pfnGetConfig)
2667        self.zesPerformanceFactorSetConfig = _zesPerformanceFactorSetConfig_t(self.__dditable.PerformanceFactor.pfnSetConfig)
2668
2669        # call driver to get function pointers
2670        _Power = _zes_power_dditable_t()
2671        r = ze_result_v(self.__dll.zesGetPowerProcAddrTable(version, byref(_Power)))
2672        if r != ze_result_v.SUCCESS:
2673            raise Exception(r)
2674        self.__dditable.Power = _Power
2675
2676        # attach function interface to function address
2677        self.zesPowerGetProperties = _zesPowerGetProperties_t(self.__dditable.Power.pfnGetProperties)
2678        self.zesPowerGetEnergyCounter = _zesPowerGetEnergyCounter_t(self.__dditable.Power.pfnGetEnergyCounter)
2679        self.zesPowerGetLimits = _zesPowerGetLimits_t(self.__dditable.Power.pfnGetLimits)
2680        self.zesPowerSetLimits = _zesPowerSetLimits_t(self.__dditable.Power.pfnSetLimits)
2681        self.zesPowerGetEnergyThreshold = _zesPowerGetEnergyThreshold_t(self.__dditable.Power.pfnGetEnergyThreshold)
2682        self.zesPowerSetEnergyThreshold = _zesPowerSetEnergyThreshold_t(self.__dditable.Power.pfnSetEnergyThreshold)
2683
2684        # call driver to get function pointers
2685        _Frequency = _zes_frequency_dditable_t()
2686        r = ze_result_v(self.__dll.zesGetFrequencyProcAddrTable(version, byref(_Frequency)))
2687        if r != ze_result_v.SUCCESS:
2688            raise Exception(r)
2689        self.__dditable.Frequency = _Frequency
2690
2691        # attach function interface to function address
2692        self.zesFrequencyGetProperties = _zesFrequencyGetProperties_t(self.__dditable.Frequency.pfnGetProperties)
2693        self.zesFrequencyGetAvailableClocks = _zesFrequencyGetAvailableClocks_t(self.__dditable.Frequency.pfnGetAvailableClocks)
2694        self.zesFrequencyGetRange = _zesFrequencyGetRange_t(self.__dditable.Frequency.pfnGetRange)
2695        self.zesFrequencySetRange = _zesFrequencySetRange_t(self.__dditable.Frequency.pfnSetRange)
2696        self.zesFrequencyGetState = _zesFrequencyGetState_t(self.__dditable.Frequency.pfnGetState)
2697        self.zesFrequencyGetThrottleTime = _zesFrequencyGetThrottleTime_t(self.__dditable.Frequency.pfnGetThrottleTime)
2698        self.zesFrequencyOcGetCapabilities = _zesFrequencyOcGetCapabilities_t(self.__dditable.Frequency.pfnOcGetCapabilities)
2699        self.zesFrequencyOcGetFrequencyTarget = _zesFrequencyOcGetFrequencyTarget_t(self.__dditable.Frequency.pfnOcGetFrequencyTarget)
2700        self.zesFrequencyOcSetFrequencyTarget = _zesFrequencyOcSetFrequencyTarget_t(self.__dditable.Frequency.pfnOcSetFrequencyTarget)
2701        self.zesFrequencyOcGetVoltageTarget = _zesFrequencyOcGetVoltageTarget_t(self.__dditable.Frequency.pfnOcGetVoltageTarget)
2702        self.zesFrequencyOcSetVoltageTarget = _zesFrequencyOcSetVoltageTarget_t(self.__dditable.Frequency.pfnOcSetVoltageTarget)
2703        self.zesFrequencyOcSetMode = _zesFrequencyOcSetMode_t(self.__dditable.Frequency.pfnOcSetMode)
2704        self.zesFrequencyOcGetMode = _zesFrequencyOcGetMode_t(self.__dditable.Frequency.pfnOcGetMode)
2705        self.zesFrequencyOcGetIccMax = _zesFrequencyOcGetIccMax_t(self.__dditable.Frequency.pfnOcGetIccMax)
2706        self.zesFrequencyOcSetIccMax = _zesFrequencyOcSetIccMax_t(self.__dditable.Frequency.pfnOcSetIccMax)
2707        self.zesFrequencyOcGetTjMax = _zesFrequencyOcGetTjMax_t(self.__dditable.Frequency.pfnOcGetTjMax)
2708        self.zesFrequencyOcSetTjMax = _zesFrequencyOcSetTjMax_t(self.__dditable.Frequency.pfnOcSetTjMax)
2709
2710        # call driver to get function pointers
2711        _Engine = _zes_engine_dditable_t()
2712        r = ze_result_v(self.__dll.zesGetEngineProcAddrTable(version, byref(_Engine)))
2713        if r != ze_result_v.SUCCESS:
2714            raise Exception(r)
2715        self.__dditable.Engine = _Engine
2716
2717        # attach function interface to function address
2718        self.zesEngineGetProperties = _zesEngineGetProperties_t(self.__dditable.Engine.pfnGetProperties)
2719        self.zesEngineGetActivity = _zesEngineGetActivity_t(self.__dditable.Engine.pfnGetActivity)
2720
2721        # call driver to get function pointers
2722        _Standby = _zes_standby_dditable_t()
2723        r = ze_result_v(self.__dll.zesGetStandbyProcAddrTable(version, byref(_Standby)))
2724        if r != ze_result_v.SUCCESS:
2725            raise Exception(r)
2726        self.__dditable.Standby = _Standby
2727
2728        # attach function interface to function address
2729        self.zesStandbyGetProperties = _zesStandbyGetProperties_t(self.__dditable.Standby.pfnGetProperties)
2730        self.zesStandbyGetMode = _zesStandbyGetMode_t(self.__dditable.Standby.pfnGetMode)
2731        self.zesStandbySetMode = _zesStandbySetMode_t(self.__dditable.Standby.pfnSetMode)
2732
2733        # call driver to get function pointers
2734        _Firmware = _zes_firmware_dditable_t()
2735        r = ze_result_v(self.__dll.zesGetFirmwareProcAddrTable(version, byref(_Firmware)))
2736        if r != ze_result_v.SUCCESS:
2737            raise Exception(r)
2738        self.__dditable.Firmware = _Firmware
2739
2740        # attach function interface to function address
2741        self.zesFirmwareGetProperties = _zesFirmwareGetProperties_t(self.__dditable.Firmware.pfnGetProperties)
2742        self.zesFirmwareFlash = _zesFirmwareFlash_t(self.__dditable.Firmware.pfnFlash)
2743
2744        # call driver to get function pointers
2745        _Memory = _zes_memory_dditable_t()
2746        r = ze_result_v(self.__dll.zesGetMemoryProcAddrTable(version, byref(_Memory)))
2747        if r != ze_result_v.SUCCESS:
2748            raise Exception(r)
2749        self.__dditable.Memory = _Memory
2750
2751        # attach function interface to function address
2752        self.zesMemoryGetProperties = _zesMemoryGetProperties_t(self.__dditable.Memory.pfnGetProperties)
2753        self.zesMemoryGetState = _zesMemoryGetState_t(self.__dditable.Memory.pfnGetState)
2754        self.zesMemoryGetBandwidth = _zesMemoryGetBandwidth_t(self.__dditable.Memory.pfnGetBandwidth)
2755
2756        # call driver to get function pointers
2757        _FabricPort = _zes_fabric_port_dditable_t()
2758        r = ze_result_v(self.__dll.zesGetFabricPortProcAddrTable(version, byref(_FabricPort)))
2759        if r != ze_result_v.SUCCESS:
2760            raise Exception(r)
2761        self.__dditable.FabricPort = _FabricPort
2762
2763        # attach function interface to function address
2764        self.zesFabricPortGetProperties = _zesFabricPortGetProperties_t(self.__dditable.FabricPort.pfnGetProperties)
2765        self.zesFabricPortGetLinkType = _zesFabricPortGetLinkType_t(self.__dditable.FabricPort.pfnGetLinkType)
2766        self.zesFabricPortGetConfig = _zesFabricPortGetConfig_t(self.__dditable.FabricPort.pfnGetConfig)
2767        self.zesFabricPortSetConfig = _zesFabricPortSetConfig_t(self.__dditable.FabricPort.pfnSetConfig)
2768        self.zesFabricPortGetState = _zesFabricPortGetState_t(self.__dditable.FabricPort.pfnGetState)
2769        self.zesFabricPortGetThroughput = _zesFabricPortGetThroughput_t(self.__dditable.FabricPort.pfnGetThroughput)
2770
2771        # call driver to get function pointers
2772        _Temperature = _zes_temperature_dditable_t()
2773        r = ze_result_v(self.__dll.zesGetTemperatureProcAddrTable(version, byref(_Temperature)))
2774        if r != ze_result_v.SUCCESS:
2775            raise Exception(r)
2776        self.__dditable.Temperature = _Temperature
2777
2778        # attach function interface to function address
2779        self.zesTemperatureGetProperties = _zesTemperatureGetProperties_t(self.__dditable.Temperature.pfnGetProperties)
2780        self.zesTemperatureGetConfig = _zesTemperatureGetConfig_t(self.__dditable.Temperature.pfnGetConfig)
2781        self.zesTemperatureSetConfig = _zesTemperatureSetConfig_t(self.__dditable.Temperature.pfnSetConfig)
2782        self.zesTemperatureGetState = _zesTemperatureGetState_t(self.__dditable.Temperature.pfnGetState)
2783
2784        # call driver to get function pointers
2785        _Psu = _zes_psu_dditable_t()
2786        r = ze_result_v(self.__dll.zesGetPsuProcAddrTable(version, byref(_Psu)))
2787        if r != ze_result_v.SUCCESS:
2788            raise Exception(r)
2789        self.__dditable.Psu = _Psu
2790
2791        # attach function interface to function address
2792        self.zesPsuGetProperties = _zesPsuGetProperties_t(self.__dditable.Psu.pfnGetProperties)
2793        self.zesPsuGetState = _zesPsuGetState_t(self.__dditable.Psu.pfnGetState)
2794
2795        # call driver to get function pointers
2796        _Fan = _zes_fan_dditable_t()
2797        r = ze_result_v(self.__dll.zesGetFanProcAddrTable(version, byref(_Fan)))
2798        if r != ze_result_v.SUCCESS:
2799            raise Exception(r)
2800        self.__dditable.Fan = _Fan
2801
2802        # attach function interface to function address
2803        self.zesFanGetProperties = _zesFanGetProperties_t(self.__dditable.Fan.pfnGetProperties)
2804        self.zesFanGetConfig = _zesFanGetConfig_t(self.__dditable.Fan.pfnGetConfig)
2805        self.zesFanSetDefaultMode = _zesFanSetDefaultMode_t(self.__dditable.Fan.pfnSetDefaultMode)
2806        self.zesFanSetFixedSpeedMode = _zesFanSetFixedSpeedMode_t(self.__dditable.Fan.pfnSetFixedSpeedMode)
2807        self.zesFanSetSpeedTableMode = _zesFanSetSpeedTableMode_t(self.__dditable.Fan.pfnSetSpeedTableMode)
2808        self.zesFanGetState = _zesFanGetState_t(self.__dditable.Fan.pfnGetState)
2809
2810        # call driver to get function pointers
2811        _Led = _zes_led_dditable_t()
2812        r = ze_result_v(self.__dll.zesGetLedProcAddrTable(version, byref(_Led)))
2813        if r != ze_result_v.SUCCESS:
2814            raise Exception(r)
2815        self.__dditable.Led = _Led
2816
2817        # attach function interface to function address
2818        self.zesLedGetProperties = _zesLedGetProperties_t(self.__dditable.Led.pfnGetProperties)
2819        self.zesLedGetState = _zesLedGetState_t(self.__dditable.Led.pfnGetState)
2820        self.zesLedSetState = _zesLedSetState_t(self.__dditable.Led.pfnSetState)
2821        self.zesLedSetColor = _zesLedSetColor_t(self.__dditable.Led.pfnSetColor)
2822
2823        # call driver to get function pointers
2824        _Ras = _zes_ras_dditable_t()
2825        r = ze_result_v(self.__dll.zesGetRasProcAddrTable(version, byref(_Ras)))
2826        if r != ze_result_v.SUCCESS:
2827            raise Exception(r)
2828        self.__dditable.Ras = _Ras
2829
2830        # attach function interface to function address
2831        self.zesRasGetProperties = _zesRasGetProperties_t(self.__dditable.Ras.pfnGetProperties)
2832        self.zesRasGetConfig = _zesRasGetConfig_t(self.__dditable.Ras.pfnGetConfig)
2833        self.zesRasSetConfig = _zesRasSetConfig_t(self.__dditable.Ras.pfnSetConfig)
2834        self.zesRasGetState = _zesRasGetState_t(self.__dditable.Ras.pfnGetState)
2835
2836        # call driver to get function pointers
2837        _Diagnostics = _zes_diagnostics_dditable_t()
2838        r = ze_result_v(self.__dll.zesGetDiagnosticsProcAddrTable(version, byref(_Diagnostics)))
2839        if r != ze_result_v.SUCCESS:
2840            raise Exception(r)
2841        self.__dditable.Diagnostics = _Diagnostics
2842
2843        # attach function interface to function address
2844        self.zesDiagnosticsGetProperties = _zesDiagnosticsGetProperties_t(self.__dditable.Diagnostics.pfnGetProperties)
2845        self.zesDiagnosticsGetTests = _zesDiagnosticsGetTests_t(self.__dditable.Diagnostics.pfnGetTests)
2846        self.zesDiagnosticsRunTests = _zesDiagnosticsRunTests_t(self.__dditable.Diagnostics.pfnRunTests)
2847
2848        # success!
2849