Skip to content

Commit b873761

Browse files
committed
[MLIR][NFC] Move some of the affine transforms / tests to dialect dirs
Move some of the affine transforms and their test cases to their respective dialect directory. This patch does not complete the move, but takes care of a good part. Renames: prefix 'affine' to affine loop tiling cl options, vectorize -> super-vectorize Signed-off-by: Uday Bondhugula <[email protected]> Differential Revision: https://reviews.llvm.org/D76565
1 parent 56e1c20 commit b873761

32 files changed

+64
-69
lines changed

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ template <typename T> class OpPassBase;
3232
std::unique_ptr<OpPassBase<FuncOp>> createSimplifyAffineStructuresPass();
3333

3434
/// Creates a loop invariant code motion pass that hoists loop invariant
35-
/// instructions out of affine loop.
35+
/// operations out of affine loops.
3636
std::unique_ptr<OpPassBase<FuncOp>> createAffineLoopInvariantCodeMotionPass();
3737

3838
/// Performs packing (or explicit copying) of accessed memref regions into
@@ -43,6 +43,31 @@ std::unique_ptr<OpPassBase<FuncOp>> createAffineDataCopyGenerationPass(
4343
unsigned tagMemorySpace = 0, int minDmaTransferSize = 1024,
4444
uint64_t fastMemCapacityBytes = std::numeric_limits<uint64_t>::max());
4545

46+
/// Creates a pass to perform tiling on loop nests.
47+
std::unique_ptr<OpPassBase<FuncOp>>
48+
createLoopTilingPass(uint64_t cacheSizeBytes);
49+
50+
/// Creates a loop unrolling pass with the provided parameters.
51+
/// 'getUnrollFactor' is a function callback for clients to supply a function
52+
/// that computes an unroll factor - the callback takes precedence over unroll
53+
/// factors supplied through other means. If -1 is passed as the unrollFactor
54+
/// and no callback is provided, anything passed from the command-line (if at
55+
/// all) or the default unroll factor is used (LoopUnroll:kDefaultUnrollFactor).
56+
std::unique_ptr<OpPassBase<FuncOp>> createLoopUnrollPass(
57+
int unrollFactor = -1, int unrollFull = -1,
58+
const std::function<unsigned(AffineForOp)> &getUnrollFactor = nullptr);
59+
60+
/// Creates a loop unroll jam pass to unroll jam by the specified factor. A
61+
/// factor of -1 lets the pass use the default factor or the one on the command
62+
/// line if provided.
63+
std::unique_ptr<OpPassBase<FuncOp>>
64+
createLoopUnrollAndJamPass(int unrollJamFactor = -1);
65+
66+
/// Creates a pass to vectorize loops, operations and data types using a
67+
/// target-independent, n-D super-vector abstraction.
68+
std::unique_ptr<OpPassBase<FuncOp>>
69+
createSuperVectorizePass(ArrayRef<int64_t> virtualVectorSize);
70+
4671
} // end namespace mlir
4772

4873
#endif // MLIR_DIALECT_AFFINE_RANSFORMS_PASSES_H

mlir/include/mlir/InitAllPasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ inline void registerAllPasses() {
6161
// Init general passes
6262
createCanonicalizerPass();
6363
createCSEPass();
64-
createVectorizePass({});
64+
createSuperVectorizePass({});
6565
createLoopUnrollPass();
6666
createLoopUnrollAndJamPass();
6767
createSimplifyAffineStructuresPass();

mlir/include/mlir/Transforms/Passes.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,6 @@ std::unique_ptr<Pass> createCanonicalizerPass();
3232
/// Creates a pass to perform common sub expression elimination.
3333
std::unique_ptr<Pass> createCSEPass();
3434

35-
/// Creates a pass to vectorize loops, operations and data types using a
36-
/// target-independent, n-D super-vector abstraction.
37-
std::unique_ptr<OpPassBase<FuncOp>>
38-
createVectorizePass(ArrayRef<int64_t> virtualVectorSize);
39-
40-
/// Creates a loop unrolling pass with the provided parameters.
41-
/// 'getUnrollFactor' is a function callback for clients to supply a function
42-
/// that computes an unroll factor - the callback takes precedence over unroll
43-
/// factors supplied through other means. If -1 is passed as the unrollFactor
44-
/// and no callback is provided, anything passed from the command-line (if at
45-
/// all) or the default unroll factor is used (LoopUnroll:kDefaultUnrollFactor).
46-
std::unique_ptr<OpPassBase<FuncOp>> createLoopUnrollPass(
47-
int unrollFactor = -1, int unrollFull = -1,
48-
const std::function<unsigned(AffineForOp)> &getUnrollFactor = nullptr);
49-
50-
/// Creates a loop unroll jam pass to unroll jam by the specified factor. A
51-
/// factor of -1 lets the pass use the default factor or the one on the command
52-
/// line if provided.
53-
std::unique_ptr<OpPassBase<FuncOp>>
54-
createLoopUnrollAndJamPass(int unrollJamFactor = -1);
55-
5635
/// Creates a loop fusion pass which fuses loops. Buffers of size less than or
5736
/// equal to `localBufSizeThreshold` are promoted to memory space
5837
/// `fastMemorySpace'.
@@ -65,10 +44,6 @@ createLoopFusionPass(unsigned fastMemorySpace = 0,
6544
/// instructions out of the loop.
6645
std::unique_ptr<Pass> createLoopInvariantCodeMotionPass();
6746

68-
/// Creates a loop invariant code motion pass that hoists loop invariant
69-
/// instructions out of affine loop.
70-
std::unique_ptr<OpPassBase<FuncOp>> createAffineLoopInvariantCodeMotionPass();
71-
7247
/// Creates a pass to pipeline explicit movement of data across levels of the
7348
/// memory hierarchy.
7449
std::unique_ptr<OpPassBase<FuncOp>> createPipelineDataTransferPass();
@@ -78,10 +53,6 @@ std::unique_ptr<OpPassBase<FuncOp>> createPipelineDataTransferPass();
7853
/// primitives).
7954
std::unique_ptr<OpPassBase<FuncOp>> createLowerAffinePass();
8055

81-
/// Creates a pass to perform tiling on loop nests.
82-
std::unique_ptr<OpPassBase<FuncOp>>
83-
createLoopTilingPass(uint64_t cacheSizeBytes);
84-
8556
/// Creates a pass that transforms perfectly nested loops with independent
8657
/// bounds into a single loop.
8758
std::unique_ptr<OpPassBase<FuncOp>> createLoopCoalescingPass();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
#include "mlir/Analysis/SliceAnalysis.h"
1717
#include "mlir/Analysis/Utils.h"
1818
#include "mlir/Dialect/Affine/IR/AffineOps.h"
19+
#include "mlir/Dialect/Affine/Passes.h"
1920
#include "mlir/IR/AffineExpr.h"
2021
#include "mlir/IR/AffineMap.h"
2122
#include "mlir/IR/Builders.h"
2223
#include "mlir/Pass/Pass.h"
2324
#include "mlir/Transforms/LoopUtils.h"
24-
#include "mlir/Transforms/Passes.h"
2525
#include "mlir/Transforms/Utils.h"
2626
#include "llvm/ADT/DenseMap.h"
2727
#include "llvm/ADT/DenseSet.h"

mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
add_mlir_dialect_library(MLIRAffineTransforms
22
AffineDataCopyGeneration.cpp
33
AffineLoopInvariantCodeMotion.cpp
4+
LoopTiling.cpp
5+
LoopUnroll.cpp
6+
LoopUnrollAndJam.cpp
7+
SuperVectorize.cpp
48
SimplifyAffineStructures.cpp
59

610
ADDITIONAL_HEADER_DIRS

mlir/lib/Transforms/LoopTiling.cpp renamed to mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#include "mlir/Analysis/LoopAnalysis.h"
1616
#include "mlir/Analysis/Utils.h"
1717
#include "mlir/Dialect/Affine/IR/AffineOps.h"
18+
#include "mlir/Dialect/Affine/Passes.h"
1819
#include "mlir/IR/Builders.h"
1920
#include "mlir/Pass/Pass.h"
2021
#include "mlir/Transforms/LoopUtils.h"
21-
#include "mlir/Transforms/Passes.h"
2222
#include "mlir/Transforms/Utils.h"
2323
#include "llvm/Support/CommandLine.h"
2424
#include "llvm/Support/Debug.h"
@@ -29,19 +29,20 @@ using namespace mlir;
2929
static llvm::cl::OptionCategory clOptionsCategory(DEBUG_TYPE " options");
3030

3131
static llvm::cl::opt<unsigned long long>
32-
clCacheSizeKiB("tile-cache-size",
32+
clCacheSizeKiB("affine-tile-cache-size",
3333
llvm::cl::desc("Set size of cache to tile for in KiB"),
3434
llvm::cl::cat(clOptionsCategory));
3535

3636
// Tile size to use for all loops (overrides -tile-sizes if provided).
3737
static llvm::cl::opt<unsigned>
38-
clTileSize("tile-size", llvm::cl::desc("Use this tile size for all loops"),
38+
clTileSize("affine-tile-size",
39+
llvm::cl::desc("Use this tile size for all loops"),
3940
llvm::cl::cat(clOptionsCategory));
4041

4142
// List of tile sizes. If any of them aren't provided, they are filled with
4243
// clTileSize / kDefaultTileSize.
4344
static llvm::cl::list<unsigned> clTileSizes(
44-
"tile-sizes",
45+
"affine-tile-sizes",
4546
llvm::cl::desc(
4647
"List of tile sizes for each perfect nest (overridden by -tile-size)"),
4748
llvm::cl::ZeroOrMore, llvm::cl::cat(clOptionsCategory));

mlir/lib/Transforms/LoopUnroll.cpp renamed to mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "mlir/Transforms/Passes.h"
14-
1513
#include "mlir/Analysis/LoopAnalysis.h"
1614
#include "mlir/Dialect/Affine/IR/AffineOps.h"
15+
#include "mlir/Dialect/Affine/Passes.h"
1716
#include "mlir/IR/AffineExpr.h"
1817
#include "mlir/IR/AffineMap.h"
1918
#include "mlir/IR/Builders.h"

mlir/lib/Transforms/LoopUnrollAndJam.cpp renamed to mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@
3232
// Note: 'if/else' blocks are not jammed. So, if there are loops inside if
3333
// op's, bodies of those loops will not be jammed.
3434
//===----------------------------------------------------------------------===//
35-
#include "mlir/Transforms/Passes.h"
36-
3735
#include "mlir/Analysis/LoopAnalysis.h"
3836
#include "mlir/Dialect/Affine/IR/AffineOps.h"
37+
#include "mlir/Dialect/Affine/Passes.h"
3938
#include "mlir/IR/AffineExpr.h"
4039
#include "mlir/IR/AffineMap.h"
4140
#include "mlir/IR/BlockAndValueMapping.h"

mlir/lib/Transforms/Vectorize.cpp renamed to mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- Vectorize.cpp - Vectorize Pass Impl --------------------------------===//
1+
//===- SuperVectorize.cpp - Vectorize Pass Impl ---------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -16,6 +16,7 @@
1616
#include "mlir/Analysis/SliceAnalysis.h"
1717
#include "mlir/Analysis/Utils.h"
1818
#include "mlir/Dialect/Affine/IR/AffineOps.h"
19+
#include "mlir/Dialect/Affine/Passes.h"
1920
#include "mlir/Dialect/StandardOps/IR/Ops.h"
2021
#include "mlir/Dialect/Vector/VectorOps.h"
2122
#include "mlir/Dialect/Vector/VectorUtils.h"
@@ -27,7 +28,6 @@
2728
#include "mlir/Support/Functional.h"
2829
#include "mlir/Support/LLVM.h"
2930
#include "mlir/Transforms/FoldUtils.h"
30-
#include "mlir/Transforms/Passes.h"
3131

3232
#include "llvm/ADT/DenseMap.h"
3333
#include "llvm/ADT/DenseSet.h"
@@ -1268,10 +1268,10 @@ void Vectorize::runOnFunction() {
12681268
}
12691269

12701270
std::unique_ptr<OpPassBase<FuncOp>>
1271-
mlir::createVectorizePass(ArrayRef<int64_t> virtualVectorSize) {
1271+
mlir::createSuperVectorizePass(ArrayRef<int64_t> virtualVectorSize) {
12721272
return std::make_unique<Vectorize>(virtualVectorSize);
12731273
}
12741274

12751275
static PassRegistration<Vectorize>
1276-
pass("affine-vectorize",
1276+
pass("affine-super-vectorize",
12771277
"Vectorize to a target independent n-D vector abstraction");

mlir/lib/Transforms/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@ add_mlir_library(MLIRTransforms
99
LoopCoalescing.cpp
1010
LoopFusion.cpp
1111
LoopInvariantCodeMotion.cpp
12-
LoopTiling.cpp
13-
LoopUnrollAndJam.cpp
14-
LoopUnroll.cpp
1512
MemRefDataFlowOpt.cpp
1613
OpStats.cpp
1714
PipelineDataTransfer.cpp
1815
StripDebugInfo.cpp
1916
SymbolDCE.cpp
20-
Vectorize.cpp
2117
ViewOpGraph.cpp
2218
ViewRegionGraph.cpp
2319

0 commit comments

Comments
 (0)