HIP: Heterogenous-computing Interface for Portability
AMDGPURuntimeMetadata.h
Go to the documentation of this file.
1 //===-- AMDGPURuntimeMetadata.h - AMDGPU Runtime Metadata -------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
29 //
30 //===----------------------------------------------------------------------===//
31 //
32 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H
33 #define LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H
34 
35 #include <cstdint>
36 #include <vector>
37 #include <string>
38 
39 namespace AMDGPU {
40 namespace RuntimeMD {
41 
42 // Version and revision of runtime metadata
43 const unsigned char MDVersion = 2;
44 const unsigned char MDRevision = 1;
45 
46 // Name of keys for runtime metadata.
47 namespace KeyName {
48 
49 // Runtime metadata version
50 const char MDVersion[] = "amd.MDVersion";
51 
52 // Instruction set architecture information
53 const char IsaInfo[] = "amd.IsaInfo";
54 // Wavefront size
55 const char IsaInfoWavefrontSize[] = "amd.IsaInfoWavefrontSize";
56 // Local memory size in bytes
57 const char IsaInfoLocalMemorySize[] = "amd.IsaInfoLocalMemorySize";
58 // Number of execution units per compute unit
59 const char IsaInfoEUsPerCU[] = "amd.IsaInfoEUsPerCU";
60 // Maximum number of waves per execution unit
61 const char IsaInfoMaxWavesPerEU[] = "amd.IsaInfoMaxWavesPerEU";
62 // Maximum flat work group size
63 const char IsaInfoMaxFlatWorkGroupSize[] = "amd.IsaInfoMaxFlatWorkGroupSize";
64 // SGPR allocation granularity
65 const char IsaInfoSGPRAllocGranule[] = "amd.IsaInfoSGPRAllocGranule";
66 // Total number of SGPRs
67 const char IsaInfoTotalNumSGPRs[] = "amd.IsaInfoTotalNumSGPRs";
68 // Addressable number of SGPRs
69 const char IsaInfoAddressableNumSGPRs[] = "amd.IsaInfoAddressableNumSGPRs";
70 // VGPR allocation granularity
71 const char IsaInfoVGPRAllocGranule[] = "amd.IsaInfoVGPRAllocGranule";
72 // Total number of VGPRs
73 const char IsaInfoTotalNumVGPRs[] = "amd.IsaInfoTotalNumVGPRs";
74 // Addressable number of VGPRs
75 const char IsaInfoAddressableNumVGPRs[] = "amd.IsaInfoAddressableNumVGPRs";
76 
77 // Language
78 const char Language[] = "amd.Language";
79 // Language version
80 const char LanguageVersion[] = "amd.LanguageVersion";
81 
82 // Kernels
83 const char Kernels[] = "amd.Kernels";
84 // Kernel name
85 const char KernelName[] = "amd.KernelName";
86 // Kernel arguments
87 const char Args[] = "amd.Args";
88 // Kernel argument size in bytes
89 const char ArgSize[] = "amd.ArgSize";
90 // Kernel argument alignment
91 const char ArgAlign[] = "amd.ArgAlign";
92 // Kernel argument type name
93 const char ArgTypeName[] = "amd.ArgTypeName";
94 // Kernel argument name
95 const char ArgName[] = "amd.ArgName";
96 // Kernel argument kind
97 const char ArgKind[] = "amd.ArgKind";
98 // Kernel argument value type
99 const char ArgValueType[] = "amd.ArgValueType";
100 // Kernel argument address qualifier
101 const char ArgAddrQual[] = "amd.ArgAddrQual";
102 // Kernel argument access qualifier
103 const char ArgAccQual[] = "amd.ArgAccQual";
104 // Kernel argument is const qualified
105 const char ArgIsConst[] = "amd.ArgIsConst";
106 // Kernel argument is restrict qualified
107 const char ArgIsRestrict[] = "amd.ArgIsRestrict";
108 // Kernel argument is volatile qualified
109 const char ArgIsVolatile[] = "amd.ArgIsVolatile";
110 // Kernel argument is pipe qualified
111 const char ArgIsPipe[] = "amd.ArgIsPipe";
112 // Required work group size
113 const char ReqdWorkGroupSize[] = "amd.ReqdWorkGroupSize";
114 // Work group size hint
115 const char WorkGroupSizeHint[] = "amd.WorkGroupSizeHint";
116 // Vector type hint
117 const char VecTypeHint[] = "amd.VecTypeHint";
118 // Kernel index for device enqueue
119 const char KernelIndex[] = "amd.KernelIndex";
120 // No partial work groups
121 const char NoPartialWorkGroups[] = "amd.NoPartialWorkGroups";
122 // Prinf function call information
123 const char PrintfInfo[] = "amd.PrintfInfo";
124 // The actual kernel argument access qualifier
125 const char ArgActualAcc[] = "amd.ArgActualAcc";
126 // Alignment of pointee type
127 const char ArgPointeeAlign[] = "amd.ArgPointeeAlign";
128 
129 } // end namespace KeyName
130 
131 namespace KernelArg {
132 
133 enum Kind : uint8_t {
134  ByValue = 0,
135  GlobalBuffer = 1,
136  DynamicSharedPointer = 2,
137  Sampler = 3,
138  Image = 4,
139  Pipe = 5,
140  Queue = 6,
141  HiddenGlobalOffsetX = 7,
142  HiddenGlobalOffsetY = 8,
143  HiddenGlobalOffsetZ = 9,
144  HiddenNone = 10,
145  HiddenPrintfBuffer = 11,
146  HiddenDefaultQueue = 12,
147  HiddenCompletionAction = 13,
148 };
149 
150 enum ValueType : uint16_t {
151  Struct = 0,
152  I8 = 1,
153  U8 = 2,
154  I16 = 3,
155  U16 = 4,
156  F16 = 5,
157  I32 = 6,
158  U32 = 7,
159  F32 = 8,
160  I64 = 9,
161  U64 = 10,
162  F64 = 11,
163 };
164 
165 // Avoid using 'None' since it conflicts with a macro in X11 header file.
166 enum AccessQualifer : uint8_t {
167  AccNone = 0,
168  ReadOnly = 1,
169  WriteOnly = 2,
170  ReadWrite = 3,
171 };
172 
173 enum AddressSpaceQualifer : uint8_t {
174  Private = 0,
175  Global = 1,
176  Constant = 2,
177  Local = 3,
178  Generic = 4,
179  Region = 5,
180 };
181 
182 } // end namespace KernelArg
183 
184 // Invalid values are used to indicate an optional key should not be emitted.
185 const uint8_t INVALID_ADDR_QUAL = 0xff;
186 const uint8_t INVALID_ACC_QUAL = 0xff;
187 const uint32_t INVALID_KERNEL_INDEX = ~0U;
188 
189 namespace KernelArg {
190 
191 // In-memory representation of kernel argument information.
192 struct Metadata {
193  uint32_t Size = 0;
194  uint32_t Align = 0;
195  uint32_t PointeeAlign = 0;
196  uint8_t Kind = 0;
197  uint16_t ValueType = 0;
198  std::string TypeName;
199  std::string Name;
200  uint8_t AddrQual = INVALID_ADDR_QUAL;
201  uint8_t AccQual = INVALID_ACC_QUAL;
202  uint8_t IsVolatile = 0;
203  uint8_t IsConst = 0;
204  uint8_t IsRestrict = 0;
205  uint8_t IsPipe = 0;
206 
207  Metadata() = default;
208 };
209 
210 } // end namespace KernelArg
211 
212 namespace Kernel {
213 
214 // In-memory representation of kernel information.
215 struct Metadata {
216  std::string Name;
217  std::string Language;
218  std::vector<uint8_t> LanguageVersion;
219  std::vector<uint32_t> ReqdWorkGroupSize;
220  std::vector<uint32_t> WorkGroupSizeHint;
221  std::string VecTypeHint;
222  uint32_t KernelIndex = INVALID_KERNEL_INDEX;
223  uint8_t NoPartialWorkGroups = 0;
224  std::vector<KernelArg::Metadata> Args;
225 
226  Metadata() = default;
227 };
228 
229 } // end namespace Kernel
230 
231 namespace IsaInfo {
232 
235 struct Metadata {
237  unsigned WavefrontSize = 0;
239  unsigned LocalMemorySize = 0;
241  unsigned EUsPerCU = 0;
243  unsigned MaxWavesPerEU = 0;
245  unsigned MaxFlatWorkGroupSize = 0;
247  unsigned SGPRAllocGranule = 0;
249  unsigned TotalNumSGPRs = 0;
251  unsigned AddressableNumSGPRs = 0;
253  unsigned VGPRAllocGranule = 0;
255  unsigned TotalNumVGPRs = 0;
257  unsigned AddressableNumVGPRs = 0;
258 
259  Metadata() = default;
260 };
261 
262 } // end namespace IsaInfo
263 
264 namespace Program {
265 
266 // In-memory representation of program information.
267 struct Metadata {
268  std::vector<uint8_t> MDVersionSeq;
269  IsaInfo::Metadata IsaInfo;
270  std::vector<std::string> PrintfInfo;
271  std::vector<Kernel::Metadata> Kernels;
272 
273  explicit Metadata() = default;
274 
275  // Construct from an YAML string.
276  explicit Metadata(const std::string& YAML);
277 
278  // Convert to YAML string.
279  std::string toYAML();
280 
281  // Convert from YAML string.
282  static Metadata fromYAML(const std::string& S);
283 };
284 
285 } // end namespace Program
286 
287 } // end namespace RuntimeMD
288 } // end namespace AMDGPU
289 
290 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H
Definition: AMDGPURuntimeMetadata.h:192
Definition: AMDGPURuntimeMetadata.h:267
In-memory representation of instruction set architecture information.
Definition: AMDGPURuntimeMetadata.h:235
Definition: AMDGPURuntimeMetadata.h:215
Definition: AMDGPUPTNote.h:20