1 //===-- AMDGPURuntimeMetadata.h - AMDGPU Runtime Metadata -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 /// Enums and structure types used by runtime metadata.
14 /// Runtime requests certain information (metadata) about kernels to be able
15 /// to execute the kernels and answer the queries about the kernels.
16 /// The metadata is represented as a note element in the .note ELF section of a
17 /// binary (code object). The desc field of the note element is a YAML string
18 /// consisting of key-value pairs. Each key is a string. Each value can be
19 /// an integer, a string, or an YAML sequence. There are 3 levels of YAML maps.
20 /// At the beginning of the YAML string is the module level YAML map. A
21 /// kernel-level YAML map is in the amd.Kernels sequence. A
22 /// kernel-argument-level map is in the amd.Args sequence.
24 /// The format should be kept backward compatible. New enum values and bit
25 /// fields should be appended at the end. It is suggested to bump up the
26 /// revision number whenever the format changes and document the change
27 /// in the revision in this header.
30 //===----------------------------------------------------------------------===//
32 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H
33 #define LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H
43 // Version and revision of runtime metadata
44 const unsigned char MDVersion = 2;
45 const unsigned char MDRevision = 0;
47 // Name of keys for runtime metadata.
49 const char MDVersion[] = "amd.MDVersion"; // Runtime metadata version
50 const char Language[] = "amd.Language"; // Language
51 const char LanguageVersion[] = "amd.LanguageVersion"; // Language version
52 const char Kernels[] = "amd.Kernels"; // Kernels
53 const char KernelName[] = "amd.KernelName"; // Kernel name
54 const char Args[] = "amd.Args"; // Kernel arguments
55 const char ArgSize[] = "amd.ArgSize"; // Kernel arg size
56 const char ArgAlign[] = "amd.ArgAlign"; // Kernel arg alignment
57 const char ArgTypeName[] = "amd.ArgTypeName"; // Kernel type name
58 const char ArgName[] = "amd.ArgName"; // Kernel name
59 const char ArgKind[] = "amd.ArgKind"; // Kernel argument kind
60 const char ArgValueType[] = "amd.ArgValueType"; // Kernel argument value type
61 const char ArgAddrQual[] = "amd.ArgAddrQual"; // Kernel argument address qualifier
62 const char ArgAccQual[] = "amd.ArgAccQual"; // Kernel argument access qualifier
63 const char ArgIsConst[] = "amd.ArgIsConst"; // Kernel argument is const qualified
64 const char ArgIsRestrict[] = "amd.ArgIsRestrict"; // Kernel argument is restrict qualified
65 const char ArgIsVolatile[] = "amd.ArgIsVolatile"; // Kernel argument is volatile qualified
66 const char ArgIsPipe[] = "amd.ArgIsPipe"; // Kernel argument is pipe qualified
67 const char ReqdWorkGroupSize[] = "amd.ReqdWorkGroupSize"; // Required work group size
68 const char WorkGroupSizeHint[] = "amd.WorkGroupSizeHint"; // Work group size hint
69 const char VecTypeHint[] = "amd.VecTypeHint"; // Vector type hint
70 const char KernelIndex[] = "amd.KernelIndex"; // Kernel index for device enqueue
71 const char NoPartialWorkGroups[] = "amd.NoPartialWorkGroups"; // No partial work groups
72 const char PrintfInfo[] = "amd.PrintfInfo"; // Prinf function call information
73 const char ArgActualAcc[] = "amd.ArgActualAcc"; // The actual kernel argument access qualifier
74 const char ArgPointeeAlign[] = "amd.ArgPointeeAlign"; // Alignment of pointee type
81 DynamicSharedPointer = 2,
86 HiddenGlobalOffsetX = 7,
87 HiddenGlobalOffsetY = 8,
88 HiddenGlobalOffsetZ = 9,
90 HiddenPrintfBuffer = 11,
91 HiddenDefaultQueue = 12,
92 HiddenCompletionAction = 13,
95 enum ValueType : uint16_t {
110 // Avoid using 'None' since it conflicts with a macro in X11 header file.
111 enum AccessQualifer : uint8_t {
118 enum AddressSpaceQualifer : uint8_t {
126 } // namespace KernelArg
128 // Invalid values are used to indicate an optional key should not be emitted.
129 const uint8_t INVALID_ADDR_QUAL = 0xff;
130 const uint8_t INVALID_ACC_QUAL = 0xff;
131 const uint32_t INVALID_KERNEL_INDEX = ~0U;
133 namespace KernelArg {
134 // In-memory representation of kernel argument information.
138 uint32_t PointeeAlign;
141 std::string TypeName;
149 Metadata() : Size(0), Align(0), PointeeAlign(0), Kind(0), ValueType(0),
150 AddrQual(INVALID_ADDR_QUAL), AccQual(INVALID_ACC_QUAL), IsVolatile(0),
151 IsConst(0), IsRestrict(0), IsPipe(0) {}
156 // In-memory representation of kernel information.
159 std::string Language;
160 std::vector<uint8_t> LanguageVersion;
161 std::vector<uint32_t> ReqdWorkGroupSize;
162 std::vector<uint32_t> WorkGroupSizeHint;
163 std::string VecTypeHint;
164 uint32_t KernelIndex;
165 uint8_t NoPartialWorkGroups;
166 std::vector<KernelArg::Metadata> Args;
167 Metadata() : KernelIndex(INVALID_KERNEL_INDEX), NoPartialWorkGroups(0) {}
172 // In-memory representation of program information.
174 std::vector<uint8_t> MDVersionSeq;
175 std::vector<std::string> PrintfInfo;
176 std::vector<Kernel::Metadata> Kernels;
178 explicit Metadata(){}
180 // Construct from an YAML string.
181 explicit Metadata(const std::string &YAML);
183 // Convert to YAML string.
184 std::string toYAML();
186 // Convert from YAML string.
187 static Metadata fromYAML(const std::string &S);
190 } // namespace RuntimeMD
191 } // namespace AMDGPU
193 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H