Debian Codegraph @

IGC/AdaptorOCL/ocl_igc_shared/gtpin/gtpin_driver_common_bti.h

raw
1 /*========================== begin_copyright_notice ============================
2
3 Copyright (C) 2019-2021 Intel Corporation
4
5 SPDX-License-Identifier: MIT
6
7 ============================= end_copyright_notice ===========================*/
8
9 #ifndef GPTIN_DRIVER_COMMON_BTI_H
10 #define GPTIN_DRIVER_COMMON_BTI_H
11
12 #include <stdint.h>
13
14 #include "gtpin_driver_common.h"
15
16
17 /************************************************************************/
18 /* Data Types */
19 /************************************************************************/
20 namespace gtpin
21 {
22 /*!
23 * GTPin <-> Driver Interface Changelog:
24 * 1. File reordering
25 */
26 static const uint8_t GTPIN_COMMON_BTI_INTERFACE_VERSION = 1;
27
28 #define GENERATE_SPECIFIC_VERSION(PLATFORM_INTERFACE_VERSION) ((GTPIN_COMMON_BTI_INTERFACE_VERSION << 8) | PLATFORM_INTERFACE_VERSION)
29
30 typedef struct command_buffer_handle_s* command_buffer_handle_t; /// driver's handle to the command buffer
31
32
33 /*!
34 * Resource addressing mode
35 */
36 typedef enum
37 {
38 GTPIN_BUFFER_BINDFULL, /// using binding table index
39 GTPIN_BUFFER_BINDLESS, /// using an offset to the surface table in a register
40 GTPIN_BUFFER_STATELESS, /// using an address to the resource in a register
41 } GTPIN_BUFFER_TYPE;
42
43
44 /*!
45 * The offest of the register in the GRF.
46 * e.g. r2.5(dw) will be represented as 2*256 + 5*4
47 */
48 typedef struct reg_desc_s
49 {
50 uint32_t reg_offset; /// the location of the register in the GRF (in bytes)
51 uint32_t size; /// size of the register in bytes
52 } reg_desc_t;
53
54
55 /*!
56 * Buffer's descriptor - could be:
57 * 1. BTI - binding table index (in bindfull buffer addressing)
58 * 2. register (in bindless / stateless buffer addressing)
59 */
60 typedef union buffer_desc_s
61 {
62 uint32_t BTI; /// Binding table index
63 reg_desc_t reg_desc;
64 } buffer_desc_t;
65
66
67 /*!
68 * kernel instrumentation parameters structure:
69 */
70 typedef struct instrument_params_s
71 {
72 GTPIN_KERNEL_TYPE kernel_type;
73 GTPIN_SIMD_WIDTH simd;
74 const uint8_t* orig_kernel_binary; /// the original kernel binary
75 uint32_t orig_kernel_size; /// size of the kernel binary in bytes
76
77 GTPIN_BUFFER_TYPE buffer_type;
78 buffer_desc_t buffer_desc;
79 uint64_t igc_hash_id;
80
81 char* kernel_name; /// the kernel name
82 const igc_info_t* igc_info; /// information form IGC
83
84 /// START Exists only from COMMON_SUPPORTED_FEATURE_SOURCELINE_MAPPING
85 const void* debug_data; /// debug data including the elf file
86 uint32_t debug_data_size; /// size of the elf file in bytes
87 /// End Exists only from COMMON_SUPPORTED_FEATURE_SOURCELINE_MAPPING
88 } instrument_params_in_t;
89
90
91 /*!
92 * kernel instrumented data structure:
93 */
94 typedef struct instrument_params_out_s
95 {
96 uint8_t* inst_kernel_binary; /// the instrumented binary
97 uint32_t inst_kernel_size; /// size in bytes on the instrumented binary
98 uint64_t kernel_id; /// GTPin's associated kernel id
99 } instrument_params_out_t;
100
101
102 /*!
103 * Allocate a buffer(resource) for GTPin
104 *
105 * @param[in] deviceHandle The handle to the device
106 * @param[in] size Size of the buffer to allocate
107 * @param[out] resource The handle to the created resource
108 */
109 typedef GTPIN_DI_STATUS(GTPIN_DRIVER_CALLCONV *BufferAllocateFPTR)(device_handle_t deviceHandle, uint32_t size, resource_handle_t* resource);
110
111
112 /*!
113 * Deallocate GTPin's buffer
114 *
115 * @param[in] deviceHandle The handle to the device
116 * @param[in] resource The handle to the resource
117 */
118 typedef GTPIN_DI_STATUS(GTPIN_DRIVER_CALLCONV *BufferDeallocateFPTR)(device_handle_t deviceHandle, resource_handle_t resource);
119
120 /*!
121 * Map GTPin's buffer to obtain the virtual address
122 *
123 * @param[in] deviceHandle The handle to the device
124 * @param[in] resource The handle to the resource
125 * @param[out] address The virtual address of the resource
126 */
127 typedef GTPIN_DI_STATUS(GTPIN_DRIVER_CALLCONV *BufferMapFPTR)(device_handle_t deviceHandle, resource_handle_t resource, uint8_t** address);
128
129 /*!
130 * UnMap GTPin's allocated buffer
131 *
132 * @param[in] deviceHandle The handle to the device
133 * @param[in] resource The handle to the resource
134 */
135 typedef GTPIN_DI_STATUS(GTPIN_DRIVER_CALLCONV *BufferUnMapFPTR)(device_handle_t deviceHandle, resource_handle_t resource);
136
137
138 /************************************************************************/
139 /* Services (GTPin -> Driver) */
140 /* The following functions are implemented by the driver */
141 /* and called by GTPin */
142 /************************************************************************/
143
144 typedef struct driver_services_s
145 {
146 BufferAllocateFPTR bufferAllocate; /// request the Driver to allocate a buffer
147 BufferDeallocateFPTR bufferDeallocate; /// request the Driver to de-allocate a buffer
148 BufferMapFPTR bufferMap; /// request the Driver to map a buffer
149 BufferUnMapFPTR bufferUnMap; /// request the Driver to unmap a buffer
150 } driver_services_t;
151
152 } /// namespace gtpin
153
154 #endif /// GPTIN_DRIVER_COMMON_BTI_H