27
27
namespace mlir {
28
28
namespace xegpu {
29
29
namespace uArch {
30
- // Architecture HW component hierarchy to present thread, core, socket ...
31
- struct uArchHierarchyComponent {
32
- std::string name = " " ; // optional name of the hierarchy component
33
- // no. of lower hierarchy component it contains, e.g., for PVC XeCore it
34
- // contains 8 threads, so no_of_component=8
35
- uint32_t no_of_component;
36
- // Constructor
37
- uArchHierarchyComponent (const std::string &name, uint32_t no_of_component)
38
- : name(name), no_of_component(no_of_component) {}
39
- };
40
30
41
31
// An enum class to represent the scope of an instruction
42
- enum class InstructionScopeEnum { WorkItem, Subgroup, Workgroup, Cluster };
32
+ enum class InstructionScope { WorkItem, Subgroup, Workgroup, Cluster };
33
+
34
+ enum class InstructionName {
35
+ DPAS, // Dot Product Accumulate Systolic (DPAS) is a matrix multiply-add
36
+ // operation
37
+ // Add more instructions as needed
38
+ };
43
39
44
40
// A struct to represent basic information about an instruction
45
41
// This struct is used to represent the information about an instruction in the
@@ -67,69 +63,62 @@ struct Instruction {
67
63
// Get methods
68
64
std::string getName () { return name; }
69
65
std::string getDescription () { return description; }
70
- InstructionScopeEnum getScope () { return scope; }
66
+ InstructionScope getScope () { return scope; }
71
67
72
68
protected:
73
69
std::string name;
74
70
std::string description;
75
- InstructionScopeEnum scope;
71
+ InstructionScope scope;
76
72
};
77
73
74
+ enum class RegisterFileMode : uint8_t { Small, Large };
75
+ enum class RegisterFileType : uint8_t { GRF, ARF };
76
+
78
77
// A struct to represent register file information
79
78
struct RegisterFileInfo {
80
79
// Constructor
81
80
RegisterFileInfo () = default ;
82
- RegisterFileInfo (uint32_t size, const std::vector<std::string> &mode,
83
- const std::vector<uint32_t > &numRegs, uint32_t num_banks,
84
- uint32_t bank_size)
85
- : size(size), mode(mode), num_regs_per_thread_per_mode(numRegs),
86
- num_banks (num_banks), bank_size(bank_size) {}
81
+ RegisterFileInfo (uint32_t size, const std::vector<RegisterFileMode> &mode,
82
+ const std::vector<uint32_t > &numRegs)
83
+ : size(size), mode(mode), numRegsPerThreadPerMode(numRegs) {}
87
84
88
- // Get methods
89
85
uint32_t getSize () const { return size; }
90
-
91
- const std::vector<std::string> &getModes () const { return mode; }
92
-
86
+ const std::vector<RegisterFileMode> &getModes () const { return mode; }
93
87
const std::vector<uint32_t > &getNumRegsPerThreadPerMode () const {
94
- return num_regs_per_thread_per_mode ;
88
+ return numRegsPerThreadPerMode ;
95
89
}
96
90
97
- uint32_t getNumBanks () const { return num_banks; }
98
-
99
- uint32_t getBankSize () const { return bank_size; }
100
-
101
91
protected:
102
- uint32_t size; // size per register in bits
103
- std::vector<std::string > mode; // e.g., "small", "large" GRF modes
92
+ uint32_t size; // size per register in bits
93
+ std::vector<RegisterFileMode > mode; // e.g., "small", "large" GRF modes
104
94
std::vector<uint32_t >
105
- num_regs_per_thread_per_mode ; // number of registers per thread per mode
106
- uint32_t num_banks;
107
- uint32_t bank_size;
95
+ numRegsPerThreadPerMode ; // number of registers per thread per mode
96
+ // TODO: Add more fields as needed (e.g., num_banks, bank_size, num_ports,
97
+ // port_width, bank_conflicts)
108
98
};
109
99
100
+ enum class CacheHierarchyLevel { L1 = 1 , L2 = 2 , L3 = 3 };
110
101
// A struct to represent cache information
111
-
112
102
struct CacheInfo {
113
103
// Constructor
114
104
CacheInfo (uint32_t size, uint32_t line_size,
115
- const uArchHierarchyComponent &component )
116
- : size(size), line_size(line_size), component(component ) {}
105
+ CacheHierarchyLevel hierarchy_level )
106
+ : size(size), line_size(line_size), hierarchy_level(hierarchy_level ) {}
117
107
118
108
virtual ~CacheInfo () = default ;
119
109
120
110
// Get methods
121
111
uint32_t getSize () const { return size; }
122
112
uint32_t getLineSize () const { return line_size; }
123
- const uArchHierarchyComponent & getComponent () const { return component ; }
113
+ CacheHierarchyLevel getHierarchyLevel () const { return hierarchy_level ; }
124
114
125
115
protected:
126
116
uint32_t size;
127
117
uint32_t line_size;
128
- // At which component level the cache is shared
129
- uArchHierarchyComponent component;
130
-
118
+ CacheHierarchyLevel hierarchy_level;
131
119
// @TODO: Add more fields as needed (e.g., associativity, num_banks,
132
- // bank_size, num_ports, port_width, bank_conflicts)
120
+ // bank_size, num_ports, port_width, bank_conflicts, hierarchy_level,
121
+ // latency, throughput, bandwidth)
133
122
};
134
123
135
124
// A struct to represent the uArch
@@ -145,29 +134,26 @@ struct uArch {
145
134
// Constructor
146
135
uArch () = default ;
147
136
uArch (const std::string &name, const std::string &description,
148
- const std::vector<uArchHierarchyComponent > &uArch_hierarchy = {},
149
- const std::map<std::string, RegisterFileInfo> ®ister_file_info = {},
137
+ const std::map<RegisterFileType, RegisterFileInfo > ®ister_file_info =
138
+ {},
150
139
const std::vector<CacheInfo> &cache_info = {},
151
140
const std::map<std::string, std::shared_ptr<Instruction>>
152
141
&instructions = {})
153
- : name(name), description(description), uArch_hierarchy(uArch_hierarchy),
154
- register_file_info (register_file_info), cache_info (cache_info),
142
+ : name(name), description(description),
143
+ registerFileInfo (register_file_info), cacheInfo (cache_info),
155
144
instructions(instructions) {}
156
145
157
146
// Get methods
158
147
const std::string &getName () const { return name; }
159
148
160
149
const std::string &getDescription () const { return description; }
161
150
162
- const std::vector<uArchHierarchyComponent> &getHierarchy () const {
163
- return uArch_hierarchy;
164
- }
165
-
166
- const std::map<std::string, RegisterFileInfo> &getRegisterFileInfo () const {
167
- return register_file_info;
151
+ const std::map<RegisterFileType, RegisterFileInfo> &
152
+ getRegisterFileInfo () const {
153
+ return registerFileInfo;
168
154
}
169
155
170
- const std::vector<CacheInfo> &getCacheInfo () const { return cache_info ; }
156
+ const std::vector<CacheInfo> &getCacheInfo () const { return cacheInfo ; }
171
157
172
158
const std::map<std::string, std::shared_ptr<Instruction>> &
173
159
getInstructions () const {
@@ -192,9 +178,8 @@ struct uArch {
192
178
protected:
193
179
std::string name; // Similar to target triple
194
180
std::string description;
195
- std::vector<uArchHierarchyComponent> uArch_hierarchy;
196
- std::map<std::string, RegisterFileInfo> register_file_info;
197
- std::vector<CacheInfo> cache_info;
181
+ std::map<RegisterFileType, RegisterFileInfo> registerFileInfo;
182
+ std::vector<CacheInfo> cacheInfo;
198
183
std::map<std::string, std::shared_ptr<Instruction>> instructions;
199
184
};
200
185
0 commit comments