File: gtpin_driver_common_bti.h

package info (click to toggle)
intel-graphics-compiler2 2.18.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 107,080 kB
  • sloc: cpp: 807,289; lisp: 287,855; ansic: 16,414; python: 4,004; yacc: 2,588; lex: 1,666; pascal: 313; sh: 186; makefile: 35
file content (143 lines) | stat: -rw-r--r-- 5,414 bytes parent folder | download
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
/*========================== begin_copyright_notice ============================

Copyright (C) 2019-2021 Intel Corporation

SPDX-License-Identifier: MIT

============================= end_copyright_notice ===========================*/

#ifndef GPTIN_DRIVER_COMMON_BTI_H
#define GPTIN_DRIVER_COMMON_BTI_H

#include <stdint.h>

#include "gtpin_driver_common.h"

/************************************************************************/
/* Data Types                                                           */
/************************************************************************/
namespace gtpin {
/*!
 * GTPin <-> Driver Interface Changelog:
 * 1. File reordering
 */
static const uint8_t GTPIN_COMMON_BTI_INTERFACE_VERSION = 1;

#define GENERATE_SPECIFIC_VERSION(PLATFORM_INTERFACE_VERSION)                                                          \
  ((GTPIN_COMMON_BTI_INTERFACE_VERSION << 8) | PLATFORM_INTERFACE_VERSION)

typedef struct command_buffer_handle_s *command_buffer_handle_t; /// driver's handle to the command buffer

/*!
 * Resource addressing mode
 */
typedef enum {
  GTPIN_BUFFER_BINDFULL,  /// using binding table index
  GTPIN_BUFFER_BINDLESS,  /// using an offset to the surface table in a register
  GTPIN_BUFFER_STATELESS, /// using an address to the resource in a register
} GTPIN_BUFFER_TYPE;

/*!
 * The offest of the register in the GRF.
 * e.g. r2.5(dw) will be represented as 2*256 + 5*4
 */
typedef struct reg_desc_s {
  uint32_t reg_offset; /// the location of the register in the GRF (in bytes)
  uint32_t size;       /// size of the register in bytes
} reg_desc_t;

/*!
 * Buffer's descriptor - could be:
 * 1. BTI - binding table index (in bindfull buffer addressing)
 * 2. register (in bindless / stateless buffer addressing)
 */
typedef union buffer_desc_s {
  uint32_t BTI; /// Binding table index
  reg_desc_t reg_desc;
} buffer_desc_t;

/*!
 * kernel instrumentation parameters structure:
 */
typedef struct instrument_params_s {
  GTPIN_KERNEL_TYPE kernel_type;
  GTPIN_SIMD_WIDTH simd;
  const uint8_t *orig_kernel_binary; /// the original kernel binary
  uint32_t orig_kernel_size;         /// size of the kernel binary in bytes

  GTPIN_BUFFER_TYPE buffer_type;
  buffer_desc_t buffer_desc;
  uint64_t igc_hash_id;

  char *kernel_name;          /// the kernel name
  const igc_info_t *igc_info; /// information form IGC

  /// START Exists only from COMMON_SUPPORTED_FEATURE_SOURCELINE_MAPPING
  const void *debug_data;   /// debug data including the elf file
  uint32_t debug_data_size; /// size of the elf file in bytes
                            /// End Exists only from COMMON_SUPPORTED_FEATURE_SOURCELINE_MAPPING
} instrument_params_in_t;

/*!
 * kernel instrumented data structure:
 */
typedef struct instrument_params_out_s {
  uint8_t *inst_kernel_binary; /// the instrumented binary
  uint32_t inst_kernel_size;   /// size in bytes on the instrumented binary
  uint64_t kernel_id;          /// GTPin's associated kernel id
} instrument_params_out_t;

/*!
 * Allocate a buffer(resource) for GTPin
 *
 * @param[in]  deviceHandle  The handle to the device
 * @param[in]  size          Size of the buffer to allocate
 * @param[out] resource      The handle to the created resource
 */
typedef GTPIN_DI_STATUS(GTPIN_DRIVER_CALLCONV *BufferAllocateFPTR)(device_handle_t deviceHandle, uint32_t size,
                                                                   resource_handle_t *resource);

/*!
 * Deallocate GTPin's buffer
 *
 * @param[in] deviceHandle   The handle to the device
 * @param[in] resource       The handle to the resource
 */
typedef GTPIN_DI_STATUS(GTPIN_DRIVER_CALLCONV *BufferDeallocateFPTR)(device_handle_t deviceHandle,
                                                                     resource_handle_t resource);

/*!
 * Map GTPin's buffer to obtain the virtual address
 *
 * @param[in]  deviceHandle  The handle to the device
 * @param[in]  resource      The handle to the resource
 * @param[out] address       The virtual address of the resource
 */
typedef GTPIN_DI_STATUS(GTPIN_DRIVER_CALLCONV *BufferMapFPTR)(device_handle_t deviceHandle, resource_handle_t resource,
                                                              uint8_t **address);

/*!
 * UnMap GTPin's allocated buffer
 *
 * @param[in] deviceHandle   The handle to the device
 * @param[in] resource       The handle to the resource
 */
typedef GTPIN_DI_STATUS(GTPIN_DRIVER_CALLCONV *BufferUnMapFPTR)(device_handle_t deviceHandle,
                                                                resource_handle_t resource);

/************************************************************************/
/* Services (GTPin -> Driver)                                           */
/* The following functions are implemented by the driver                */
/* and called by GTPin                                                  */
/************************************************************************/

typedef struct driver_services_s {
  BufferAllocateFPTR bufferAllocate;     /// request the Driver to allocate a buffer
  BufferDeallocateFPTR bufferDeallocate; /// request the Driver to de-allocate a buffer
  BufferMapFPTR bufferMap;               /// request the Driver to map a buffer
  BufferUnMapFPTR bufferUnMap;           /// request the Driver to unmap a buffer
} driver_services_t;

} // namespace gtpin

#endif /// GPTIN_DRIVER_COMMON_BTI_H