Yaxun Liu | a711cc7 | 2016-07-16 05:09:21 +0000 | [diff] [blame] | 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 | // |
| 10 | /// \file |
| 11 | /// |
| 12 | /// Enums and structure types used by runtime metadata. |
| 13 | /// |
| 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 byte stream in an ELF section of a |
| 17 | /// binary (code object). The byte stream consists of key-value pairs. |
| 18 | /// Each key is an 8 bit unsigned integer. Each value can be an integer, |
| 19 | /// a string, or a stream of key-value pairs. There are 3 levels of key-value |
| 20 | /// pair streams. At the beginning of the ELF section is the top level |
| 21 | /// key-value pair stream. A kernel-level key-value pair stream starts after |
| 22 | /// encountering KeyKernelBegin and ends immediately before encountering |
| 23 | /// KeyKernelEnd. A kernel-argument-level key-value pair stream starts |
| 24 | /// after encountering KeyArgBegin and ends immediately before encountering |
| 25 | /// KeyArgEnd. A kernel-level key-value pair stream can only appear in a top |
| 26 | /// level key-value pair stream. A kernel-argument-level key-value pair stream |
| 27 | /// can only appear in a kernel-level key-value pair stream. |
| 28 | /// |
| 29 | /// The format should be kept backward compatible. New enum values and bit |
| 30 | /// fields should be appended at the end. It is suggested to bump up the |
| 31 | /// revision number whenever the format changes and document the change |
| 32 | /// in the revision in this header. |
| 33 | /// |
| 34 | // |
| 35 | //===----------------------------------------------------------------------===// |
| 36 | // |
| 37 | #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H |
| 38 | #define LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H |
| 39 | |
| 40 | #include <stdint.h> |
| 41 | |
| 42 | namespace AMDGPU { |
| 43 | |
| 44 | namespace RuntimeMD { |
| 45 | |
| 46 | // Version and revision of runtime metadata |
| 47 | const unsigned char MDVersion = 1; |
| 48 | const unsigned char MDRevision = 0; |
| 49 | |
| 50 | // ELF section name containing runtime metadata |
| 51 | const char SectionName[] = ".AMDGPU.runtime_metadata"; |
| 52 | |
| 53 | // Enumeration values of keys in runtime metadata. |
| 54 | enum Key { |
| 55 | KeyNull = 0, // Place holder. Ignored when encountered |
| 56 | KeyMDVersion = 1, // Runtime metadata version |
| 57 | KeyLanguage = 2, // Language |
| 58 | KeyLanguageVersion = 3, // Language version |
| 59 | KeyKernelBegin = 4, // Beginning of kernel-level stream |
| 60 | KeyKernelEnd = 5, // End of kernel-level stream |
| 61 | KeyKernelName = 6, // Kernel name |
| 62 | KeyArgBegin = 7, // Beginning of kernel-arg-level stream |
| 63 | KeyArgEnd = 8, // End of kernel-arg-level stream |
| 64 | KeyArgSize = 9, // Kernel arg size |
| 65 | KeyArgAlign = 10, // Kernel arg alignment |
| 66 | KeyArgTypeName = 11, // Kernel type name |
| 67 | KeyArgName = 12, // Kernel name |
Yaxun Liu | 6389140 | 2016-09-07 17:44:00 +0000 | [diff] [blame] | 68 | KeyArgKind = 13, // Kernel argument kind |
Yaxun Liu | a711cc7 | 2016-07-16 05:09:21 +0000 | [diff] [blame] | 69 | KeyArgValueType = 14, // Kernel argument value type |
| 70 | KeyArgAddrQual = 15, // Kernel argument address qualifier |
| 71 | KeyArgAccQual = 16, // Kernel argument access qualifier |
| 72 | KeyArgIsConst = 17, // Kernel argument is const qualified |
| 73 | KeyArgIsRestrict = 18, // Kernel argument is restrict qualified |
| 74 | KeyArgIsVolatile = 19, // Kernel argument is volatile qualified |
| 75 | KeyArgIsPipe = 20, // Kernel argument is pipe qualified |
| 76 | KeyReqdWorkGroupSize = 21, // Required work group size |
| 77 | KeyWorkGroupSizeHint = 22, // Work group size hint |
| 78 | KeyVecTypeHint = 23, // Vector type hint |
| 79 | KeyKernelIndex = 24, // Kernel index for device enqueue |
Yaxun Liu | 6389140 | 2016-09-07 17:44:00 +0000 | [diff] [blame] | 80 | KeyMinWavesPerSIMD = 25, // Minimum number of waves per SIMD |
| 81 | KeyMaxWavesPerSIMD = 26, // Maximum number of waves per SIMD |
| 82 | KeyFlatWorkGroupSizeLimits = 27, // Flat work group size limits |
| 83 | KeyMaxWorkGroupSize = 28, // Maximum work group size |
| 84 | KeyNoPartialWorkGroups = 29, // No partial work groups |
| 85 | KeyPrintfInfo = 30, // Prinf function call information |
| 86 | KeyArgActualAcc = 31, // The actual kernel argument access qualifier |
Yaxun Liu | add05a8 | 2016-09-01 18:46:49 +0000 | [diff] [blame] | 87 | KeyArgPointeeAlign = 32, // Alignment of pointee type |
Yaxun Liu | a711cc7 | 2016-07-16 05:09:21 +0000 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | enum Language : uint8_t { |
| 91 | OpenCL_C = 0, |
| 92 | HCC = 1, |
| 93 | OpenMP = 2, |
| 94 | OpenCL_CPP = 3, |
| 95 | }; |
| 96 | |
| 97 | enum LanguageVersion : uint16_t { |
| 98 | V100 = 100, |
| 99 | V110 = 110, |
| 100 | V120 = 120, |
| 101 | V200 = 200, |
| 102 | V210 = 210, |
| 103 | }; |
| 104 | |
| 105 | namespace KernelArg { |
Yaxun Liu | 6389140 | 2016-09-07 17:44:00 +0000 | [diff] [blame] | 106 | enum Kind : uint8_t { |
| 107 | ByValue = 0, |
| 108 | GlobalBuffer = 1, |
| 109 | DynamicSharedPointer = 2, |
| 110 | Sampler = 3, |
| 111 | Image = 4, |
| 112 | Pipe = 5, |
| 113 | Queue = 6, |
| 114 | HiddenGlobalOffsetX = 7, |
| 115 | HiddenGlobalOffsetY = 8, |
| 116 | HiddenGlobalOffsetZ = 9, |
| 117 | HiddenNone = 10, |
| 118 | HiddenPrintfBuffer = 11, |
| 119 | HiddenDefaultQueue = 12, |
| 120 | HiddenCompletionAction = 13, |
Yaxun Liu | a711cc7 | 2016-07-16 05:09:21 +0000 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | enum ValueType : uint16_t { |
| 124 | Struct = 0, |
| 125 | I8 = 1, |
| 126 | U8 = 2, |
| 127 | I16 = 3, |
| 128 | U16 = 4, |
| 129 | F16 = 5, |
| 130 | I32 = 6, |
| 131 | U32 = 7, |
| 132 | F32 = 8, |
| 133 | I64 = 9, |
| 134 | U64 = 10, |
| 135 | F64 = 11, |
| 136 | }; |
| 137 | |
| 138 | enum AccessQualifer : uint8_t { |
| 139 | None = 0, |
| 140 | ReadOnly = 1, |
| 141 | WriteOnly = 2, |
| 142 | ReadWrite = 3, |
| 143 | }; |
Yaxun Liu | c7cbd72 | 2016-08-15 16:54:25 +0000 | [diff] [blame] | 144 | |
| 145 | enum AddressSpaceQualifer : uint8_t { |
| 146 | Private = 0, |
| 147 | Global = 1, |
| 148 | Constant = 2, |
| 149 | Local = 3, |
Yaxun Liu | 6389140 | 2016-09-07 17:44:00 +0000 | [diff] [blame] | 150 | Generic = 4, |
| 151 | Region = 5, |
Yaxun Liu | c7cbd72 | 2016-08-15 16:54:25 +0000 | [diff] [blame] | 152 | }; |
Yaxun Liu | a711cc7 | 2016-07-16 05:09:21 +0000 | [diff] [blame] | 153 | } // namespace KernelArg |
| 154 | } // namespace RuntimeMD |
| 155 | } // namespace AMDGPU |
| 156 | |
| 157 | #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H |