[Mlir-commits] [mlir] c7592c7 - [mlir][scf] NFC - Add debug information to scf pipelining
Nicolas Vasilache
llvmlistbot at llvm.org
Tue May 30 01:02:57 PDT 2023
Author: Nicolas Vasilache
Date: 2023-05-30T01:02:51-07:00
New Revision: c7592c7714c2796715e6460fc5fd19e5a930c427
URL: https://github.com/llvm/llvm-project/commit/c7592c7714c2796715e6460fc5fd19e5a930c427
DIFF: https://github.com/llvm/llvm-project/commit/c7592c7714c2796715e6460fc5fd19e5a930c427.diff
LOG: [mlir][scf] NFC - Add debug information to scf pipelining
Added:
Modified:
mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp b/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp
index a85985b84a037..9b673d6f1de93 100644
--- a/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp
@@ -20,6 +20,11 @@
#include "mlir/Support/MathExtras.h"
#include "mlir/Transforms/RegionUtils.h"
#include "llvm/ADT/MapVector.h"
+#include "llvm/Support/Debug.h"
+
+#define DEBUG_TYPE "scf-loop-pipelining"
+#define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE "]: ")
+#define LDBG(X) LLVM_DEBUG(DBGS() << X << "\n")
using namespace mlir;
using namespace mlir::scf;
@@ -84,26 +89,33 @@ struct LoopPipelinerInternal {
bool LoopPipelinerInternal::initializeLoopInfo(
ForOp op, const PipeliningOption &options) {
+ LDBG("Start initializeLoopInfo");
forOp = op;
auto upperBoundCst =
forOp.getUpperBound().getDefiningOp<arith::ConstantIndexOp>();
auto lowerBoundCst =
forOp.getLowerBound().getDefiningOp<arith::ConstantIndexOp>();
auto stepCst = forOp.getStep().getDefiningOp<arith::ConstantIndexOp>();
- if (!upperBoundCst || !lowerBoundCst || !stepCst)
+ if (!upperBoundCst || !lowerBoundCst || !stepCst) {
+ LDBG("--no constant bounds or step -> BAIL");
return false;
+ }
ub = upperBoundCst.value();
lb = lowerBoundCst.value();
step = stepCst.value();
peelEpilogue = options.peelEpilogue;
predicateFn = options.predicateFn;
- if (!peelEpilogue && predicateFn == nullptr)
+ if (!peelEpilogue && predicateFn == nullptr) {
+ LDBG("--no epilogue or predicate set -> BAIL");
return false;
+ }
int64_t numIteration = ceilDiv(ub - lb, step);
std::vector<std::pair<Operation *, unsigned>> schedule;
options.getScheduleFn(forOp, schedule);
- if (schedule.empty())
+ if (schedule.empty()) {
+ LDBG("--empty schedule -> BAIL");
return false;
+ }
opOrder.reserve(schedule.size());
for (auto &opSchedule : schedule) {
@@ -111,13 +123,16 @@ bool LoopPipelinerInternal::initializeLoopInfo(
stages[opSchedule.first] = opSchedule.second;
opOrder.push_back(opSchedule.first);
}
- if (numIteration <= maxStage)
+ if (numIteration <= maxStage) {
+ LDBG("--fewer loop iterations than pipeline stages -> BAIL");
return false;
+ }
// All operations need to have a stage.
for (Operation &op : forOp.getBody()->without_terminator()) {
if (!stages.contains(&op)) {
op.emitOpError("not assigned a pipeline stage");
+ LDBG("--op not assigned a pipeline stage: " << op << " -> BAIL");
return false;
}
}
@@ -129,11 +144,15 @@ bool LoopPipelinerInternal::initializeLoopInfo(
(void)stageNum;
if (op == forOp.getBody()->getTerminator()) {
op->emitError("terminator should not be assigned a stage");
+ LDBG("--terminator should not be assigned stage: " << *op << " -> BAIL");
return false;
}
if (op->getBlock() != forOp.getBody()) {
op->emitOpError("the owning Block of all operations assigned a stage "
"should be the loop body block");
+ LDBG("--the owning Block of all operations assigned a stage "
+ "should be the loop body block: "
+ << *op << " -> BAIL");
return false;
}
}
@@ -145,8 +164,10 @@ bool LoopPipelinerInternal::initializeLoopInfo(
[this](Value operand) {
Operation *def = operand.getDefiningOp();
return !def || !stages.contains(def);
- }))
+ })) {
+ LDBG("--only support loop carried dependency with a distance of 1 -> BAIL");
return false;
+ }
annotateFn = options.annotateFn;
return true;
}
More information about the Mlir-commits
mailing list