mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Fix the MachineScheduler's logic for updating ready times for in-order.
Now the scheduler updates a node's ready time as soon as it is scheduled, before releasing dependent nodes. There was a reason I didn't do this initially but it no longer applies. A53 is in-order and was running into an issue where nodes where added to the readyQ too early. That's now fixed. This also makes it easier for custom scheduling strategies to build heuristics based on the actual cycles that the node was scheduled at. The only impact on OOO (sandybridge/cyclone) is that ready times will be slightly more accurate. I didn't measure any significant regressions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210390 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7fe88820e3
commit
808823cf77
@ -624,9 +624,9 @@ private:
|
||||
SmallVector<unsigned, 16> ReservedCycles;
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Remember the greatest operand latency as an upper bound on the number of
|
||||
// Remember the greatest possible stall as an upper bound on the number of
|
||||
// times we should retry the pending queue because of a hazard.
|
||||
unsigned MaxObservedLatency;
|
||||
unsigned MaxObservedStall;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
@ -535,6 +535,11 @@ void ScheduleDAGMI::releaseSucc(SUnit *SU, SDep *SuccEdge) {
|
||||
llvm_unreachable(nullptr);
|
||||
}
|
||||
#endif
|
||||
// SU->TopReadyCycle was set to CurrCycle when it was scheduled. However,
|
||||
// CurrCycle may have advanced since then.
|
||||
if (SuccSU->TopReadyCycle < SU->TopReadyCycle + SuccEdge->getLatency())
|
||||
SuccSU->TopReadyCycle = SU->TopReadyCycle + SuccEdge->getLatency();
|
||||
|
||||
--SuccSU->NumPredsLeft;
|
||||
if (SuccSU->NumPredsLeft == 0 && SuccSU != &ExitSU)
|
||||
SchedImpl->releaseTopNode(SuccSU);
|
||||
@ -569,6 +574,11 @@ void ScheduleDAGMI::releasePred(SUnit *SU, SDep *PredEdge) {
|
||||
llvm_unreachable(nullptr);
|
||||
}
|
||||
#endif
|
||||
// SU->BotReadyCycle was set to CurrCycle when it was scheduled. However,
|
||||
// CurrCycle may have advanced since then.
|
||||
if (PredSU->BotReadyCycle < SU->BotReadyCycle + PredEdge->getLatency())
|
||||
PredSU->BotReadyCycle = SU->BotReadyCycle + PredEdge->getLatency();
|
||||
|
||||
--PredSU->NumSuccsLeft;
|
||||
if (PredSU->NumSuccsLeft == 0 && PredSU != &EntrySU)
|
||||
SchedImpl->releaseBottomNode(PredSU);
|
||||
@ -680,10 +690,13 @@ void ScheduleDAGMI::schedule() {
|
||||
CurrentBottom = MI;
|
||||
}
|
||||
}
|
||||
updateQueues(SU, IsTopNode);
|
||||
|
||||
// Notify the scheduling strategy after updating the DAG.
|
||||
// Notify the scheduling strategy before updating the DAG.
|
||||
// This sets the scheduled nodes ReadyCycle to CurrCycle. When updateQueues
|
||||
// runs, it can then use the accurate ReadyCycle time to determine whether
|
||||
// newly released nodes can move to the readyQ.
|
||||
SchedImpl->schedNode(SU, IsTopNode);
|
||||
|
||||
updateQueues(SU, IsTopNode);
|
||||
}
|
||||
assert(CurrentTop == CurrentBottom && "Nonempty unscheduled zone.");
|
||||
|
||||
@ -1574,7 +1587,7 @@ void SchedBoundary::reset() {
|
||||
// Track the maximum number of stall cycles that could arise either from the
|
||||
// latency of a DAG edge or the number of cycles that a processor resource is
|
||||
// reserved (SchedBoundary::ReservedCycles).
|
||||
MaxObservedLatency = 0;
|
||||
MaxObservedStall = 0;
|
||||
#endif
|
||||
// Reserve a zero-count for invalid CritResIdx.
|
||||
ExecutedResCounts.resize(1);
|
||||
@ -1731,6 +1744,12 @@ getOtherResourceCount(unsigned &OtherCritIdx) {
|
||||
}
|
||||
|
||||
void SchedBoundary::releaseNode(SUnit *SU, unsigned ReadyCycle) {
|
||||
assert(SU->getInstr() && "Scheduled SUnit must have instr");
|
||||
|
||||
#ifndef NDEBUG
|
||||
MaxObservedStall = std::max(ReadyCycle - CurrCycle, MaxObservedStall);
|
||||
#endif
|
||||
|
||||
if (ReadyCycle < MinReadyCycle)
|
||||
MinReadyCycle = ReadyCycle;
|
||||
|
||||
@ -1750,18 +1769,6 @@ void SchedBoundary::releaseTopNode(SUnit *SU) {
|
||||
if (SU->isScheduled)
|
||||
return;
|
||||
|
||||
for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
|
||||
I != E; ++I) {
|
||||
if (I->isWeak())
|
||||
continue;
|
||||
unsigned PredReadyCycle = I->getSUnit()->TopReadyCycle;
|
||||
unsigned Latency = I->getLatency();
|
||||
#ifndef NDEBUG
|
||||
MaxObservedLatency = std::max(Latency, MaxObservedLatency);
|
||||
#endif
|
||||
if (SU->TopReadyCycle < PredReadyCycle + Latency)
|
||||
SU->TopReadyCycle = PredReadyCycle + Latency;
|
||||
}
|
||||
releaseNode(SU, SU->TopReadyCycle);
|
||||
}
|
||||
|
||||
@ -1769,20 +1776,6 @@ void SchedBoundary::releaseBottomNode(SUnit *SU) {
|
||||
if (SU->isScheduled)
|
||||
return;
|
||||
|
||||
assert(SU->getInstr() && "Scheduled SUnit must have instr");
|
||||
|
||||
for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
|
||||
I != E; ++I) {
|
||||
if (I->isWeak())
|
||||
continue;
|
||||
unsigned SuccReadyCycle = I->getSUnit()->BotReadyCycle;
|
||||
unsigned Latency = I->getLatency();
|
||||
#ifndef NDEBUG
|
||||
MaxObservedLatency = std::max(Latency, MaxObservedLatency);
|
||||
#endif
|
||||
if (SU->BotReadyCycle < SuccReadyCycle + Latency)
|
||||
SU->BotReadyCycle = SuccReadyCycle + Latency;
|
||||
}
|
||||
releaseNode(SU, SU->BotReadyCycle);
|
||||
}
|
||||
|
||||
@ -1951,7 +1944,7 @@ void SchedBoundary::bumpNode(SUnit *SU) {
|
||||
if (SchedModel->getProcResource(PIdx)->BufferSize == 0) {
|
||||
ReservedCycles[PIdx] = isTop() ? NextCycle + PI->Cycles : NextCycle;
|
||||
#ifndef NDEBUG
|
||||
MaxObservedLatency = std::max(PI->Cycles, MaxObservedLatency);
|
||||
MaxObservedStall = std::max(PI->Cycles, MaxObservedStall);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -2055,7 +2048,7 @@ SUnit *SchedBoundary::pickOnlyChoice() {
|
||||
}
|
||||
}
|
||||
for (unsigned i = 0; Available.empty(); ++i) {
|
||||
assert(i <= (HazardRec->getMaxLookAhead() + MaxObservedLatency) &&
|
||||
assert(i <= (HazardRec->getMaxLookAhead() + MaxObservedStall) &&
|
||||
"permanent hazard"); (void)i;
|
||||
bumpCycle(CurrCycle + 1);
|
||||
releasePending();
|
||||
|
Loading…
Reference in New Issue
Block a user