MLIR: lib/Dialect/SPIRV/IR/GroupOps.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
15
18
20
22
23 template
25 spirv::Scope scope =
26 groupOp
28 OpTy::getExecutionScopeAttrName(groupOp->getName()))
29 .getValue();
30 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
32 "execution scope must be 'Workgroup' or 'Subgroup'");
33
34 GroupOperation operation =
35 groupOp
37 OpTy::getGroupOperationAttrName(groupOp->getName()))
38 .getValue();
39 if (operation == GroupOperation::ClusteredReduce &&
41 return groupOp->emitOpError("cluster size operand must be provided for "
42 "'ClusteredReduce' group operation");
45 int32_t clusterSize = 0;
46
47
50 "cluster size operand must come from a constant op");
51
52 if (!llvm::isPowerOf2_32(clusterSize))
54 "cluster size operand must be a power of two");
55 }
56 return success();
57 }
58
59
60
61
62
64 spirv::Scope scope = getExecutionScope();
65 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
66 return emitOpError("execution scope must be 'Workgroup' or 'Subgroup'");
67
68 if (auto localIdTy = llvm::dyn_cast(getLocalid().getType()))
69 if (localIdTy.getNumElements() != 2 && localIdTy.getNumElements() != 3)
70 return emitOpError("localid is a vector and can be with only "
71 " 2 or 3 components, actual number is ")
72 << localIdTy.getNumElements();
73
74 return success();
75 }
76
77
78
79
80
82 spirv::Scope scope = getExecutionScope();
83 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
84 return emitOpError("execution scope must be 'Workgroup' or 'Subgroup'");
85
86 return success();
87 }
88
89
90
91
92
94 spirv::Scope scope = getExecutionScope();
95 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
96 return emitOpError("execution scope must be 'Workgroup' or 'Subgroup'");
97
98 return success();
99 }
100
101
102
103
104
106 spirv::Scope scope = getExecutionScope();
107 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
108 return emitOpError("execution scope must be 'Workgroup' or 'Subgroup'");
109
110 return success();
111 }
112
113
114
115
116
118 spirv::Scope scope = getExecutionScope();
119 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
120 return emitOpError("execution scope must be 'Workgroup' or 'Subgroup'");
121
122
123
125 if (auto spirvModule = (*this)->getParentOfTypespirv::ModuleOp())
127
128 if (targetEnv.getVersion() < spirv::Version::V_1_5) {
129 auto *idOp = getId().getDefiningOp();
130 if (!idOp || !isa<spirv::ConstantOp,
131 spirv::ReferenceOfOp>(idOp))
132 return emitOpError("id must be the result of a constant op");
133 }
134
135 return success();
136 }
137
138
139
140
141
142 template
144 spirv::Scope scope = op.getExecutionScope();
145 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
146 return op.emitOpError("execution scope must be 'Workgroup' or 'Subgroup'");
147
148 if (op.getOperands().back().getType().isSignedInteger())
149 return op.emitOpError("second operand must be a singless/unsigned integer");
150
151 return success();
152 }
153
156 }
159 }
162 }
165 }
166
167
168
169
170
172 spirv::Scope scope = getExecutionScope();
173 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
174 return emitOpError("execution scope must be 'Workgroup' or 'Subgroup'");
175
176 return success();
177 }
178
179
180
181
182
184 return verifyGroupNonUniformArithmeticOp(*this);
185 }
186
187
188
189
190
192 return verifyGroupNonUniformArithmeticOp(*this);
193 }
194
195
196
197
198
200 return verifyGroupNonUniformArithmeticOp(*this);
201 }
202
203
204
205
206
208 return verifyGroupNonUniformArithmeticOp(*this);
209 }
210
211
212
213
214
216 return verifyGroupNonUniformArithmeticOp(*this);
217 }
218
219
220
221
222
224 return verifyGroupNonUniformArithmeticOp(*this);
225 }
226
227
228
229
230
232 return verifyGroupNonUniformArithmeticOp(*this);
233 }
234
235
236
237
238
240 return verifyGroupNonUniformArithmeticOp(*this);
241 }
242
243
244
245
246
248 return verifyGroupNonUniformArithmeticOp(*this);
249 }
250
251
252
253
254
256 return verifyGroupNonUniformArithmeticOp(*this);
257 }
258
259
260
261
262
264 return verifyGroupNonUniformArithmeticOp(*this);
265 }
266
267
268
269
270
272 return verifyGroupNonUniformArithmeticOp(*this);
273 }
274
275
276
277
278
280 return verifyGroupNonUniformArithmeticOp(*this);
281 }
282
283
284
285
286
288 return verifyGroupNonUniformArithmeticOp(*this);
289 }
290
291
292
293
294
296 return verifyGroupNonUniformArithmeticOp(*this);
297 }
298
299
300
301
302
304 return verifyGroupNonUniformArithmeticOp(*this);
305 }
306
307
308
309
310
312 spirv::Scope scope = getExecutionScope();
313 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
314 return emitOpError("execution scope must be 'Workgroup' or 'Subgroup'");
315
316 if (Value clusterSizeVal = getClusterSize()) {
318 int32_t clusterSize = 0;
319
321 return emitOpError("cluster size operand must come from a constant op");
322
323 if (!llvm::isPowerOf2_32(clusterSize))
324 return emitOpError("cluster size operand must be a power of two");
325 }
326
327 return success();
328 }
329
330
331
332
333
334 template
336 spirv::Scope scope = op.getExecutionScope();
337 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
338 return op.emitOpError("execution scope must be 'Workgroup' or 'Subgroup'");
339
340 return success();
341 }
342
344
346
348
350
352
354
356
358
360
362
363 }
static MLIRContext * getContext(OpFoldResult val)
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
This provides public APIs that all operations should have.
Operation is the basic unit of execution within MLIR.
Value getOperand(unsigned idx)
AttrClass getAttrOfType(StringAttr name)
unsigned getNumOperands()
OperationName getName()
The name of an operation is the key identifier for it.
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
static LogicalResult verifyGroupNonUniformArithmeticOp(Operation *groupOp)
TargetEnvAttr lookupTargetEnvOrDefault(Operation *op)
Queries the target environment recursively from enclosing symbol table ops containing the given op or...
static LogicalResult verifyGroupNonUniformShuffleOp(OpTy op)
static LogicalResult verifyGroupOp(Op op)
LogicalResult extractValueFromConstOp(Operation *op, int32_t &value)
TargetEnvAttr getDefaultTargetEnv(MLIRContext *context)
Returns the default target environment: SPIR-V 1.0 with Shader capability and no extra extensions.
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...