-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathzet.py
1885 lines (1581 loc) · 112 KB
/
zet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Copyright (C) 2019-2021 Intel Corporation
SPDX-License-Identifier: MIT
@file zet.py
@version v1.12-r1.12.15
"""
import platform
from ctypes import *
from enum import *
###############################################################################
__version__ = "1.0"
###############################################################################
## @brief Handle to a driver instance
class zet_driver_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of device object
class zet_device_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of context object
class zet_context_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of command list object
class zet_command_list_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of module object
class zet_module_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of function object
class zet_kernel_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of metric group's object
class zet_metric_group_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of metric's object
class zet_metric_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of metric streamer's object
class zet_metric_streamer_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of metric query pool's object
class zet_metric_query_pool_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of metric query's object
class zet_metric_query_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of tracer object
class zet_tracer_exp_handle_t(c_void_p):
pass
###############################################################################
## @brief Debug session handle
class zet_debug_session_handle_t(c_void_p):
pass
###############################################################################
## @brief Defines structure types
class zet_structure_type_v(IntEnum):
METRIC_GROUP_PROPERTIES = 0x1 ## ::zet_metric_group_properties_t
METRIC_PROPERTIES = 0x2 ## ::zet_metric_properties_t
METRIC_STREAMER_DESC = 0x3 ## ::zet_metric_streamer_desc_t
METRIC_QUERY_POOL_DESC = 0x4 ## ::zet_metric_query_pool_desc_t
PROFILE_PROPERTIES = 0x5 ## ::zet_profile_properties_t
DEVICE_DEBUG_PROPERTIES = 0x6 ## ::zet_device_debug_properties_t
DEBUG_MEMORY_SPACE_DESC = 0x7 ## ::zet_debug_memory_space_desc_t
DEBUG_REGSET_PROPERTIES = 0x8 ## ::zet_debug_regset_properties_t
GLOBAL_METRICS_TIMESTAMPS_EXP_PROPERTIES = 0x9 ## ::zet_metric_global_timestamps_resolution_exp_t. Deprecated, use
## ::ZET_STRUCTURE_TYPE_METRIC_GLOBAL_TIMESTAMPS_RESOLUTION_EXP.
METRIC_GLOBAL_TIMESTAMPS_RESOLUTION_EXP = 0x9 ## ::zet_metric_global_timestamps_resolution_exp_t
TRACER_EXP_DESC = 0x00010001 ## ::zet_tracer_exp_desc_t
METRICS_CALCULATE_EXP_DESC = 0x00010002 ## ::zet_metric_calculate_exp_desc_t. Deprecated, use
## ::ZET_STRUCTURE_TYPE_METRIC_CALCULATE_EXP_DESC.
METRIC_CALCULATE_EXP_DESC = 0x00010002 ## ::zet_metric_calculate_exp_desc_t
METRIC_PROGRAMMABLE_EXP_PROPERTIES = 0x00010003 ## ::zet_metric_programmable_exp_properties_t
METRIC_PROGRAMMABLE_PARAM_INFO_EXP = 0x00010004 ## ::zet_metric_programmable_param_info_exp_t
METRIC_PROGRAMMABLE_PARAM_VALUE_INFO_EXP = 0x00010005 ## ::zet_metric_programmable_param_value_info_exp_t
METRIC_GROUP_TYPE_EXP = 0x00010006 ## ::zet_metric_group_type_exp_t
EXPORT_DMA_EXP_PROPERTIES = 0x00010007 ## ::zet_export_dma_buf_exp_properties_t
METRIC_TRACER_EXP_DESC = 0x00010008 ## ::zet_metric_tracer_exp_desc_t
class zet_structure_type_t(c_int):
def __str__(self):
return str(zet_structure_type_v(self.value))
###############################################################################
## @brief Base for all properties types
class zet_base_properties_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p) ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
]
###############################################################################
## @brief Base for all descriptor types
class zet_base_desc_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p) ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
]
###############################################################################
## @brief Supported value types
class zet_value_type_v(IntEnum):
UINT32 = 0 ## 32-bit unsigned-integer
UINT64 = 1 ## 64-bit unsigned-integer
FLOAT32 = 2 ## 32-bit floating-point
FLOAT64 = 3 ## 64-bit floating-point
BOOL8 = 4 ## 8-bit boolean
STRING = 5 ## C string
UINT8 = 6 ## 8-bit unsigned-integer
UINT16 = 7 ## 16-bit unsigned-integer
class zet_value_type_t(c_int):
def __str__(self):
return str(zet_value_type_v(self.value))
###############################################################################
## @brief Union of values
class zet_value_t(Structure):
_fields_ = [
("ui32", c_ulong), ## [out] 32-bit unsigned-integer
("ui64", c_ulonglong), ## [out] 64-bit unsigned-integer
("fp32", c_float), ## [out] 32-bit floating-point
("fp64", c_double), ## [out] 64-bit floating-point
("b8", ze_bool_t) ## [out] 8-bit boolean
]
###############################################################################
## @brief Typed value
class zet_typed_value_t(Structure):
_fields_ = [
("type", zet_value_type_t), ## [out] type of value
("value", zet_value_t) ## [out] value
]
###############################################################################
## @brief Enables driver instrumentation and dependencies for device metrics
###############################################################################
## @brief Enables driver instrumentation and dependencies for program
## instrumentation
###############################################################################
## @brief Enables driver instrumentation and dependencies for program debugging
###############################################################################
## @brief Supported module debug info formats.
class zet_module_debug_info_format_v(IntEnum):
ELF_DWARF = 0 ## Format is ELF/DWARF
class zet_module_debug_info_format_t(c_int):
def __str__(self):
return str(zet_module_debug_info_format_v(self.value))
###############################################################################
## @brief Supported device debug property flags
class zet_device_debug_property_flags_v(IntEnum):
ATTACH = ZE_BIT(0) ## the device supports attaching for debug
class zet_device_debug_property_flags_t(c_int):
def __str__(self):
return hex(self.value)
###############################################################################
## @brief Device debug properties queried using ::zetDeviceGetDebugProperties.
class zet_device_debug_properties_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("flags", zet_device_debug_property_flags_t) ## [out] returns 0 (none) or a valid combination of
## ::zet_device_debug_property_flag_t
]
###############################################################################
## @brief Debug configuration provided to ::zetDebugAttach
class zet_debug_config_t(Structure):
_fields_ = [
("pid", c_ulong) ## [in] the host process identifier
]
###############################################################################
## @brief Supported debug event flags.
class zet_debug_event_flags_v(IntEnum):
NEED_ACK = ZE_BIT(0) ## The event needs to be acknowledged by calling
## ::zetDebugAcknowledgeEvent.
class zet_debug_event_flags_t(c_int):
def __str__(self):
return hex(self.value)
###############################################################################
## @brief Supported debug event types.
class zet_debug_event_type_v(IntEnum):
INVALID = 0 ## The event is invalid
DETACHED = 1 ## The tool was detached
PROCESS_ENTRY = 2 ## The debuggee process created command queues on the device
PROCESS_EXIT = 3 ## The debuggee process destroyed all command queues on the device
MODULE_LOAD = 4 ## An in-memory module was loaded onto the device
MODULE_UNLOAD = 5 ## An in-memory module is about to get unloaded from the device
THREAD_STOPPED = 6 ## The thread stopped due to a device exception
THREAD_UNAVAILABLE = 7 ## The thread is not available to be stopped
PAGE_FAULT = 8 ## A page request could not be completed on the device
class zet_debug_event_type_t(c_int):
def __str__(self):
return str(zet_debug_event_type_v(self.value))
###############################################################################
## @brief Supported debug detach reasons.
class zet_debug_detach_reason_v(IntEnum):
INVALID = 0 ## The detach reason is not valid
HOST_EXIT = 1 ## The host process exited
class zet_debug_detach_reason_t(c_int):
def __str__(self):
return str(zet_debug_detach_reason_v(self.value))
###############################################################################
## @brief Event information for ::ZET_DEBUG_EVENT_TYPE_DETACHED
class zet_debug_event_info_detached_t(Structure):
_fields_ = [
("reason", zet_debug_detach_reason_t) ## [out] the detach reason
]
###############################################################################
## @brief Event information for ::ZET_DEBUG_EVENT_TYPE_MODULE_LOAD and
## ::ZET_DEBUG_EVENT_TYPE_MODULE_UNLOAD
class zet_debug_event_info_module_t(Structure):
_fields_ = [
("format", zet_module_debug_info_format_t), ## [out] the module format
("moduleBegin", c_ulonglong), ## [out] the begin address of the in-memory module (inclusive)
("moduleEnd", c_ulonglong), ## [out] the end address of the in-memory module (exclusive)
("load", c_ulonglong) ## [out] the load address of the module on the device
]
###############################################################################
## @brief Event information for ::ZET_DEBUG_EVENT_TYPE_THREAD_STOPPED and
## ::ZET_DEBUG_EVENT_TYPE_THREAD_UNAVAILABLE
class zet_debug_event_info_thread_stopped_t(Structure):
_fields_ = [
("thread", ze_device_thread_t) ## [out] the stopped/unavailable thread
]
###############################################################################
## @brief Page fault reasons.
class zet_debug_page_fault_reason_v(IntEnum):
INVALID = 0 ## The page fault reason is not valid
MAPPING_ERROR = 1 ## The address is not mapped
PERMISSION_ERROR = 2 ## Invalid access permissions
class zet_debug_page_fault_reason_t(c_int):
def __str__(self):
return str(zet_debug_page_fault_reason_v(self.value))
###############################################################################
## @brief Event information for ::ZET_DEBUG_EVENT_TYPE_PAGE_FAULT
class zet_debug_event_info_page_fault_t(Structure):
_fields_ = [
("address", c_ulonglong), ## [out] the faulting address
("mask", c_ulonglong), ## [out] the alignment mask
("reason", zet_debug_page_fault_reason_t) ## [out] the page fault reason
]
###############################################################################
## @brief Event type-specific information
class zet_debug_event_info_t(Structure):
_fields_ = [
("detached", zet_debug_event_info_detached_t), ## [out] type == ::ZET_DEBUG_EVENT_TYPE_DETACHED
("module", zet_debug_event_info_module_t), ## [out] type == ::ZET_DEBUG_EVENT_TYPE_MODULE_LOAD or
## ::ZET_DEBUG_EVENT_TYPE_MODULE_UNLOAD
("thread", zet_debug_event_info_thread_stopped_t), ## [out] type == ::ZET_DEBUG_EVENT_TYPE_THREAD_STOPPED or
## ::ZET_DEBUG_EVENT_TYPE_THREAD_UNAVAILABLE
("page_fault", zet_debug_event_info_page_fault_t) ## [out] type == ::ZET_DEBUG_EVENT_TYPE_PAGE_FAULT
]
###############################################################################
## @brief A debug event on the device.
class zet_debug_event_t(Structure):
_fields_ = [
("type", zet_debug_event_type_t), ## [out] the event type
("flags", zet_debug_event_flags_t), ## [out] returns 0 (none) or a combination of ::zet_debug_event_flag_t
("info", zet_debug_event_info_t) ## [out] event type specific information
]
###############################################################################
## @brief Supported device memory space types.
class zet_debug_memory_space_type_v(IntEnum):
DEFAULT = 0 ## default memory space (attribute may be omitted)
SLM = 1 ## shared local memory space (GPU-only)
ELF = 2 ## ELF file memory space
class zet_debug_memory_space_type_t(c_int):
def __str__(self):
return str(zet_debug_memory_space_type_v(self.value))
###############################################################################
## @brief Device memory space descriptor
class zet_debug_memory_space_desc_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("type", zet_debug_memory_space_type_t), ## [in] type of memory space
("address", c_ulonglong) ## [in] the virtual address within the memory space
]
###############################################################################
## @brief Supported general register set flags.
class zet_debug_regset_flags_v(IntEnum):
READABLE = ZE_BIT(0) ## register set is readable
WRITEABLE = ZE_BIT(1) ## register set is writeable
class zet_debug_regset_flags_t(c_int):
def __str__(self):
return hex(self.value)
###############################################################################
## @brief Device register set properties queried using
## ::zetDebugGetRegisterSetProperties.
class zet_debug_regset_properties_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("type", c_ulong), ## [out] device-specific register set type
("version", c_ulong), ## [out] device-specific version of this register set
("generalFlags", zet_debug_regset_flags_t), ## [out] general register set flags
("deviceFlags", c_ulong), ## [out] device-specific register set flags
("count", c_ulong), ## [out] number of registers in the set
("bitSize", c_ulong), ## [out] the size of a register in bits
("byteSize", c_ulong) ## [out] the size required for reading or writing a register in bytes
]
###############################################################################
## @brief Maximum metric group name string size
ZET_MAX_METRIC_GROUP_NAME = 256
###############################################################################
## @brief Maximum metric group description string size
ZET_MAX_METRIC_GROUP_DESCRIPTION = 256
###############################################################################
## @brief Metric group sampling type
class zet_metric_group_sampling_type_flags_v(IntEnum):
EVENT_BASED = ZE_BIT(0) ## Event based sampling
TIME_BASED = ZE_BIT(1) ## Time based sampling
EXP_TRACER_BASED = ZE_BIT(2) ## Experimental Tracer based sampling
class zet_metric_group_sampling_type_flags_t(c_int):
def __str__(self):
return hex(self.value)
###############################################################################
## @brief Metric group properties queried using ::zetMetricGroupGetProperties
class zet_metric_group_properties_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("name", c_char * ZET_MAX_METRIC_GROUP_NAME), ## [out] metric group name
("description", c_char * ZET_MAX_METRIC_GROUP_DESCRIPTION), ## [out] metric group description
("samplingType", zet_metric_group_sampling_type_flags_t), ## [out] metric group sampling type.
## returns a combination of ::zet_metric_group_sampling_type_flag_t.
("domain", c_ulong), ## [out] metric group domain number. Cannot use multiple, simultaneous
## metric groups from the same domain.
("metricCount", c_ulong) ## [out] metric count belonging to this group
]
###############################################################################
## @brief Metric types
class zet_metric_type_v(IntEnum):
DURATION = 0 ## Metric type: duration
EVENT = 1 ## Metric type: event
EVENT_WITH_RANGE = 2 ## Metric type: event with range
THROUGHPUT = 3 ## Metric type: throughput
TIMESTAMP = 4 ## Metric type: timestamp
FLAG = 5 ## Metric type: flag
RATIO = 6 ## Metric type: ratio
RAW = 7 ## Metric type: raw
EVENT_EXP_TIMESTAMP = 0x7ffffff9 ## Metric type: event with only timestamp and value has no meaning
EVENT_EXP_START = 0x7ffffffa ## Metric type: the first event of a start/end event pair
EVENT_EXP_END = 0x7ffffffb ## Metric type: the second event of a start/end event pair
EVENT_EXP_MONOTONIC_WRAPS_VALUE = 0x7ffffffc ## Metric type: value of the event is a monotonically increasing value
## that can wrap around
EXP_EXPORT_DMA_BUF = 0x7ffffffd ## Metric which exports linux dma_buf, which could be imported/mapped to
## the host process
IP_EXP = 0x7ffffffe ## Metric type: instruction pointer. Deprecated, use
## ::ZET_METRIC_TYPE_IP.
IP = 0x7ffffffe ## Metric type: instruction pointer
class zet_metric_type_t(c_int):
def __str__(self):
return str(zet_metric_type_v(self.value))
###############################################################################
## @brief Metric group calculation type
class zet_metric_group_calculation_type_v(IntEnum):
METRIC_VALUES = 0 ## Calculated metric values from raw data.
MAX_METRIC_VALUES = 1 ## Maximum metric values.
class zet_metric_group_calculation_type_t(c_int):
def __str__(self):
return str(zet_metric_group_calculation_type_v(self.value))
###############################################################################
## @brief Maximum metric name string size
ZET_MAX_METRIC_NAME = 256
###############################################################################
## @brief Maximum metric description string size
ZET_MAX_METRIC_DESCRIPTION = 256
###############################################################################
## @brief Maximum metric component string size
ZET_MAX_METRIC_COMPONENT = 256
###############################################################################
## @brief Maximum metric result units string size
ZET_MAX_METRIC_RESULT_UNITS = 256
###############################################################################
## @brief Metric properties queried using ::zetMetricGetProperties
class zet_metric_properties_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("name", c_char * ZET_MAX_METRIC_NAME), ## [out] metric name
("description", c_char * ZET_MAX_METRIC_DESCRIPTION), ## [out] metric description
("component", c_char * ZET_MAX_METRIC_COMPONENT), ## [out] metric component
("tierNumber", c_ulong), ## [out] number of tier
("metricType", zet_metric_type_t), ## [out] metric type
("resultType", zet_value_type_t), ## [out] metric result type
("resultUnits", c_char * ZET_MAX_METRIC_RESULT_UNITS) ## [out] metric result units
]
###############################################################################
## @brief Metric streamer descriptor
class zet_metric_streamer_desc_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("notifyEveryNReports", c_ulong), ## [in,out] number of collected reports after which notification event
## will be signaled. If the requested value is not supported exactly,
## then the driver may use a value that is the closest supported
## approximation and shall update this member during ::zetMetricStreamerOpen.
("samplingPeriod", c_ulong) ## [in,out] streamer sampling period in nanoseconds. If the requested
## value is not supported exactly, then the driver may use a value that
## is the closest supported approximation and shall update this member
## during ::zetMetricStreamerOpen.
]
###############################################################################
## @brief Metric query pool types
class zet_metric_query_pool_type_v(IntEnum):
PERFORMANCE = 0 ## Performance metric query pool.
EXECUTION = 1 ## Skips workload execution between begin/end calls.
class zet_metric_query_pool_type_t(c_int):
def __str__(self):
return str(zet_metric_query_pool_type_v(self.value))
###############################################################################
## @brief Metric query pool description
class zet_metric_query_pool_desc_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("type", zet_metric_query_pool_type_t), ## [in] Query pool type.
("count", c_ulong) ## [in] Internal slots count within query pool object.
]
###############################################################################
## @brief Supportted profile features
class zet_profile_flags_v(IntEnum):
REGISTER_REALLOCATION = ZE_BIT(0) ## request the compiler attempt to minimize register usage as much as
## possible to allow for instrumentation
FREE_REGISTER_INFO = ZE_BIT(1) ## request the compiler generate free register info
class zet_profile_flags_t(c_int):
def __str__(self):
return hex(self.value)
###############################################################################
## @brief Profiling meta-data for instrumentation
class zet_profile_properties_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("flags", zet_profile_flags_t), ## [out] indicates which flags were enabled during compilation.
## returns 0 (none) or a combination of ::zet_profile_flag_t
("numTokens", c_ulong) ## [out] number of tokens immediately following this structure
]
###############################################################################
## @brief Supported profile token types
class zet_profile_token_type_v(IntEnum):
FREE_REGISTER = 0 ## GRF info
class zet_profile_token_type_t(c_int):
def __str__(self):
return str(zet_profile_token_type_v(self.value))
###############################################################################
## @brief Profile free register token detailing unused registers in the current
## function
class zet_profile_free_register_token_t(Structure):
_fields_ = [
("type", zet_profile_token_type_t), ## [out] type of token
("size", c_ulong), ## [out] total size of the token, in bytes
("count", c_ulong) ## [out] number of register sequences immediately following this
## structure
]
###############################################################################
## @brief Profile register sequence detailing consecutive bytes, all of which
## are unused
class zet_profile_register_sequence_t(Structure):
_fields_ = [
("start", c_ulong), ## [out] starting byte in the register table, representing the start of
## unused bytes in the current function
("count", c_ulong) ## [out] number of consecutive bytes in the sequence, starting from start
]
###############################################################################
## @brief API Tracing Experimental Extension Name
ZET_API_TRACING_EXP_NAME = "ZET_experimental_api_tracing"
###############################################################################
## @brief API Tracing Experimental Extension Version(s)
class zet_api_tracing_exp_version_v(IntEnum):
_1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0
CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version
class zet_api_tracing_exp_version_t(c_int):
def __str__(self):
return str(zet_api_tracing_exp_version_v(self.value))
###############################################################################
## @brief Alias the existing callbacks definition for 'core' callbacks
class zet_core_callbacks_t(ze_callbacks_t):
pass
###############################################################################
## @brief Tracer descriptor
class zet_tracer_exp_desc_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("pUserData", c_void_p) ## [in] pointer passed to every tracer's callbacks
]
###############################################################################
## @brief Concurrent Metric Groups Experimental Extension Name
ZET_CONCURRENT_METRIC_GROUPS_EXP_NAME = "ZET_experimental_concurrent_metric_groups"
###############################################################################
## @brief Concurrent Metric Groups Experimental Extension Version(s)
class zet_concurrent_metric_groups_exp_version_v(IntEnum):
_1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0
CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version
class zet_concurrent_metric_groups_exp_version_t(c_int):
def __str__(self):
return str(zet_concurrent_metric_groups_exp_version_v(self.value))
###############################################################################
## @brief Metric Tracer Experimental Extension Name
ZET_METRICS_TRACER_EXP_NAME = "ZET_experimental_metric_tracer"
###############################################################################
## @brief Metric Tracer Experimental Extension Version(s)
class zet_metric_tracer_exp_version_v(IntEnum):
_1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0
CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version
class zet_metric_tracer_exp_version_t(c_int):
def __str__(self):
return str(zet_metric_tracer_exp_version_v(self.value))
###############################################################################
## @brief Handle of metric tracer's object
class zet_metric_tracer_exp_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of metric decoder's object
class zet_metric_decoder_exp_handle_t(c_void_p):
pass
###############################################################################
## @brief Metric tracer descriptor
class zet_metric_tracer_exp_desc_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("notifyEveryNBytes", c_ulong) ## [in,out] number of collected bytes after which notification event will
## be signaled. If the requested value is not supported exactly, then the
## driver may use a value that is the closest supported approximation and
## shall update this member during ::zetMetricTracerCreateExp.
]
###############################################################################
## @brief Decoded metric entry
class zet_metric_entry_exp_t(Structure):
_fields_ = [
("value", zet_value_t), ## [out] value of the decodable metric entry or event. Number is
## meaningful based on the metric type.
("timeStamp", c_ulonglong), ## [out] timestamp at which the event happened.
("metricIndex", c_ulong), ## [out] index to the decodable metric handle in the input array
## (phMetric) in ::zetMetricTracerDecodeExp().
("onSubdevice", ze_bool_t), ## [out] True if the event occurred on a sub-device; false means the
## device on which the metric tracer was opened does not have
## sub-devices.
("subdeviceId", c_ulong) ## [out] If onSubdevice is true, this gives the ID of the sub-device.
]
###############################################################################
## @brief Metric group type
class zet_metric_group_type_exp_flags_v(IntEnum):
EXPORT_DMA_BUF = ZE_BIT(0) ## Metric group and metrics exports memory using linux dma-buf, which
## could be imported/mapped to the host process. Properties of the
## dma_buf could be queried using ::zet_export_dma_buf_exp_properties_t.
USER_CREATED = ZE_BIT(1) ## Metric group created using ::zetDeviceCreateMetricGroupsFromMetricsExp
OTHER = ZE_BIT(2) ## Metric group which has a collection of metrics
class zet_metric_group_type_exp_flags_t(c_int):
def __str__(self):
return hex(self.value)
###############################################################################
## @brief Query the metric group type using `pNext` of
## ::zet_metric_group_properties_t
class zet_metric_group_type_exp_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("type", zet_metric_group_type_exp_flags_t) ## [out] metric group type.
## returns a combination of ::zet_metric_group_type_exp_flags_t.
]
###############################################################################
## @brief Exported dma_buf properties queried using `pNext` of
## ::zet_metric_group_properties_t or ::zet_metric_properties_t
class zet_export_dma_buf_exp_properties_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("fd", c_int), ## [out] the file descriptor handle that could be used to import the
## memory by the host process.
("size", c_size_t) ## [out] size in bytes of the dma_buf
]
###############################################################################
## @brief Calculating Multiple Metrics Experimental Extension Name
ZET_MULTI_METRICS_EXP_NAME = "ZET_experimental_calculate_multiple_metrics"
###############################################################################
## @brief Calculating Multiple Metrics Experimental Extension Version(s)
class ze_calculate_multiple_metrics_exp_version_v(IntEnum):
_1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0
CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version
class ze_calculate_multiple_metrics_exp_version_t(c_int):
def __str__(self):
return str(ze_calculate_multiple_metrics_exp_version_v(self.value))
###############################################################################
## @brief Global Metric Timestamps Experimental Extension Name
ZET_GLOBAL_METRICS_TIMESTAMPS_EXP_NAME = "ZET_experimental_global_metric_timestamps"
###############################################################################
## @brief Global Metric Timestamps Experimental Extension Version(s)
class ze_metric_global_timestamps_exp_version_v(IntEnum):
_1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0
CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version
class ze_metric_global_timestamps_exp_version_t(c_int):
def __str__(self):
return str(ze_metric_global_timestamps_exp_version_v(self.value))
###############################################################################
## @brief Metric timestamps resolution
##
## @details
## - This structure may be returned from ::zetMetricGroupGetProperties via
## the `pNext` member of ::zet_metric_group_properties_t.
## - Used for mapping metric timestamps to other timers.
class zet_metric_global_timestamps_resolution_exp_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("timerResolution", c_ulonglong), ## [out] Returns the resolution of metrics timer (used for timestamps) in
## cycles/sec.
("timestampValidBits", c_ulonglong) ## [out] Returns the number of valid bits in the timestamp value.
]
###############################################################################
## @brief Exporting Metrics Data Experimental Extension Name
ZET_EXPORT_METRICS_DATA_EXP_NAME = "ZET_experimental_metric_export_data"
###############################################################################
## @brief Exporting Metrics Data Experimental Extension Version(s)
class zet_export_metric_data_exp_version_v(IntEnum):
_1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0
CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version
class zet_export_metric_data_exp_version_t(c_int):
def __str__(self):
return str(zet_export_metric_data_exp_version_v(self.value))
###############################################################################
## @brief Maximum count of characters in export data element name
ZET_MAX_METRIC_EXPORT_DATA_ELEMENT_NAME_EXP = 256
###############################################################################
## @brief Maximum export data element description string size
ZET_MAX_METRIC_EXPORT_DATA_ELEMENT_DESCRIPTION_EXP = 256
###############################################################################
## @brief Metrics calculation descriptor
class zet_metric_calculate_exp_desc_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("rawReportSkipCount", c_ulong) ## [in] number of reports to skip during calculation
]
###############################################################################
## @brief Programmable Metrics Experimental Extension Name
ZET_PROGRAMMABLE_METRICS_EXP_NAME = "ZET_experimental_programmable_metrics"
###############################################################################
## @brief Programmable Metrics Experimental Extension Version(s)
class zet_metric_programmable_exp_version_v(IntEnum):
_1_1 = ZE_MAKE_VERSION( 1, 1 ) ## version 1.1
CURRENT = ZE_MAKE_VERSION( 1, 1 ) ## latest known version
class zet_metric_programmable_exp_version_t(c_int):
def __str__(self):
return str(zet_metric_programmable_exp_version_v(self.value))
###############################################################################
## @brief Maximum count of characters in export data element name
ZET_MAX_PROGRAMMABLE_METRICS_ELEMENT_NAME_EXP = 256
###############################################################################
## @brief Maximum export data element description string size
ZET_MAX_PROGRAMMABLE_METRICS_ELEMENT_DESCRIPTION_EXP = 256
###############################################################################
## @brief Maximum count of characters in metric group name prefix
ZET_MAX_METRIC_GROUP_NAME_PREFIX_EXP = 64
###############################################################################
## @brief Maximum metric programmable name string size
ZET_MAX_METRIC_PROGRAMMABLE_NAME_EXP = 128
###############################################################################
## @brief Maximum metric programmable description string size
ZET_MAX_METRIC_PROGRAMMABLE_DESCRIPTION_EXP = 128
###############################################################################
## @brief Maximum metric programmable component string size
ZET_MAX_METRIC_PROGRAMMABLE_COMPONENT_EXP = 128
###############################################################################
## @brief Maximum metric programmable parameter string size
ZET_MAX_METRIC_PROGRAMMABLE_PARAMETER_NAME_EXP = 128
###############################################################################
## @brief Maximum value for programmable value description
ZET_MAX_METRIC_PROGRAMMABLE_VALUE_DESCRIPTION_EXP = 128
###############################################################################
## @brief Maximum value metric group name prefix
ZE_MAX_METRIC_GROUP_NAME_PREFIX = 64
###############################################################################
## @brief Handle of metric programmable's object
class zet_metric_programmable_exp_handle_t(c_void_p):
pass
###############################################################################
## @brief Metric Programmable properties queried using
## ::zetMetricProgrammableGetPropertiesExp
class zet_metric_programmable_exp_properties_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("name", c_char * ZET_MAX_METRIC_PROGRAMMABLE_NAME_EXP), ## [out] metric programmable name
("description", c_char * ZET_MAX_METRIC_PROGRAMMABLE_DESCRIPTION_EXP), ## [out] metric programmable description
("component", c_char * ZET_MAX_METRIC_PROGRAMMABLE_COMPONENT_EXP), ## [out] metric programmable component
("tierNumber", c_ulong), ## [out] tier number
("domain", c_ulong), ## [out] metric domain number.
("parameterCount", c_ulong), ## [out] number of parameters in the programmable
("samplingType", zet_metric_group_sampling_type_flags_t), ## [out] metric sampling type.
## returns a combination of ::zet_metric_group_sampling_type_flag_t.
("sourceId", c_ulong) ## [out] unique metric source identifier(within platform)to identify the
## HW block where the metric is collected.
]
###############################################################################
## @brief Metric Programmable Parameter types
class zet_metric_programmable_param_type_exp_v(IntEnum):
DISAGGREGATION = 0 ## Metric is disaggregated.
LATENCY = 1 ## Metric for latency measurement.
NORMALIZATION_UTILIZATION = 2 ## Produces normalization in percent using raw_metric * 100 / cycles / HW
## instance_count.
NORMALIZATION_AVERAGE = 3 ## Produces normalization using raw_metric / HW instance_count.
NORMALIZATION_RATE = 4 ## Produces normalization average using raw_metric / timestamp.
NORMALIZATION_BYTES = 5 ## Produces normalization average using raw_metric * n bytes.
GENERIC = 6 ## Generic Parameter type. Please refer the parameter's description.
class zet_metric_programmable_param_type_exp_t(c_int):
def __str__(self):
return str(zet_metric_programmable_param_type_exp_v(self.value))
###############################################################################
## @brief Supported value info types
class zet_value_info_type_exp_v(IntEnum):
UINT32 = 0 ## 32-bit unsigned-integer
UINT64 = 1 ## 64-bit unsigned-integer
FLOAT32 = 2 ## 32-bit floating-point
FLOAT64 = 3 ## 64-bit floating-point
BOOL8 = 4 ## 8-bit boolean
UINT8 = 5 ## 8-bit unsigned-integer
UINT16 = 6 ## 16-bit unsigned-integer
UINT64_RANGE = 7 ## 64-bit unsigned-integer range (minimum and maximum)
FLOAT64_RANGE = 8 ## 64-bit floating point range (minimum and maximum)
class zet_value_info_type_exp_t(c_int):
def __str__(self):
return str(zet_value_info_type_exp_v(self.value))
###############################################################################
## @brief Value info of type uint64_t range
class zet_value_uint64_range_exp_t(Structure):
_fields_ = [
("ui64Min", c_ulonglong), ## [out] minimum value of the range
("ui64Max", c_ulonglong) ## [out] maximum value of the range
]
###############################################################################
## @brief Value info of type float64 range
class zet_value_fp64_range_exp_t(Structure):
_fields_ = [
("fp64Min", c_double), ## [out] minimum value of the range
("fp64Max", c_double) ## [out] maximum value of the range
]
###############################################################################
## @brief Union of value information
class zet_value_info_exp_t(Structure):
_fields_ = [
("ui32", c_ulong), ## [out] 32-bit unsigned-integer
("ui64", c_ulonglong), ## [out] 64-bit unsigned-integer
("fp32", c_float), ## [out] 32-bit floating-point
("fp64", c_double), ## [out] 64-bit floating-point
("b8", ze_bool_t), ## [out] 8-bit boolean
("ui8", c_ubyte), ## [out] 8-bit unsigned integer
("ui16", c_ushort), ## [out] 16-bit unsigned integer
("ui64Range", zet_value_uint64_range_exp_t), ## [out] minimum and maximum value of the range
("fp64Range", zet_value_fp64_range_exp_t) ## [out] minimum and maximum value of the range
]
###############################################################################
## @brief Metric Programmable parameter information
class zet_metric_programmable_param_info_exp_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("type", zet_metric_programmable_param_type_exp_t), ## [out] programmable parameter type
("name", c_char * ZET_MAX_METRIC_PROGRAMMABLE_PARAMETER_NAME_EXP), ## [out] metric programmable parameter name
("valueInfoType", zet_value_info_type_exp_t), ## [out] value info type
("defaultValue", zet_value_t), ## [out] default value for the parameter
("valueInfoCount", c_ulong) ## [out] count of ::zet_metric_programmable_param_value_info_exp_t
]
###############################################################################
## @brief Metric Programmable parameter value information
class zet_metric_programmable_param_value_info_exp_t(Structure):
_fields_ = [
("stype", zet_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("valueInfo", zet_value_info_exp_t), ## [out] information about the parameter value
("description", c_char * ZET_MAX_METRIC_PROGRAMMABLE_VALUE_DESCRIPTION_EXP) ## [out] description about the value
]
###############################################################################
## @brief Metric Programmable parameter value
class zet_metric_programmable_param_value_exp_t(Structure):
_fields_ = [
("value", zet_value_t) ## [in] parameter value
]
###############################################################################
__use_win_types = "Windows" == platform.uname()[0]
###############################################################################
## @brief Function-pointer for zetMetricProgrammableGetExp
if __use_win_types:
_zetMetricProgrammableGetExp_t = WINFUNCTYPE( ze_result_t, zet_device_handle_t, POINTER(c_ulong), POINTER(zet_metric_programmable_exp_handle_t) )
else:
_zetMetricProgrammableGetExp_t = CFUNCTYPE( ze_result_t, zet_device_handle_t, POINTER(c_ulong), POINTER(zet_metric_programmable_exp_handle_t) )
###############################################################################
## @brief Function-pointer for zetMetricProgrammableGetPropertiesExp
if __use_win_types:
_zetMetricProgrammableGetPropertiesExp_t = WINFUNCTYPE( ze_result_t, zet_metric_programmable_exp_handle_t, POINTER(zet_metric_programmable_exp_properties_t) )
else:
_zetMetricProgrammableGetPropertiesExp_t = CFUNCTYPE( ze_result_t, zet_metric_programmable_exp_handle_t, POINTER(zet_metric_programmable_exp_properties_t) )
###############################################################################
## @brief Function-pointer for zetMetricProgrammableGetParamInfoExp
if __use_win_types:
_zetMetricProgrammableGetParamInfoExp_t = WINFUNCTYPE( ze_result_t, zet_metric_programmable_exp_handle_t, POINTER(c_ulong), POINTER(zet_metric_programmable_param_info_exp_t) )
else:
_zetMetricProgrammableGetParamInfoExp_t = CFUNCTYPE( ze_result_t, zet_metric_programmable_exp_handle_t, POINTER(c_ulong), POINTER(zet_metric_programmable_param_info_exp_t) )
###############################################################################
## @brief Function-pointer for zetMetricProgrammableGetParamValueInfoExp
if __use_win_types:
_zetMetricProgrammableGetParamValueInfoExp_t = WINFUNCTYPE( ze_result_t, zet_metric_programmable_exp_handle_t, c_ulong, POINTER(c_ulong), POINTER(zet_metric_programmable_param_value_info_exp_t) )
else:
_zetMetricProgrammableGetParamValueInfoExp_t = CFUNCTYPE( ze_result_t, zet_metric_programmable_exp_handle_t, c_ulong, POINTER(c_ulong), POINTER(zet_metric_programmable_param_value_info_exp_t) )
###############################################################################
## @brief Table of MetricProgrammableExp functions pointers
class _zet_metric_programmable_exp_dditable_t(Structure):
_fields_ = [
("pfnGetExp", c_void_p), ## _zetMetricProgrammableGetExp_t