@@ -116,24 +116,21 @@ def DLTI_TargetSystemSpecAttr :
116
116
}];
117
117
let description = [{
118
118
A system specification describes the overall system containing
119
- multiple devices, with each device having a unique ID
119
+ multiple devices, with each device having a unique ID (string)
120
120
and its corresponding TargetDeviceSpec object.
121
121
122
122
Example:
123
123
dlti.target_system_spec =
124
- #dlti.target_device_spec<
125
- #dlti.dl_entry<"dlti.device_id", 0: ui32>,
126
- #dlti.dl_entry<"dlti.device_type", "CPU">>,
127
- #dlti.target_device_spec<
128
- #dlti.dl_entry<"dlti.device_id", 1: ui32>,
129
- #dlti.dl_entry<"dlti.device_type", "GPU">,
130
- #dlti.dl_entry<"dlti.max_vector_op_width", 64 : ui32>>,
131
- #dlti.target_device_spec<
132
- #dlti.dl_entry<"dlti.device_id", 2: ui32>,
133
- #dlti.dl_entry<"dlti.device_type", "XPU">>>
124
+ #dlti.target_system_spec<
125
+ "CPU": #dlti.target_device_spec<
126
+ #dlti.dl_entry<"dlti.L1_cache_size_in_bytes", 4096: ui32>>,
127
+ "GPU": #dlti.target_device_spec<
128
+ #dlti.dl_entry<"dlti.max_vector_op_width", 64 : ui32>>,
129
+ "XPU": #dlti.target_device_spec<
130
+ #dlti.dl_entry<"dlti.max_vector_op_width", 4096 : ui32>>>
134
131
}];
135
132
let parameters = (ins
136
- ArrayRefParameter<"TargetDeviceSpecInterface ", "">:$entries
133
+ ArrayRefParameter<"DeviceIDTargetDeviceSpecPair ", "">:$entries
137
134
);
138
135
let mnemonic = "target_system_spec";
139
136
let genVerifyDecl = 1;
@@ -142,15 +139,15 @@ def DLTI_TargetSystemSpecAttr :
142
139
/// Return the device specification that matches the given device ID
143
140
std::optional<TargetDeviceSpecInterface>
144
141
getDeviceSpecForDeviceID(
145
- TargetDeviceSpecInterface ::DeviceID deviceID);
142
+ TargetSystemSpecInterface ::DeviceID deviceID);
146
143
}];
147
144
let extraClassDefinition = [{
148
145
std::optional<TargetDeviceSpecInterface>
149
146
$cppClass::getDeviceSpecForDeviceID(
150
- TargetDeviceSpecInterface ::DeviceID deviceID) {
151
- for (TargetDeviceSpecInterface entry : getEntries()) {
152
- if (entry.getDeviceID() == deviceID)
153
- return entry;
147
+ TargetSystemSpecInterface ::DeviceID deviceID) {
148
+ for (const auto& entry : getEntries()) {
149
+ if (entry.first == deviceID)
150
+ return entry.second ;
154
151
}
155
152
return std::nullopt;
156
153
}
@@ -173,15 +170,12 @@ def DLTI_TargetDeviceSpecAttr :
173
170
}];
174
171
let description = [{
175
172
Each device specification describes a single device and its
176
- hardware properties. Each device specification must have a device_id
177
- and a device_type. In addition, the specification can contain any number
173
+ hardware properties. Each device specification can contain any number
178
174
of optional hardware properties (e.g., max_vector_op_width below).
179
175
180
176
Example:
181
177
#dlti.target_device_spec<
182
- #dlti.dl_entry<"dlti.device_id", 1: ui32>,
183
- #dlti.dl_entry<"dlti.device_type", "GPU">,
184
- #dlti.dl_entry<"dlti.max_vector_op_width", 64 : ui32>>
178
+ #dlti.dl_entry<"dlti.max_vector_op_width", 64 : ui32>>
185
179
}];
186
180
let parameters = (ins
187
181
ArrayRefParameter<"DataLayoutEntryInterface", "">:$entries
@@ -190,28 +184,12 @@ def DLTI_TargetDeviceSpecAttr :
190
184
let genVerifyDecl = 1;
191
185
let assemblyFormat = "`<` $entries `>`";
192
186
let extraClassDeclaration = [{
193
- /// Returns the device ID identifier.
194
- StringAttr getDeviceIDIdentifier();
195
-
196
- /// Returns the device type identifier.
197
- StringAttr getDeviceTypeIdentifier();
198
-
199
187
/// Returns max vector op width identifier.
200
188
StringAttr getMaxVectorOpWidthIdentifier();
201
189
202
190
/// Returns L1 cache size identifier
203
191
StringAttr getL1CacheSizeInBytesIdentifier();
204
192
205
- /// Returns the interface spec for device ID
206
- /// Since we verify that the spec contains device ID the function
207
- /// will return a valid spec.
208
- DataLayoutEntryInterface getSpecForDeviceID();
209
-
210
- /// Returns the interface spec for device type
211
- /// Since we verify that the spec contains device type the function
212
- /// will return a valid spec.
213
- DataLayoutEntryInterface getSpecForDeviceType();
214
-
215
193
/// Returns the interface spec for max vector op width
216
194
/// Since max vector op width is an optional property, this function will
217
195
/// return a valid spec if the property is defined, otherwise it
@@ -223,9 +201,6 @@ def DLTI_TargetDeviceSpecAttr :
223
201
/// return a valid spec if the property is defined, otherwise it
224
202
/// will return an empty spec.
225
203
DataLayoutEntryInterface getSpecForL1CacheSizeInBytes();
226
-
227
- /// Return the value of device ID
228
- TargetDeviceSpecInterface::DeviceID getDeviceID();
229
204
}];
230
205
}
231
206
0 commit comments