[llvm] [AMDGPU] Examine instructions in pending queues during scheduling (PR #147653)
Austin Kerbow via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 7 10:34:09 PDT 2025
================
@@ -450,35 +534,46 @@ SUnit *GCNSchedStrategy::pickNode(bool &IsTopNode) {
Bot.Available.empty() && Bot.Pending.empty() && "ReadyQ garbage");
return nullptr;
}
+ bool PickedPending;
SUnit *SU;
do {
+ PickedPending = false;
if (RegionPolicy.OnlyTopDown) {
- SU = Top.pickOnlyChoice();
+ SU = pickOnlyChoice(Top, SchedModel);
if (!SU) {
CandPolicy NoPolicy;
TopCand.reset(NoPolicy);
pickNodeFromQueue(Top, NoPolicy, DAG->getTopRPTracker(), TopCand,
+ PickedPending,
/*IsBottomUp=*/false);
assert(TopCand.Reason != NoCand && "failed to find a candidate");
SU = TopCand.SU;
}
IsTopNode = true;
} else if (RegionPolicy.OnlyBottomUp) {
- SU = Bot.pickOnlyChoice();
+ SU = pickOnlyChoice(Bot, SchedModel);
if (!SU) {
CandPolicy NoPolicy;
BotCand.reset(NoPolicy);
pickNodeFromQueue(Bot, NoPolicy, DAG->getBotRPTracker(), BotCand,
+ PickedPending,
/*IsBottomUp=*/true);
assert(BotCand.Reason != NoCand && "failed to find a candidate");
SU = BotCand.SU;
}
IsTopNode = false;
} else {
- SU = pickNodeBidirectional(IsTopNode);
+ SU = pickNodeBidirectional(IsTopNode, PickedPending);
}
} while (SU->isScheduled);
+ if (PickedPending) {
+ unsigned ReadyCycle = IsTopNode ? SU->TopReadyCycle : SU->BotReadyCycle;
+ SchedBoundary &Zone = IsTopNode ? Top : Bot;
+ Zone.bumpCycle(ReadyCycle);
----------------
kerbowa wrote:
Fixed. Thanks for finding this. There were two issues with the previous implementation.
1. The scheduler doesn't keep SU's next ready cycle in sync with possible hazards, and `checkHazard(SU)` needs to be queried to confirm whether the instruction can be issued in the current cycle. There is not currently a mechanism to identify exactly which cycle the hazard will resolve.
2. There is additional bookkeeping in the base implementation of `pickOnlyChoice()` that really should exist in other functions, but for our purposes it makes the most sense to always call `pickOnlyChoice()` before selecting any candidate SU. This matches the behavior of the generic scheduler.
https://github.com/llvm/llvm-project/pull/147653
More information about the llvm-commits
mailing list