Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions mlir/lib/Pass/PassTiming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ struct PassTiming : public PassInstrumentation {
auto &activeTimers = activeThreadTimers[tid];
auto &parentScope = activeTimers.empty() ? rootScope : activeTimers.back();

parentTimerIndices[{tid, pass}] = activeTimers.size();
if (auto *adaptor = dyn_cast<OpToOpPassAdaptor>(pass)) {
parentTimerIndices[{tid, pass}] = activeTimers.size();
auto scope =
parentScope.nest(pass->getThreadingSiblingOrThis(),
[adaptor]() { return adaptor->getAdaptorName(); });
Expand All @@ -107,8 +107,7 @@ struct PassTiming : public PassInstrumentation {

void runAfterPass(Pass *pass, Operation *) override {
auto tid = llvm::get_threadid();
if (isa<OpToOpPassAdaptor>(pass))
parentTimerIndices.erase({tid, pass});
parentTimerIndices.erase({tid, pass});
auto &activeTimers = activeThreadTimers[tid];
assert(!activeTimers.empty() && "expected active timer");
activeTimers.pop_back();
Expand Down
20 changes: 20 additions & 0 deletions mlir/test/Pass/pass-timing.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// RUN: mlir-opt %s -mlir-disable-threading=false -verify-each=true -pass-pipeline='builtin.module(func.func(cse,canonicalize,cse))' -mlir-timing -mlir-timing-display=list 2>&1 | FileCheck -check-prefix=MT_LIST %s
// RUN: mlir-opt %s -mlir-disable-threading=false -verify-each=true -pass-pipeline='builtin.module(func.func(cse,canonicalize,cse))' -mlir-timing -mlir-timing-display=tree 2>&1 | FileCheck -check-prefix=MT_PIPELINE %s
// RUN: mlir-opt %s -mlir-disable-threading=true -verify-each=false -test-pm-nested-pipeline -mlir-timing -mlir-timing-display=tree 2>&1 | FileCheck -check-prefix=NESTED_PIPELINE %s
// RUN: mlir-opt %s -mlir-disable-threading=true -verify-each=true -pass-pipeline='builtin.module(func.func(cse,canonicalize,cse),inline)' -mlir-timing -mlir-timing-display=tree 2>&1 | FileCheck -check-prefix=DYNAMIC-PIPELINE %s
// RUN: mlir-opt %s -mlir-disable-threading=false -verify-each=true -pass-pipeline='builtin.module(func.func(cse,canonicalize,cse),inline)' -mlir-timing -mlir-timing-display=tree 2>&1 | FileCheck -check-prefix=DYNAMIC-PIPELINE %s

// LIST: Execution time report
// LIST: Total Execution Time:
Expand Down Expand Up @@ -95,6 +97,24 @@
// NESTED_PIPELINE-NEXT: Rest
// NESTED_PIPELINE-NEXT: Total

// DYNAMIC-PIPELINE: Execution time report
// DYNAMIC-PIPELINE: Total Execution Time:
// DYNAMIC-PIPELINE: Name
// DYNAMIC-PIPELINE-NEXT: Parser
// DYNAMIC-PIPELINE-NEXT: 'func.func' Pipeline
// DYNAMIC-PIPELINE-NEXT: CSE
// DYNAMIC-PIPELINE-NEXT: (A) DominanceInfo
// DYNAMIC-PIPELINE-NEXT: Canonicalizer
// DYNAMIC-PIPELINE-NEXT: CSE
// DYNAMIC-PIPELINE-NEXT: (A) DominanceInfo
// DYNAMIC-PIPELINE-NEXT: Inliner
// DYNAMIC-PIPELINE-NEXT: (A) CallGraph
// DYNAMIC-PIPELINE-NEXT: 'func.func' Pipeline
// DYNAMIC-PIPELINE-NEXT: Canonicalizer
// DYNAMIC-PIPELINE-NEXT: Output
// DYNAMIC-PIPELINE-NEXT: Rest
// DYNAMIC-PIPELINE-NEXT: Total
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is passing at HEAD apparently, so may not be testing what you think it is?


func.func @foo() {
return
}
Expand Down