MLIR 24.0.0git
ACCPartitionKernelLoops.cpp
Go to the documentation of this file.
1//===- ACCPartitionKernelLoops.cpp - Partition OpenACC parallel loops -----===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This pass strip-mines the parallel loops of an acc.compute_region so that
10// each resulting loop carries a single GPU dimension.
11//
12// Overview:
13// ---------
14// An scf.parallel loop in an acc.compute_region lists the GPU dimensions it
15// runs over in acc.par_dims, for example [block_x, thread_x] for a loop with
16// gang and vector parallelism. GPU lowering expects each loop to carry one
17// dimension, so this pass splits the loop accordingly. Each non-sequential
18// dimension becomes an outer loop over the launch width of that dimension (the
19// acc.par_width launch operand of the compute region). The original loop
20// becomes sequential and walks the iterations of one lane, such that adjacent
21// lanes of the innermost dimension execute adjacent iterations.
22//
23// Example:
24//
25// acc.compute_region launch(%w = %pw_x) {
26// scf.parallel (%i) = (%lb) to (%ub) step (%s) {
27// ...
28// } {acc.par_dims = #acc<par_dims[thread_x]>}
29// }
30//
31// becomes
32//
33// acc.compute_region launch(%w = %pw_x) {
34// scf.parallel (%t) = (%c0) to (%w) step (%c1) {
35// %off = arith.muli %t, %s
36// %lb2 = arith.addi %lb, %off
37// %s2 = arith.muli %s, %w
38// scf.parallel (%i) = (%lb2) to (%ub) step (%s2) {
39// ...
40// } {acc.par_dims = #acc<par_dims[sequential]>}
41// scf.reduce
42// } {acc.par_dims = #acc<par_dims[thread_x]>}
43// }
44//
45// Transformations:
46// ----------------
47// 1. Dimension strips: Each dimension in acc.par_dims, innermost first, adds
48// an outer loop as shown above. With [block_x, thread_x] the thread_x strip
49// is nested inside the block_x strip, so consecutive iterations go to
50// consecutive threads of a block and then to the next block.
51//
52// 2. Gang chunking: A block_x loop with gang(static:N) and no reductions gets
53// an additional sequential loop of width N, so gangs receive chunks of N
54// consecutive iterations in round-robin order.
55//
56// 3. Fully covered loops: A thread_x loop whose trip count equals the thread_x
57// width runs its body at most once per lane.
58//
59// 4. Reductions: An explicit reduction, written as acc.reduction_accumulate
60// after the loop, moves together with the ops that compute its operands
61// into the innermost strip after the sequential loop. Each lane then
62// accumulates its own partial result.
63//
64// Requirements:
65// -------------
66// 1. Each scf.parallel to partition has one induction variable (see
67// acc-loop-collapse) and a non-empty acc.par_dims. Other loops are reported
68// as not yet implemented and the pass fails.
69//
70// 2. The acc.compute_region has a single block, and its launch operands are
71// acc.par_width values that give the width of each dimension.
72//
73// 3. The pass uses the OpenACCSupport analysis for NYI (not yet implemented)
74// emission. Custom implementations can be registered via setImplementation()
75// to provide pipeline-specific handling.
76//
77//===----------------------------------------------------------------------===//
78
92#include "llvm/ADT/STLExtras.h"
93#include "llvm/ADT/SmallPtrSet.h"
94#include "llvm/Support/Debug.h"
95
96namespace mlir {
97namespace acc {
98#define GEN_PASS_DEF_ACCPARTITIONKERNELLOOPS
99#include "mlir/Dialect/OpenACC/Transforms/Passes.h.inc"
100} // namespace acc
101} // namespace mlir
102
103#define DEBUG_TYPE "acc-partition-kernel-loops"
104
105using namespace mlir;
106using namespace mlir::acc;
107
108namespace {
109static Operation *getOnlyUser(Value value) {
110 assert(value.hasOneUse() && "expected a single use");
111 return *value.getUsers().begin();
112}
113
114/// See through compute-region block arguments, acc.par_width, and index casts
115/// to the value that was passed into the region.
116static Value resolveRoot(Value value) {
117 while (value) {
118 value = stripIndexCasts(value);
119 if (auto blockArg = dyn_cast<BlockArgument>(value)) {
120 Value operand = getACCOperandForBlockArg(blockArg);
121 if (!operand)
122 break;
123 value = operand;
124 continue;
125 }
126 if (auto parWidth = value.getDefiningOp<ParWidthOp>()) {
127 value = parWidth.getLaunchArg();
128 continue;
129 }
130 break;
131 }
132 return value;
133}
134
135/// A normalized vector loop whose trip count equals its thread_x width runs
136/// the body once per lane.
137static bool loopFullyCoveredByThreadDim(scf::ParallelOp loop,
138 ComputeRegionOp computeRegion,
140 if (parDims.size() != 1 || !parDims[0].isThreadX())
141 return false;
142 if (!isConstantIntValue(stripIndexCasts(loop.getLowerBound()[0]), 0) ||
143 !isConstantIntValue(stripIndexCasts(loop.getStep()[0]), 1))
144 return false;
145 Value width = computeRegion.parDimToWidth(parDims[0]);
146 return isEqualConstantIntOrValue(resolveRoot(loop.getUpperBound()[0]),
147 resolveRoot(width));
148}
149
150/// Bounds of one induction variable. `ub` is exclusive.
151struct LoopRange {
152 Value lb;
153 Value ub;
154 Value step;
155};
156
157static LoopRange outerCoalescedStrip(IRRewriter &rewriter, Location loc,
158 LoopRange orig, Value stripIV,
159 Value stripWidth) {
160 Value step =
161 getValueOrCreateConstantIndexOp(rewriter, stripIV.getLoc(), orig.step);
162 Value lb =
163 getValueOrCreateConstantIndexOp(rewriter, stripIV.getLoc(), orig.lb);
164 Value newStep = arith::MulIOp::create(rewriter, loc, step, stripWidth);
165 Value bigStep = arith::MulIOp::create(rewriter, loc, stripIV, step);
166 Value newLB = arith::AddIOp::create(rewriter, loc, lb, bigStep);
167 return {newLB, orig.ub, newStep};
168}
169
170/// Runtime unrolling emits a trip-count division and a remainder loop in every
171/// thread, which only pays off when a lane runs many iterations.
172static void disableRuntimeUnroll(Operation *loop) {
173 // An annotation already on the loop states an intent, so leave it alone.
175 return;
176 MLIRContext *ctx = loop->getContext();
177 auto unroll = LLVM::LoopUnrollAttr::get(
178 ctx, /*disable=*/{}, /*count=*/{},
179 /*runtimeDisable=*/BoolAttr::get(ctx, true), /*full=*/{}, {}, {}, {});
180 auto annotation = LLVM::LoopAnnotationAttr::get(
181 ctx, /*id=*/{}, /*disableNonforced=*/{}, /*vectorize=*/{},
182 /*interleave=*/{}, /*unroll=*/unroll, /*unrollAndJam=*/{}, /*licm=*/{},
183 /*distribute=*/{}, /*pipeline=*/{}, /*peeled=*/{}, /*unswitch=*/{},
184 /*mustProgress=*/{}, /*isVectorized=*/{}, /*align=*/{}, /*startLoc=*/{},
185 /*endLoc=*/{}, /*parallelAccesses=*/{});
187}
188
189/// Chunk size of a gang(static:N) loop, or 1 when the loop is not chunked.
190/// A missing, zero, negative, or unit chunk means 1.
191static int64_t getGangChunkSize(scf::ParallelOp loop,
193 if (!llvm::any_of(parDims,
194 [](GPUParallelDimAttr dim) { return dim.isBlockX(); }))
195 return 1;
196 std::optional<int64_t> chunk = getChunkSize(loop);
197 if (!chunk || *chunk <= 1)
198 return 1;
199
200 // Chunking is not yet combined with reductions.
201 bool hasReduction = loop->getNumResults() > 0;
202 loop.getBody()->walk([&](Operation *op) {
203 if (isa<ReductionAccumulateOp, ReductionCombineOp, ReductionInitOp>(op))
204 hasReduction = true;
205 });
206 // Explicit reductions are accumulated by ops that follow the loop, up to the
207 // next op with a region. Do not look past that, so a sibling loop's
208 // reduction does not disable chunking for this loop.
209 for (auto it = std::next(Block::iterator(loop));
210 it != loop->getBlock()->end(); ++it) {
211 if (it->getNumRegions() > 0)
212 break;
213 if (isa<ReductionAccumulateOp>(*it)) {
214 hasReduction = true;
215 break;
216 }
217 }
218 if (hasReduction) {
219 LLVM_DEBUG(llvm::dbgs()
220 << "gang chunk size ignored: loop has reductions\n");
221 return 1;
222 }
223 return *chunk;
224}
225
226class ACCPartitionKernelLoops
227 : public acc::impl::ACCPartitionKernelLoopsBase<ACCPartitionKernelLoops> {
228 using ACCPartitionKernelLoopsBase<
229 ACCPartitionKernelLoops>::ACCPartitionKernelLoopsBase;
230
231 static LoopRange getLoopRange(scf::ParallelOp parOp, int ivIdx) {
232 return {parOp.getLowerBound()[ivIdx], parOp.getUpperBound()[ivIdx],
233 parOp.getStep()[ivIdx]};
234 }
235
236 static void setLoopRange(IRRewriter &rewriter, scf::ParallelOp parLoop,
237 int ivIdx, LoopRange range) {
238 rewriter.modifyOpInPlace(parLoop, [&]() {
239 parLoop.getLowerBoundMutable()[ivIdx].assign(
240 getValueOrCreateConstantIndexOp(rewriter, parLoop->getLoc(),
241 range.lb));
242 parLoop.getUpperBoundMutable()[ivIdx].assign(
243 getValueOrCreateConstantIndexOp(rewriter, parLoop->getLoc(),
244 range.ub));
245 parLoop.getStepMutable()[ivIdx].assign(getValueOrCreateConstantIndexOp(
246 rewriter, parLoop->getLoc(), range.step));
247 });
248 }
249
250 LogicalResult partitionParallelOp(IRRewriter &rewriter,
251 OpenACCSupport &accSupport,
252 ComputeRegionOp computeRegion,
253 scf::ParallelOp parallelOp);
254
255 void runOnOperation() override;
256};
257
258LogicalResult ACCPartitionKernelLoops::partitionParallelOp(
259 IRRewriter &rewriter, OpenACCSupport &accSupport,
260 ComputeRegionOp computeRegion, scf::ParallelOp parallelOp) {
261 GPUParallelDimsAttr parDimsAttr = getParDimsAttr(parallelOp);
262 LLVM_DEBUG(llvm::dbgs() << "partitionParallelOp: " << parallelOp << "\n"
263 << "parDimsAttr: " << parDimsAttr << "\n");
264
265 if (parallelOp.getInductionVars().size() != 1) {
266 accSupport.emitNYI(parallelOp.getLoc(),
267 "partition of an uncollapsed parallel loop");
268 return failure();
269 }
270 if (!parDimsAttr || parDimsAttr.getArray().empty()) {
271 accSupport.emitNYI(parallelOp.getLoc(),
272 "partition of a loop with no parallel dimension");
273 return failure();
274 }
275 ArrayRef<GPUParallelDimAttr> parDims = parDimsAttr.getArray();
276
277 Block *parentBlock = parallelOp->getBlock();
278 Block::iterator blockIter = std::next(Block::iterator(parallelOp));
279
280 GPUParallelDimAttr innerParDim = GPUParallelDimAttr::seqDim(&getContext());
281 scf::ParallelOp seqLoop = parallelOp;
282 LoopRange newLoopRange = getLoopRange(seqLoop, 0);
283
284 bool loopTCEqualToBlockWidth =
285 loopFullyCoveredByThreadDim(parallelOp, computeRegion, parDims);
286 bool isStridedLoop = false;
287 // Grid sized from this loop's trip count: at most one iteration per lane
288 // unless the grid cap binds at runtime. The launch planner writes the
289 // marker only in that case.
290 bool gridCoversTripCount = hasGridCoversTripCountAttr(seqLoop);
292
293 Location loc = parallelOp.getLoc();
294
295 // gang(static:N): iterations are divided into chunks of N, assigned to gangs
296 // round-robin. The chunk loop is the first strip, so it has stride 1.
297 int64_t chunkSize = getGangChunkSize(seqLoop, parDims);
298 if (chunkSize > 1) {
299 rewriter.setInsertionPoint(parallelOp);
300 Value zero = arith::ConstantIndexOp::create(rewriter, loc, 0);
301 Value one = arith::ConstantIndexOp::create(rewriter, loc, 1);
302 Value chunkWidth = arith::ConstantIndexOp::create(rewriter, loc, chunkSize);
303 scf::ParallelOp chunkLoop =
304 scf::ParallelOp::create(rewriter, loc, ValueRange{zero},
305 ValueRange{chunkWidth}, ValueRange{one});
306 rewriter.moveOpBefore(parallelOp, chunkLoop.getBody(),
307 chunkLoop.getBody()->begin());
308
309 rewriter.setInsertionPoint(seqLoop);
310 newLoopRange =
311 outerCoalescedStrip(rewriter, loc, newLoopRange,
312 chunkLoop.getInductionVars()[0], chunkWidth);
313
314 auto seqAttr = GPUParallelDimsAttr::get(&getContext(), {innerParDim});
315 setParDimsAttr(chunkLoop, seqAttr);
316 updateParDimsAttr(seqLoop, seqAttr);
317
318 parallelOp = chunkLoop;
319 isStridedLoop = true;
320 gridCoversTripCount = false;
321 }
322
323 for (GPUParallelDimAttr parDim : llvm::reverse(parDims)) {
324 if (parDim.isSeq())
325 continue;
326
327 rewriter.setInsertionPoint(parallelOp);
328 Value one = arith::ConstantIndexOp::create(rewriter, loc, 1);
329 Value zero = arith::ConstantIndexOp::create(rewriter, loc, 0);
330
331 if (parDim.isThreadX() || parDim.isThreadY()) {
332 bool hasNestedAccumulate = false;
333 parallelOp.getBody()->walk([&](Operation *op) {
334 if (auto accumulate = dyn_cast<ReductionAccumulateOp>(op)) {
335 for (GPUParallelDimAttr dim : accumulate.getParDims().getArray()) {
336 if (dim.isThreadX() || dim.isThreadY())
337 hasNestedAccumulate = true;
338 }
339 }
340 if (isa<ReductionCombineOp, ReductionInitOp>(op)) {
341 for (Operation *ancestor = op->getParentOp(); ancestor;
342 ancestor = ancestor->getParentOp()) {
343 if (auto par = dyn_cast<scf::ParallelOp>(ancestor)) {
344 if (GPUParallelDimsAttr pd = getParDimsAttr(par)) {
345 for (GPUParallelDimAttr dim : pd.getArray()) {
346 if (dim.isThreadX() || dim.isThreadY()) {
347 hasNestedAccumulate = true;
348 return WalkResult::interrupt();
349 }
350 }
351 }
352 break;
353 }
354 }
355 }
356 return hasNestedAccumulate ? WalkResult::interrupt()
358 });
359 if (hasNestedAccumulate) {
360 Value ub = parallelOp.getUpperBound()[0];
361 Value lb = parallelOp.getLowerBound()[0];
362 if (auto ubConst = ub.getDefiningOp<arith::ConstantIndexOp>()) {
363 if (auto lbConst = lb.getDefiningOp<arith::ConstantIndexOp>()) {
364 int64_t tripCount = ubConst.value() - lbConst.value();
365 for (Value launchArg : computeRegion.getLaunchArgs()) {
366 auto parWidth = launchArg.getDefiningOp<ParWidthOp>();
367 if (!parWidth || parWidth.getParDim() != parDim)
368 continue;
369 // Leave an explicit width of 1, such as num_workers(1), alone.
370 if (std::optional<int64_t> width =
371 getConstantIntValue(parWidth.getLaunchArg())) {
372 if (*width == 1)
373 continue;
374 }
375 rewriter.setInsertionPoint(parWidth);
377 rewriter, parWidth.getLoc(), tripCount);
378 rewriter.modifyOpInPlace(parWidth, [&]() {
379 parWidth.getLaunchArgMutable().assign(clamped);
380 });
381 rewriter.setInsertionPoint(parallelOp);
382 break;
383 }
384 }
385 }
386 }
387 }
388
389 Value width = computeRegion.parDimToWidth(parDim);
390 scf::ParallelOp outerStripLoop = scf::ParallelOp::create(
391 rewriter, loc, ValueRange{zero}, ValueRange{width}, ValueRange{one});
392 isStridedLoop = true;
393 rewriter.moveOpBefore(parallelOp, outerStripLoop.getBody(),
394 outerStripLoop.getBody()->begin());
395
396 rewriter.setInsertionPoint(seqLoop);
397 newLoopRange =
398 outerCoalescedStrip(rewriter, loc, newLoopRange,
399 outerStripLoop.getInductionVars()[0], width);
400
401 if (seqLoop->getNumResults()) {
402 for (Value result : parallelOp.getResults()) {
403 if (result.use_empty())
404 continue;
405 rewriter.moveOpBefore(getOnlyUser(result), parallelOp->getBlock(),
406 std::prev(parallelOp->getBlock()->end()));
407 }
408 } else {
409 // Move accumulate ops that are not linked through a loop result.
410 // The trailing ops are those after the loop, up to the next op with a
411 // region, in block order.
413 while (blockIter != parentBlock->end()) {
414 if (blockIter->getNumRegions() > 0)
415 break;
416 trailing.push_back(&*blockIter);
417 blockIter = std::next(blockIter);
418 }
419 llvm::SmallPtrSet<Operation *, 16> trailingSet(trailing.begin(),
420 trailing.end());
421
422 // An accumulate may read its value and memref through ops that also sit
423 // after the loop, such as a cast or a load of the memref. Those ops must
424 // move with the accumulate, or the moved ops would use values defined
425 // after the loop.
428 for (Operation *op : trailing) {
429 if (isa<ReductionAccumulateOp>(op)) {
430 opsToMove.insert(op);
431 worklist.push_back(op);
432 }
433 }
434 while (!worklist.empty()) {
435 Operation *op = worklist.pop_back_val();
436 for (Value operand : op->getOperands()) {
437 Operation *def = operand.getDefiningOp();
438 if (def && trailingSet.contains(def) && opsToMove.insert(def).second)
439 worklist.push_back(def);
440 }
441 }
442 // A moved op must have no user left behind after the loop, since that
443 // user would then be dominated by a value that moved into the loop.
444 for (Operation *op : opsToMove) {
445 if (isa<ReductionAccumulateOp>(op))
446 continue;
447 for (Operation *user : op->getUsers()) {
448 if (!opsToMove.contains(user)) {
449 accSupport.emitNYI(op->getLoc(),
450 "reduction: accumulate operand is also used "
451 "after the loop");
452 return failure();
453 }
454 }
455 }
456 // Move in block order so each op lands after its operands.
457 for (Operation *op : trailing) {
458 if (opsToMove.contains(op))
459 rewriter.moveOpBefore(op, parallelOp->getBlock(),
460 std::prev(parallelOp->getBlock()->end()));
461 }
462 }
463
464 setParDimsAttr(outerStripLoop,
465 GPUParallelDimsAttr::get(&getContext(), {parDim}));
466 updateParDimsAttr(parallelOp,
467 GPUParallelDimsAttr::get(&getContext(), {innerParDim}));
468 innerParDim = parDim;
469 parallelOp = outerStripLoop;
470 }
471
472 rewriter.setInsertionPoint(seqLoop);
473 // A fully covered loop steps by its upper bound, so it runs at most once
474 // per lane.
475 if (loopTCEqualToBlockWidth)
476 newLoopRange.step = newLoopRange.ub;
477 setLoopRange(rewriter, seqLoop, 0, newLoopRange);
478
479 if (isStridedLoop && !loopTCEqualToBlockWidth && gridCoversTripCount)
480 disableRuntimeUnroll(seqLoop);
481
482 LLVM_DEBUG(llvm::dbgs() << "partitioned-loop: " << parallelOp);
483 return success();
484}
485
486void ACCPartitionKernelLoops::runOnOperation() {
487 OpenACCSupport &accSupport = getAnalysis<OpenACCSupport>();
488 IRRewriter rewriter(&getContext());
489 getOperation()->walk([&](ComputeRegionOp computeRegion) {
490 if (computeRegion.getRegion().getBlocks().size() > 1) {
491 accSupport.emitNYI(computeRegion.getLoc(),
492 "multiple blocks in acc.compute_region");
493 signalPassFailure();
494 return;
495 }
496 bool fromKernels =
497 computeRegion.getOrigin() == KernelsOp::getOperationName();
498 for (Block &block : computeRegion.getRegion()) {
500 block.walk([&](Operation *op) {
501 if (auto parallelOp = dyn_cast<scf::ParallelOp>(op)) {
502 worklist.push_back(parallelOp);
503 return WalkResult::skip();
504 }
505 // An acc.kernels region keeps walking into nested regions. An
506 // acc.parallel region stops at the first region-bearing op. The walk
507 // is post-order, so loops already visited inside that op stay in the
508 // worklist.
509 return fromKernels ? WalkResult::advance() : WalkResult::skip();
510 });
511 for (scf::ParallelOp parallelOp : worklist) {
512 if (failed(partitionParallelOp(rewriter, accSupport, computeRegion,
513 parallelOp)))
514 signalPassFailure();
515 }
516 }
517 });
518}
519} // namespace
return success()
b getContext())
Block represents an ordered list of Operations.
Definition Block.h:34
OpListType::iterator iterator
Definition Block.h:165
iterator end()
Definition Block.h:169
static BoolAttr get(MLIRContext *context, bool value)
This class coordinates rewriting a piece of IR outside of a pattern rewrite, providing a way to keep ...
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition Location.h:76
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:71
void setInsertionPoint(Block *block, Block::iterator insertPoint)
Set the insertion point to the specified location.
Definition Builders.h:401
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
Attribute getDiscardableAttr(StringRef name)
Access a discardable attribute by name, returns a null Attribute if the discardable attribute does no...
Definition Operation.h:487
void setDiscardableAttr(StringAttr name, Attribute value)
Set a discardable attribute by name.
Definition Operation.h:514
Operation * getParentOp()
Returns the closest surrounding operation that contains this operation or nullptr if this is a top-le...
Definition Operation.h:251
operand_range getOperands()
Returns an iterator on the underlying Value's.
Definition Operation.h:405
user_range getUsers()
Returns a range of all users.
Definition Operation.h:927
MLIRContext * getContext()
Return the context this operation is associated with.
Definition Operation.h:233
void moveOpBefore(Operation *op, Operation *existingOp)
Unlink this operation from its current block and insert it right before existingOp which may be in th...
void modifyOpInPlace(Operation *root, CallableT &&callable)
This method is a utility wrapper around an in-place modification of an operation.
This class provides an abstraction over the different types of ranges over Values.
Definition ValueRange.h:392
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
user_range getUsers() const
Definition Value.h:218
bool hasOneUse() const
Returns true if this value has exactly one use.
Definition Value.h:197
Location getLoc() const
Return the location of this value.
Definition Value.cpp:24
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
Definition Value.cpp:18
static WalkResult skip()
Definition WalkResult.h:48
static WalkResult advance()
Definition WalkResult.h:47
static WalkResult interrupt()
Definition WalkResult.h:46
InFlightDiagnostic emitNYI(Location loc, const Twine &message)
Report a case that is not yet supported by the implementation.
Specialization of arith.constant op that returns an integer of index type.
Definition Arith.h:85
static ConstantIndexOp create(OpBuilder &builder, Location location, int64_t value)
Definition ArithOps.cpp:453
constexpr llvm::StringLiteral getLoopAnnotationAttrName()
Canonical name used when attaching LoopAnnotationAttr as a discardable attribute on operations that d...
Definition LLVMAttrs.h:117
std::optional< int64_t > getChunkSize(Operation *op)
Return the chunk size carried by op, if any.
GPUParallelDimsAttr getParDimsAttr(Operation *op)
Obtain the parallel dimensions carried by op, if any.
mlir::Value getACCOperandForBlockArg(mlir::Value v)
If v is not a block argument of an acc.compute_region body, returns nullptr.
mlir::Value stripIndexCasts(mlir::Value value)
Follow arith.index_cast and arith.index_castui to the value being cast.
void updateParDimsAttr(Operation *op, GPUParallelDimsAttr attr)
Update parallel dimensions on op.
bool hasGridCoversTripCountAttr(Operation *op)
Return whether this loop's trip count sized its grid dimension.
void setParDimsAttr(Operation *op, GPUParallelDimsAttr attr)
Set parallel dimensions on op.
void removeGridCoversTripCountAttr(Operation *op)
Clear the record that this loop's trip count sized its grid dimension.
Include the generated interface declarations.
bool isConstantIntValue(OpFoldResult ofr, int64_t value)
Return true if ofr is constant integer equal to value.
std::optional< int64_t > getConstantIntValue(OpFoldResult ofr)
If ofr is a constant integer or an IntegerAttr, return the integer.
bool isEqualConstantIntOrValue(OpFoldResult ofr1, OpFoldResult ofr2)
Return true if ofr1 and ofr2 are the same integer constant attribute values or the same SSA value.
Value getValueOrCreateConstantIndexOp(OpBuilder &b, Location loc, OpFoldResult ofr)
Converts an OpFoldResult to a Value.
Definition Utils.cpp:114