-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[MLIR][Timing] Fix timing report of nested pass pipeline and negative Rest field when using -mlir-timing (Try to close #169443) #169615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-core Author: ChenyangXu (Xubaidu) ChangesThis PR tries to close [MLIR][Timing] Nested pipeline is displayed at top level and show negative Rest field when using -mlir-timing Full diff: https://github.com/llvm/llvm-project/pull/169615.diff 1 Files Affected:
diff --git a/mlir/lib/Pass/PassTiming.cpp b/mlir/lib/Pass/PassTiming.cpp
index dab56f09a72eb..8b78a99069cc9 100644
--- a/mlir/lib/Pass/PassTiming.cpp
+++ b/mlir/lib/Pass/PassTiming.cpp
@@ -90,6 +90,9 @@ struct PassTiming : public PassInstrumentation {
auto &activeTimers = activeThreadTimers[tid];
auto &parentScope = activeTimers.empty() ? rootScope : activeTimers.back();
+ // Record the parent information for this pass so nested pipelines can find it,
+ // regardless of whether this is an adaptor pass or a regular pass.
+ parentTimerIndices[{tid, pass}] = activeTimers.size();
if (auto *adaptor = dyn_cast<OpToOpPassAdaptor>(pass)) {
parentTimerIndices[{tid, pass}] = activeTimers.size();
auto scope =
@@ -107,8 +110,8 @@ struct PassTiming : public PassInstrumentation {
void runAfterPass(Pass *pass, Operation *) override {
auto tid = llvm::get_threadid();
- if (isa<OpToOpPassAdaptor>(pass))
- parentTimerIndices.erase({tid, pass});
+ // Erase the parent index mapping for this pass (adaptor or not).
+ parentTimerIndices.erase({tid, pass});
auto &activeTimers = activeThreadTimers[tid];
assert(!activeTimers.empty() && "expected active timer");
activeTimers.pop_back();
|
mlir/lib/Pass/PassTiming.cpp
Outdated
| // regardless of whether this is an adaptor pass or a regular pass. | ||
| parentTimerIndices[{tid, pass}] = activeTimers.size(); | ||
| if (auto *adaptor = dyn_cast<OpToOpPassAdaptor>(pass)) { | ||
| parentTimerIndices[{tid, pass}] = activeTimers.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this line redundant now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the redundant code now. Please take a look again.
joker-eph
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems fine, how could this be tested though?
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
3a6ef8c to
85925cb
Compare
@joker-eph I added two tests in the test file but I am not sure if they are sufficient. Would you mind adding more reviewers of dynamic pass pipeline and MLIR core to review it? |
| // DYNAMIC-PIPELINE-NEXT: Canonicalizer | ||
| // DYNAMIC-PIPELINE-NEXT: Output | ||
| // DYNAMIC-PIPELINE-NEXT: Rest | ||
| // DYNAMIC-PIPELINE-NEXT: Total |
There was a problem hiding this comment.
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?
This PR tries to close [MLIR][Timing] Nested pipeline is displayed at top level and show negative Rest field when using -mlir-timing
Here is the timing report of the
inlinerpass w/o and w/ this change:Also take
mlir/test/Pass/dynamic-pipeline-nested.mliras an example: