Skip to content

Commit f5c04c8

Browse files
rscottmanleyScott Manley
authored andcommitted
[AffineParallelize] expose options when creating pass
Add a createAffineParallelizePass that takes the AffineParallelizeOptions so it can be customized in a pass pipeline.
1 parent 9adc99b commit f5c04c8

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

mlir/include/mlir/Dialect/Affine/Passes.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ createAffineLoopInvariantCodeMotionPass();
4848
/// ops.
4949
std::unique_ptr<OperationPass<func::FuncOp>> createAffineParallelizePass();
5050

51+
/// Creates a pass to convert all parallel affine.for's into 1-d affine.parallel
52+
/// ops using the specified parallelize options.
53+
std::unique_ptr<OperationPass<func::FuncOp>>
54+
createAffineParallelizePass(const AffineParallelizeOptions &options);
55+
5156
/// Apply normalization transformations to affine loop-like ops. If
5257
/// `promoteSingleIter` is true, single iteration loops are promoted (i.e., the
5358
/// loop is replaced by its loop body).

mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ namespace {
4242
/// Convert all parallel affine.for op into 1-D affine.parallel op.
4343
struct AffineParallelize
4444
: public affine::impl::AffineParallelizeBase<AffineParallelize> {
45+
46+
AffineParallelize() = default;
47+
48+
explicit AffineParallelize(const AffineParallelizeOptions &options) {
49+
maxNested = std::move(options.maxNested);
50+
parallelReductions = std::move(options.parallelReductions);
51+
}
52+
4553
void runOnOperation() override;
4654
};
4755

@@ -95,3 +103,9 @@ std::unique_ptr<OperationPass<func::FuncOp>>
95103
mlir::affine::createAffineParallelizePass() {
96104
return std::make_unique<AffineParallelize>();
97105
}
106+
107+
std::unique_ptr<OperationPass<func::FuncOp>>
108+
mlir::affine::createAffineParallelizePass(
109+
const AffineParallelizeOptions &options) {
110+
return std::make_unique<AffineParallelize>(options);
111+
}

0 commit comments

Comments
 (0)