Skip to content

Commit fa6c4bc

Browse files
committed
Address review comments.
1 parent 31b93d6 commit fa6c4bc

File tree

2 files changed

+41
-57
lines changed

2 files changed

+41
-57
lines changed

mlir/include/mlir/Dialect/XeGPU/uArch/IntelGpuXe2.h

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,17 @@ using namespace mlir::xegpu::uArch;
3131
namespace mlir {
3232
namespace xegpu {
3333
namespace uArch {
34-
struct XeCoreInfo {
35-
uint32_t num_threads;
36-
SharedMemory shared_memory;
37-
uint32_t num_vector_units;
38-
uint32_t num_matrix_units;
39-
40-
XeCoreInfo(uint32_t num_threads, const SharedMemory &shared_memory,
41-
uint32_t num_vector_units, uint32_t num_matrix_units)
42-
: num_threads(num_threads), shared_memory(shared_memory),
43-
num_vector_units(num_vector_units), num_matrix_units(num_matrix_units) {
44-
}
45-
};
4634

4735
struct Xe2Plus : public uArch {
48-
XeCoreInfo xe_core;
36+
XeCoreInfo xeCore;
4937
Xe2Plus(const std::string &archName, const std::string &archDescription,
5038
const XeCoreInfo &xeCore,
5139
const std::map<RegisterFileType, RegisterFileInfo> &regInfo = {},
5240
const llvm::SmallVector<CacheInfo, 4> &cacheInfo = {},
5341
const std::map<InstructionKind, std::shared_ptr<Instruction>>
5442
&instrs = {})
5543
: uArch(archName, archDescription, regInfo, cacheInfo, instrs),
56-
xe_core(xeCore) {}
44+
xeCore(xeCore) {}
5745
};
5846

5947
// struct to represent DPAS instruction
@@ -91,9 +79,9 @@ struct PVCuArch : public Xe2Plus {
9179
: Xe2Plus("pvc", // archName
9280
"Ponte Vecchio Architecture", // archDescription
9381
XeCoreInfo(8, SharedMemory(512 * 1024, 4), 8, 8), // xeCore
94-
{/* register_file_info */}, // Optional: empty
95-
{/* cache_info */}, // Optional: empty
96-
{/* instructions */} // Optional: empty
82+
{/* registerFileInfo */}, // Optional: empty
83+
{/* cacheInfo */}, // Optional: empty
84+
{/* instructions */} // Optional: empty
9785
) {
9886
// Intialize register file info
9987
// GRF
@@ -126,9 +114,9 @@ struct BMGuArch : public Xe2Plus {
126114
: Xe2Plus("bmg", // archName
127115
"Battlemage Architecture", // archDescription
128116
XeCoreInfo(8, SharedMemory(256 * 1024, 4), 8, 8), // xeCore
129-
{/* register_file_info */}, // Optional: empty
130-
{/* cache_info */}, // Optional: empty
131-
{/* instructions */} // Optional: empty)
117+
{/* registerFileInfo */}, // Optional: empty
118+
{/* cacheInfo */}, // Optional: empty
119+
{/* instructions */} // Optional: empty
132120
) {
133121
// Intialize register file info
134122
// GRF

mlir/include/mlir/Dialect/XeGPU/uArch/uArchBase.h

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- uArch.h ------------------------------------------------*- C++ -*-===//
1+
//===- uArch.h --------------------------------------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,7 +34,7 @@ enum class InstructionScope { WorkItem, Subgroup, Workgroup, Cluster };
3434
enum class InstructionKind {
3535
DPAS, // Dot Product Accumulate Systolic (DPAS) is a matrix
3636
// multiply-add operation
37-
// Add more instructions as needed
37+
// @TODO: Add more instructions as needed
3838
};
3939

4040
llvm::StringRef toString(InstructionKind name) {
@@ -51,24 +51,12 @@ std::optional<InstructionKind> parseInstructionKind(llvm::StringRef str) {
5151
return std::nullopt;
5252
}
5353

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.
6655
// The primary purpose of the Instruction struct is to provide a generic way to
6756
// represent information about an instruction and to use this information to
6857
// 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.
7059
struct Instruction {
71-
// @TODO: Add more fields as needed
7260
Instruction(InstructionKind kind, InstructionScope scope)
7361
: instKind(kind), scope(scope) {}
7462

@@ -79,8 +67,8 @@ struct Instruction {
7967

8068
protected:
8169
InstructionKind instKind;
82-
std::string description;
8370
InstructionScope scope;
71+
// @TODO: Add more fields as needed
8472
};
8573

8674
enum class RegisterFileMode : uint8_t { Small, Large };
@@ -89,16 +77,18 @@ enum class RegisterFileType : uint8_t { GRF, ARF };
8977
// A struct to represent register file information
9078
struct RegisterFileInfo {
9179
// Constructor
92-
RegisterFileInfo() = default;
9380
RegisterFileInfo(uint32_t size,
9481
const llvm::SmallVector<RegisterFileMode, 4> &mode,
9582
const llvm::SmallVector<uint32_t, 4> &numRegs)
9683
: size(size), mode(mode), numRegsPerThreadPerMode(numRegs) {}
9784

85+
// Get methods
9886
uint32_t getSize() const { return size; }
87+
9988
const llvm::SmallVector<RegisterFileMode, 4> &getModes() const {
10089
return mode;
10190
}
91+
10292
const llvm::SmallVector<uint32_t, 4> &getNumRegsPerThreadPerMode() const {
10393
return numRegsPerThreadPerMode;
10494
}
@@ -137,25 +127,17 @@ struct CacheInfo {
137127
};
138128

139129
// 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.
148131
struct uArch {
149132
// Constructor
150-
uArch() = default;
151-
uArch(const std::string &name, const std::string &description,
152-
const std::map<RegisterFileType, RegisterFileInfo> &register_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> &registerFileInfo = {},
136+
const llvm::SmallVector<CacheInfo, 4> &cacheInfo = {},
137+
const std::map<InstructionKind, std::shared_ptr<Instruction>>
138+
&instructions = {})
157139
: name(name), description(description),
158-
registerFileInfo(register_file_info), cacheInfo(cache_info),
140+
registerFileInfo(registerFileInfo), cacheInfo(cacheInfo),
159141
instructions(instructions) {}
160142

161143
// Get methods
@@ -193,11 +175,12 @@ struct uArch {
193175
}
194176

195177
protected:
196-
std::string name; // Similar to target triple
178+
std::string name; // Name of the uArch, similar to target triple
197179
std::string description;
198180
std::map<RegisterFileType, RegisterFileInfo> registerFileInfo;
199181
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
201184
};
202185

203186
// A struct to represent shared memory information
@@ -206,7 +189,7 @@ struct SharedMemory {
206189
SharedMemory(uint32_t size, uint32_t alignment)
207190
: size(size), alignment(alignment) {}
208191

209-
// Getters
192+
// Get methods
210193
uint32_t getSize() const { return size; }
211194
uint32_t getAlignment() const { return alignment; }
212195

@@ -216,6 +199,19 @@ struct SharedMemory {
216199
// @TODO: Add more fields as needed (e.g., latency, throughput, bandwidth)
217200
};
218201

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+
219215
//===----------------------------------------------------------------------===//
220216
// Interfaces
221217
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)