1
- // ===--- uArch.h ------------------------------------------------*- C++ -*-===//
1
+ // ===- uArch.h -- ------------------------------------------------*- C++ -*-===//
2
2
//
3
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
4
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,7 +34,7 @@ enum class InstructionScope { WorkItem, Subgroup, Workgroup, Cluster };
34
34
enum class InstructionKind {
35
35
DPAS, // Dot Product Accumulate Systolic (DPAS) is a matrix
36
36
// multiply-add operation
37
- // Add more instructions as needed
37
+ // @TODO: Add more instructions as needed
38
38
};
39
39
40
40
llvm::StringRef toString (InstructionKind name) {
@@ -51,24 +51,12 @@ std::optional<InstructionKind> parseInstructionKind(llvm::StringRef str) {
51
51
return std::nullopt ;
52
52
}
53
53
54
- // A struct to represent basic information about an instruction
55
- // This struct is used to represent the information about an instruction in the
56
- // uArch The information includes:
57
- // - the name of the instruction,
58
- // - the description of the instruction
59
- // - the scope of the instruction,
60
- //
61
- // The information is represented as strings
62
- // For example, the information about an instruction can be represented as:
63
- // Instruction instr = {"dpas", "Dot Product Accumulate Systolic (DPAS) is a
64
- // matrix multiply-add operation", "subgroup"};
65
-
54
+ // A struct to represent basic information about an instruction.
66
55
// The primary purpose of the Instruction struct is to provide a generic way to
67
56
// represent information about an instruction and to use this information to
68
57
// generate the uArch. Specifc instruction in a uArch can inherit from this
69
- // struct and add more fields as needed
58
+ // struct and add more fields as needed.
70
59
struct Instruction {
71
- // @TODO: Add more fields as needed
72
60
Instruction (InstructionKind kind, InstructionScope scope)
73
61
: instKind(kind), scope(scope) {}
74
62
@@ -79,8 +67,8 @@ struct Instruction {
79
67
80
68
protected:
81
69
InstructionKind instKind;
82
- std::string description;
83
70
InstructionScope scope;
71
+ // @TODO: Add more fields as needed
84
72
};
85
73
86
74
enum class RegisterFileMode : uint8_t { Small, Large };
@@ -89,16 +77,18 @@ enum class RegisterFileType : uint8_t { GRF, ARF };
89
77
// A struct to represent register file information
90
78
struct RegisterFileInfo {
91
79
// Constructor
92
- RegisterFileInfo () = default ;
93
80
RegisterFileInfo (uint32_t size,
94
81
const llvm::SmallVector<RegisterFileMode, 4 > &mode,
95
82
const llvm::SmallVector<uint32_t , 4 > &numRegs)
96
83
: size(size), mode(mode), numRegsPerThreadPerMode(numRegs) {}
97
84
85
+ // Get methods
98
86
uint32_t getSize () const { return size; }
87
+
99
88
const llvm::SmallVector<RegisterFileMode, 4 > &getModes () const {
100
89
return mode;
101
90
}
91
+
102
92
const llvm::SmallVector<uint32_t , 4 > &getNumRegsPerThreadPerMode () const {
103
93
return numRegsPerThreadPerMode;
104
94
}
@@ -137,25 +127,17 @@ struct CacheInfo {
137
127
};
138
128
139
129
// A struct to represent the uArch
140
- // This struct is used to represent the microarchitecture of a target device
141
- // The uArch includes:
142
- // - the name of the uArch,
143
- // - the description of the uArch,
144
- // - uArch hierarchy
145
- // - Register File information
146
- // - Cache information
147
- // - the set of instructions supported by the uArch,
130
+ // This struct is used to represent the microarchitecture of a target device.
148
131
struct uArch {
149
132
// Constructor
150
- uArch () = default ;
151
- uArch (const std::string &name, const std::string &description,
152
- const std::map<RegisterFileType, RegisterFileInfo> ®ister_file_info =
153
- {},
154
- const llvm::SmallVector<CacheInfo, 4 > &cache_info = {},
155
- const std::map<InstructionKind, std::shared_ptr<Instruction>>
156
- &instructions = {})
133
+ uArch (
134
+ const std::string &name, const std::string &description,
135
+ const std::map<RegisterFileType, RegisterFileInfo> ®isterFileInfo = {},
136
+ const llvm::SmallVector<CacheInfo, 4 > &cacheInfo = {},
137
+ const std::map<InstructionKind, std::shared_ptr<Instruction>>
138
+ &instructions = {})
157
139
: name(name), description(description),
158
- registerFileInfo (register_file_info ), cacheInfo(cache_info ),
140
+ registerFileInfo (registerFileInfo ), cacheInfo(cacheInfo ),
159
141
instructions(instructions) {}
160
142
161
143
// Get methods
@@ -193,11 +175,12 @@ struct uArch {
193
175
}
194
176
195
177
protected:
196
- std::string name; // Similar to target triple
178
+ std::string name; // Name of the uArch, similar to target triple
197
179
std::string description;
198
180
std::map<RegisterFileType, RegisterFileInfo> registerFileInfo;
199
181
llvm::SmallVector<CacheInfo, 4 > cacheInfo;
200
- std::map<InstructionKind, std::shared_ptr<Instruction>> instructions;
182
+ std::map<InstructionKind, std::shared_ptr<Instruction>>
183
+ instructions; // set of instructions supported by the uArch
201
184
};
202
185
203
186
// A struct to represent shared memory information
@@ -206,7 +189,7 @@ struct SharedMemory {
206
189
SharedMemory (uint32_t size, uint32_t alignment)
207
190
: size(size), alignment(alignment) {}
208
191
209
- // Getters
192
+ // Get methods
210
193
uint32_t getSize () const { return size; }
211
194
uint32_t getAlignment () const { return alignment; }
212
195
@@ -216,6 +199,19 @@ struct SharedMemory {
216
199
// @TODO: Add more fields as needed (e.g., latency, throughput, bandwidth)
217
200
};
218
201
202
+ struct XeCoreInfo {
203
+ uint32_t num_threads;
204
+ SharedMemory shared_memory;
205
+ uint32_t num_vector_units;
206
+ uint32_t num_matrix_units;
207
+
208
+ XeCoreInfo (uint32_t num_threads, const SharedMemory &shared_memory,
209
+ uint32_t num_vector_units, uint32_t num_matrix_units)
210
+ : num_threads(num_threads), shared_memory(shared_memory),
211
+ num_vector_units (num_vector_units), num_matrix_units(num_matrix_units) {
212
+ }
213
+ };
214
+
219
215
// ===----------------------------------------------------------------------===//
220
216
// Interfaces
221
217
// ===----------------------------------------------------------------------===//
0 commit comments