-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[AMDGPU] Add register usage diagnostics at the point of maximum register pressure. #161850
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
Changes from 1 commit
28c8172
335007f
f30ac2a
9349a0b
6ba76c0
5ebe1d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,21 @@ static cl::opt<bool> GCNTrackers( | |
| cl::desc("Use the AMDGPU specific RPTrackers during scheduling"), | ||
| cl::init(false)); | ||
|
|
||
| #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||
| #define DUMP_MAX_REG_PRESSURE | ||
| static cl::opt<bool> PrintMaxRPRegUsageBeforeScheduler( | ||
| "amdgpu-print-maxrp-regusage-before-scheduler", cl::Hidden, | ||
vpykhtin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cl::desc("Print a list of live registers along with their def/uses at the " | ||
| "point of maximum register pressure before scheduling."), | ||
| cl::init(false)); | ||
|
|
||
| static cl::opt<bool> PrintMaxRPRegUsageAfterScheduler( | ||
| "amdgpu-print-maxrp-regusage-after-scheduler", cl::Hidden, | ||
vpykhtin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cl::desc("Print a list of live registers along with their def/uses at the " | ||
| "point of maximum register pressure after scheduling."), | ||
| cl::init(false)); | ||
| #endif | ||
|
|
||
| const unsigned ScheduleMetrics::ScaleFactor = 100; | ||
|
|
||
| GCNSchedStrategy::GCNSchedStrategy(const MachineSchedContext *C) | ||
|
|
@@ -960,6 +975,16 @@ void GCNScheduleDAGMILive::runSchedStages() { | |
| RegionLiveOuts.buildLiveRegMap(); | ||
| } | ||
|
|
||
| #ifdef DUMP_MAX_REG_PRESSURE | ||
| auto dumpRegUsage = [this]() { | ||
| dumpMaxRegPressure(MF, GCNRegPressure::VGPR, *LIS, MLI); | ||
| dumpMaxRegPressure(MF, GCNRegPressure::SGPR, *LIS, MLI); | ||
| LIS->dump(); | ||
|
Comment on lines
+980
to
+982
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lambda not doing anything, just inline it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But it called twice, before and after scheduling. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's still trivial enough to just duplicate |
||
| }; | ||
| if (PrintMaxRPRegUsageBeforeScheduler) | ||
| dumpRegUsage(); | ||
| #endif | ||
|
|
||
| GCNSchedStrategy &S = static_cast<GCNSchedStrategy &>(*SchedImpl); | ||
| while (S.advanceStage()) { | ||
| auto Stage = createSchedStage(S.getCurrentStage()); | ||
|
|
@@ -995,6 +1020,11 @@ void GCNScheduleDAGMILive::runSchedStages() { | |
|
|
||
| Stage->finalizeGCNSchedStage(); | ||
| } | ||
|
|
||
| #ifdef DUMP_MAX_REG_PRESSURE | ||
| if (PrintMaxRPRegUsageAfterScheduler) | ||
| dumpRegUsage(); | ||
| #endif | ||
| } | ||
|
|
||
| #ifndef NDEBUG | ||
|
|
||
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 is just a suggestion for potentially increased utility. Most of the time the highest register pressure in the program unit is what you are interested in, but not always. It could be useful to have this dump be more targeted. That is, provide an option to make it specific to a single basic block or even a scheduling region. This isn't something that needs to be done now, of course.
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 is a very nice feature. I think we can specify slot index to print the info. Also it could print all slot indexes where register pressure reaches maximum.