-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[AMDGPU][MISCHED] GCNBalancedSchedStrategy. #66634
Conversation
@llvm/pr-subscribers-backend-amdgpu @llvm/pr-subscribers-llvm-globalisel ChangesThe change implements the scheduling strategy which aims to find a reasonable trade-off between the ILP and occupancy.
|
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.
I have two remaining points to discuss.
We bypass the UnclusteredHighRPStage (in its initGCNRegion
) for regions with the following condition:
if ((!DAG.RegionsWithMinOcc[RegionIdx] ||
DAG.MinOccupancy <= InitialOccupancy) &&
!DAG.RegionsWithExcessRP[RegionIdx])
return false;
My question: for the balanced scheduler, should we actually run this phase for RegionsWithMinOcc && !RegionsWithExcessRP
?
Should we run ClusteredLowOccStage
for any region so long as we have observed an occupancy drop (at least for the experimental version)?
if (WavesAfter < DAG.MinOccupancy) | ||
return true; | ||
|
||
return false; | ||
} | ||
|
||
bool OccInitialScheduleStage::shouldRevertScheduling(unsigned WavesAfter) { | ||
bool OccInitialScheduleStage::shouldRevertScheduling(unsigned WavesAfter, | ||
unsigned WavesBefore) { | ||
if (PressureAfter == PressureBefore) |
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.
For the balanced scheduler, should we really early exit on RP?
if (PressureAfter == PressureBefore) | ||
return false; | ||
|
||
if (GCNSchedStage::shouldRevertScheduling(WavesAfter)) |
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.
We need to keep this in order to preserve MaxOccupancy scheduler's behavior, but it should not be the priority for the balanced scheduler. Maybe the balanced scheduler should just have a different initial stage entirely.
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.
We need to keep this in order to preserve MaxOccupancy scheduler's behavior, but it should not be the priority for the balanced scheduler. Maybe the balanced scheduler should just have a different initial stage entirely.
If we decide to exactly preserve the MaxOccupancy scheduler's behavior, we'd better write a completely new code for most things. We could try to have a separate set of stages for the balanced scheduler but it still has to communicate with interfaces that are focused on the occupancy. So, I agree that the approach to minimize the existing code changes could be not viable.
// Revert if may cause spilling. Otherwise rely on the metric computed by the | ||
// strategy class. Exception: does not make sense to revert the unclustered | ||
// schedule if we are still in excess RP state as it will not become better. | ||
return GCNSchedStage::shouldRevertScheduling(WavesAfter, WavesBefore) || |
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.
Does this preserve the behavior of MaxOccupancy scheduler?
The idea to run this stage for the ExcessRP regions only is correct. This is (I hope temporarily) left aside to avoid vast changes throughout the scheduler. The reason is that the spill-controlling mechanisms heavily rely on the MinOCC set and as soon as we touch this we immediately have to rewrite a lot of things.
The fact we observed an occupancy drop does not make our schedule invalid, right? So, maybe the chance to improve ILP at the cost of worsening the occupancy yet more is not as bad? We need to have more real traces collected from the real program runs to have statistics. |
The change implements the scheduling strategy which aims to find a reasonable trade-off between the ILP and occupancy.
For that purpose, it computes the heuristic metric to decide if the current schedule is worth to be kept.
This is an attempt to use the same idea as in the https://reviews.llvm.org/D139710 to replace the shouldRevertScheduling function.
Unlike the https://reviews.llvm.org/D139710 the heuristic is applied to all scheduling stages.