28 LogicalResult matchAndRewrite(gpu::SubgroupIdOp op,
58 Value dimX = rewriter.
create<gpu::BlockDimOp>(loc, gpu::Dimension::x);
59 Value dimY = rewriter.
create<gpu::BlockDimOp>(loc, gpu::Dimension::y);
60 Value tidX = rewriter.
create<gpu::ThreadIdOp>(loc, gpu::Dimension::x);
61 Value tidY = rewriter.
create<gpu::ThreadIdOp>(loc, gpu::Dimension::y);
62 Value tidZ = rewriter.
create<gpu::ThreadIdOp>(loc, gpu::Dimension::z);
64 Value dimYxIdZ = rewriter.
create<arith::MulIOp>(loc, indexType, dimY, tidZ);
65 Value dimYxIdZPlusIdY =
66 rewriter.
create<arith::AddIOp>(loc, indexType, dimYxIdZ, tidY);
67 Value dimYxIdZPlusIdYTimesDimX =
68 rewriter.
create<arith::MulIOp>(loc, indexType, dimX, dimYxIdZPlusIdY);
69 Value IdXPlusDimYxIdZPlusIdYTimesDimX = rewriter.
create<arith::AddIOp>(
70 loc, indexType, tidX, dimYxIdZPlusIdYTimesDimX);
73 Value subgroupIdOp = rewriter.
create<arith::DivUIOp>(
74 loc, indexType, IdXPlusDimYxIdZPlusIdYTimesDimX,
subgroupSize);
constexpr unsigned subgroupSize
HW dependent constants.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
virtual void replaceOp(Operation *op, ValueRange newValues)
Replace the results of the given (original) operation with the specified list of values (replacements...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Include the generated interface declarations.
const FrozenRewritePatternSet & patterns
void populateGpuSubgroupIdPatterns(RewritePatternSet &patterns)
Collect a set of patterns to rewrite SubgroupIdOp op within the GPU dialect.
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...