|
LLVM
10.0.0
|
Each Scheduling boundary is associated with ready queues. More...
#include "llvm/CodeGen/MachineScheduler.h"
Public Types | |
| enum | { TopQID = 1, BotQID = 2, LogMaxQID = 2 } |
| SUnit::NodeQueueId: 0 (none), 1 (top), 2 (bot), 3 (both) More... | |
Public Member Functions | |
| SchedBoundary (unsigned ID, const Twine &Name) | |
| Pending queues extend the ready queues with the same ID and the PendingFlag set. More... | |
| ~SchedBoundary () | |
| void | reset () |
| void | init (ScheduleDAGMI *dag, const TargetSchedModel *smodel, SchedRemainder *rem) |
| bool | isTop () const |
| unsigned | getCurrCycle () const |
| Number of cycles to issue the instructions scheduled in this zone. More... | |
| unsigned | getCurrMOps () const |
| Micro-ops issued in the current cycle. More... | |
| unsigned | getDependentLatency () const |
| unsigned | getScheduledLatency () const |
| Get the number of latency cycles "covered" by the scheduled instructions. More... | |
| unsigned | getUnscheduledLatency (SUnit *SU) const |
| unsigned | getResourceCount (unsigned ResIdx) const |
| unsigned | getCriticalCount () const |
| Get the scaled count of scheduled micro-ops and resources, including executed resources. More... | |
| unsigned | getExecutedCount () const |
| Get a scaled count for the minimum execution time of the scheduled micro-ops that are ready to execute by getExecutedCount. More... | |
| unsigned | getZoneCritResIdx () const |
| bool | isResourceLimited () const |
| unsigned | getLatencyStallCycles (SUnit *SU) |
| Get the difference between the given SUnit's ready time and the current cycle. More... | |
| unsigned | getNextResourceCycleByInstance (unsigned InstanceIndex, unsigned Cycles) |
| Compute the next cycle at which the given processor resource unit can be scheduled. More... | |
| std::pair< unsigned, unsigned > | getNextResourceCycle (unsigned PIdx, unsigned Cycles) |
| Compute the next cycle at which the given processor resource can be scheduled. More... | |
| bool | checkHazard (SUnit *SU) |
| Does this SU have a hazard within the current instruction group. More... | |
| unsigned | findMaxLatency (ArrayRef< SUnit *> ReadySUs) |
| unsigned | getOtherResourceCount (unsigned &OtherCritIdx) |
| void | releaseNode (SUnit *SU, unsigned ReadyCycle, bool InPQueue, unsigned Idx=0) |
| Release SU to make it ready. More... | |
| void | bumpCycle (unsigned NextCycle) |
| Move the boundary of scheduled code by one cycle. More... | |
| void | incExecutedResources (unsigned PIdx, unsigned Count) |
| unsigned | countResource (unsigned PIdx, unsigned Cycles, unsigned ReadyCycle) |
| Add the given processor resource to this scheduled zone. More... | |
| void | bumpNode (SUnit *SU) |
| Move the boundary of scheduled code by one SUnit. More... | |
| void | releasePending () |
| Release pending ready nodes in to the available queue. More... | |
| void | removeReady (SUnit *SU) |
| Remove SU from the ready set for this boundary. More... | |
| SUnit * | pickOnlyChoice () |
| Call this before applying any other heuristics to the Available queue. More... | |
| void | dumpScheduledState () const |
Public Attributes | |
| ScheduleDAGMI * | DAG = nullptr |
| const TargetSchedModel * | SchedModel = nullptr |
| SchedRemainder * | Rem = nullptr |
| ReadyQueue | Available |
| ReadyQueue | Pending |
| ScheduleHazardRecognizer * | HazardRec = nullptr |
Each Scheduling boundary is associated with ready queues.
It tracks the current cycle in the direction of movement, and maintains the state of "hazards" and other interlocks at the current cycle.
Definition at line 604 of file MachineScheduler.h.
| anonymous enum |
SUnit::NodeQueueId: 0 (none), 1 (top), 2 (bot), 3 (both)
| Enumerator | |
|---|---|
| TopQID | |
| BotQID | |
| LogMaxQID | |
Definition at line 607 of file MachineScheduler.h.
Pending queues extend the ready queues with the same ID and the PendingFlag set.
Definition at line 683 of file MachineScheduler.h.
References llvm::cl::init().
| SchedBoundary::~SchedBoundary | ( | ) |
Definition at line 1836 of file MachineScheduler.cpp.
| void SchedBoundary::bumpCycle | ( | unsigned | NextCycle | ) |
Move the boundary of scheduled code by one cycle.
Definition at line 2120 of file MachineScheduler.cpp.
References assert(), checkResourceLimit(), llvm::dbgs(), LLVM_DEBUG, and llvm::max().
| void SchedBoundary::bumpNode | ( | SUnit * | SU | ) |
Move the boundary of scheduled code by one SUnit.
Definition at line 2205 of file MachineScheduler.cpp.
References assert(), llvm::SUnit::BotReadyCycle, checkResourceLimit(), llvm::dbgs(), llvm::SUnit::getDepth(), llvm::SUnit::getHeight(), llvm::SUnit::getInstr(), llvm::ScheduleDAGInstrs::getSchedClass(), llvm::SUnit::hasReservedResource, llvm::SUnit::isCall, llvm::SUnit::isUnbuffered, LLVM_DEBUG, llvm::max(), llvm::SUnit::NodeNum, llvm::PPCISD::SC, and llvm::SUnit::TopReadyCycle.
Does this SU have a hazard within the current instruction group.
The scheduler supports two modes of hazard recognition. The first is the ScheduleHazardRecognizer API. It is a fully general hazard recognizer that supports highly complicated in-order reservation tables (ScoreboardHazardRecognizer) and arbitrary target-specific logic.
The second is a streamlined mechanism that checks for hazards based on simple counters that the scheduler itself maintains. It explicitly checks for instruction dispatch limitations, including the number of micro-ops that can dispatch per cycle.
TODO: Also check whether the SU must start a new group.
Definition at line 1992 of file MachineScheduler.cpp.
References llvm::dbgs(), findMaxLatency(), llvm::SUnit::getInstr(), llvm::ScheduleDAGInstrs::getSchedClass(), llvm::SUnit::hasReservedResource, LLVM_DEBUG, llvm::make_range(), llvm::max(), llvm::SUnit::NodeNum, llvm::ScheduleHazardRecognizer::NoHazard, and llvm::PPCISD::SC.
Add the given processor resource to this scheduled zone.
| Cycles | indicates the number of consecutive (non-pipelined) cycles during which this resource is consumed. |
Definition at line 2172 of file MachineScheduler.cpp.
References assert(), llvm::dbgs(), and LLVM_DEBUG.
Referenced by incExecutedResources().
| LLVM_DUMP_METHOD void SchedBoundary::dumpScheduledState | ( | ) | const |
Definition at line 2423 of file MachineScheduler.cpp.
References llvm::dbgs(), and llvm::GenericSchedulerBase::SchedCandidate::initResourceDelta().
Definition at line 2039 of file MachineScheduler.cpp.
References llvm::dbgs(), getOtherResourceCount(), LLVM_DEBUG, and llvm::SUnit::NodeNum.
Referenced by checkHazard(), and computeRemLatency().
|
inline |
Get the scaled count of scheduled micro-ops and resources, including executed resources.
Definition at line 725 of file MachineScheduler.h.
References llvm::TargetSchedModel::getMicroOpFactor().
|
inline |
Number of cycles to issue the instructions scheduled in this zone.
Definition at line 700 of file MachineScheduler.h.
Referenced by computeRemLatency(), and llvm::GenericSchedulerBase::setPolicy().
|
inline |
Micro-ops issued in the current cycle.
Definition at line 703 of file MachineScheduler.h.
Referenced by llvm::GenericScheduler::tryCandidate().
|
inline |
Definition at line 706 of file MachineScheduler.h.
Referenced by computeRemLatency().
|
inline |
Get a scaled count for the minimum execution time of the scheduled micro-ops that are ready to execute by getExecutedCount.
Notice the feedback loop.
Definition at line 734 of file MachineScheduler.h.
References llvm::TargetSchedModel::getLatencyFactor(), and llvm::max().
Get the difference between the given SUnit's ready time and the current cycle.
Compute the stall cycles based on this SUnit's ready time.
Heuristics treat these "soft stalls" differently than the hard stall cycles based on CPU resources and computed by checkHazard(). A fully in-order model (MicroOpBufferSize==0) will not make use of this since instructions are not available for scheduling until they are ready. However, a weaker in-order model may use this for heuristics. For example, if a processor has in-order behavior when reading certain resources, this may come into play.
Definition at line 1932 of file MachineScheduler.cpp.
References llvm::SUnit::BotReadyCycle, llvm::SUnit::isUnbuffered, and llvm::SUnit::TopReadyCycle.
Referenced by llvm::GenericScheduler::tryCandidate().
| std::pair< unsigned, unsigned > SchedBoundary::getNextResourceCycle | ( | unsigned | PIdx, |
| unsigned | Cycles | ||
| ) |
Compute the next cycle at which the given processor resource can be scheduled.
Returns the next cycle and the index of the processor resource instance in the reserved cycles vector.
Definition at line 1960 of file MachineScheduler.cpp.
References assert(), I, and InvalidCycle.
Compute the next cycle at which the given processor resource unit can be scheduled.
Definition at line 1944 of file MachineScheduler.cpp.
Definition at line 2060 of file MachineScheduler.cpp.
References llvm::dbgs(), and LLVM_DEBUG.
Referenced by findMaxLatency(), and llvm::GenericSchedulerBase::setPolicy().
Definition at line 719 of file MachineScheduler.h.
|
inline |
Get the number of latency cycles "covered" by the scheduled instructions.
This is the larger of the critical path within the zone and the number of cycles required to issue the instructions.
Definition at line 711 of file MachineScheduler.h.
References llvm::max().
Referenced by llvm::tryLatency().
Definition at line 715 of file MachineScheduler.h.
References llvm::SUnit::getDepth(), and llvm::SUnit::getHeight().
|
inline |
Definition at line 739 of file MachineScheduler.h.
Referenced by llvm::GenericSchedulerBase::setPolicy().
Definition at line 2158 of file MachineScheduler.cpp.
References countResource().
| void SchedBoundary::init | ( | ScheduleDAGMI * | dag, |
| const TargetSchedModel * | smodel, | ||
| SchedRemainder * | rem | ||
| ) |
Definition at line 1905 of file MachineScheduler.cpp.
Referenced by llvm::SchedRemainder::init().
|
inline |
Definition at line 742 of file MachineScheduler.h.
Referenced by llvm::GenericSchedulerBase::setPolicy().
|
inline |
Definition at line 695 of file MachineScheduler.h.
References llvm::ReadyQueue::getID().
Referenced by llvm::GCNMaxOccupancySchedStrategy::initialize(), llvm::GenericScheduler::pickNodeFromQueue(), llvm::GenericScheduler::tryCandidate(), and llvm::tryLatency().
| SUnit * SchedBoundary::pickOnlyChoice | ( | ) |
Call this before applying any other heuristics to the Available queue.
If this queue only has one ready candidate, return it.
Updates the Available/Pending Q's if necessary and returns the single available instruction, or NULL if there are multiple candidates.
As a side effect, defer any nodes that now hit a hazard, and advance the cycle until at least one node is ready. If multiple instructions are ready, return NULL.
Definition at line 2388 of file MachineScheduler.cpp.
References I, and LLVM_DEBUG.
Referenced by llvm::GCNMaxOccupancySchedStrategy::initialize(), and llvm::GCNMaxOccupancySchedStrategy::pickNode().
| void SchedBoundary::releaseNode | ( | SUnit * | SU, |
| unsigned | ReadyCycle, | ||
| bool | InPQueue, | ||
| unsigned | Idx = 0 |
||
| ) |
Release SU to make it ready.
If it's not in hazard, remove it from pending queue (if already in) and push into available queue. Otherwise, push the SU into pending queue.
| SU | The unit to be released. |
| ReadyCycle | Until which cycle the unit is ready. |
| InPQueue | Whether SU is already in pending queue. |
| Idx | Position offset in pending queue (if in it). |
Definition at line 2086 of file MachineScheduler.cpp.
References assert(), llvm::SUnit::getInstr(), llvm::max(), and ReadyListLimit.
Referenced by llvm::PostGenericScheduler::releaseTopNode().
| void SchedBoundary::releasePending | ( | ) |
Release pending ready nodes in to the available queue.
This makes them visible to heuristics.
Definition at line 2349 of file MachineScheduler.cpp.
References llvm::SUnit::BotReadyCycle, E, I, llvm::max(), ReadyListLimit, and llvm::SUnit::TopReadyCycle.
| void SchedBoundary::removeReady | ( | SUnit * | SU | ) |
Remove SU from the ready set for this boundary.
Definition at line 2376 of file MachineScheduler.cpp.
References assert().
Referenced by llvm::GCNMaxOccupancySchedStrategy::pickNode().
| void SchedBoundary::reset | ( | ) |
Definition at line 1851 of file MachineScheduler.cpp.
References assert(), llvm::SchedRemainder::init(), and llvm::max().
| ReadyQueue llvm::SchedBoundary::Available |
Definition at line 617 of file MachineScheduler.h.
Referenced by computeRemLatency(), llvm::GCNMaxOccupancySchedStrategy::initialize(), llvm::GCNMaxOccupancySchedStrategy::pickNode(), llvm::GenericScheduler::pickNodeFromQueue(), and llvm::GenericSchedulerBase::setPolicy().
| ScheduleDAGMI* llvm::SchedBoundary::DAG = nullptr |
Definition at line 613 of file MachineScheduler.h.
Referenced by llvm::GCNMaxOccupancySchedStrategy::initialize().
| ScheduleHazardRecognizer* llvm::SchedBoundary::HazardRec = nullptr |
Definition at line 620 of file MachineScheduler.h.
| ReadyQueue llvm::SchedBoundary::Pending |
Definition at line 618 of file MachineScheduler.h.
Referenced by computeRemLatency(), and llvm::GCNMaxOccupancySchedStrategy::pickNode().
| SchedRemainder* llvm::SchedBoundary::Rem = nullptr |
Definition at line 615 of file MachineScheduler.h.
| const TargetSchedModel* llvm::SchedBoundary::SchedModel = nullptr |
Definition at line 614 of file MachineScheduler.h.
1.8.13