14 #ifndef LLVM_MCA_SCHEDULER_H 15 #define LLVM_MCA_SCHEDULER_H 43 int computeRank(
const InstRef &Lhs)
const {
52 int LhsRank = computeRank(Lhs);
53 int RhsRank = computeRank(Rhs);
57 if (LhsRank == RhsRank)
59 return LhsRank < RhsRank;
74 std::unique_ptr<SchedulerStrategy> Strategy;
77 std::unique_ptr<ResourceManager> Resources;
111 std::vector<InstRef> WaitSet;
112 std::vector<InstRef> PendingSet;
113 std::vector<InstRef> ReadySet;
114 std::vector<InstRef> IssuedSet;
121 uint64_t BusyResourceUnits;
125 unsigned NumDispatchedToThePendingSet;
134 void initializeStrategy(std::unique_ptr<SchedulerStrategy> S);
137 void issueInstructionImpl(
161 std::unique_ptr<SchedulerStrategy> SelectStrategy)
163 std::move(SelectStrategy)) {}
166 std::unique_ptr<SchedulerStrategy> SelectStrategy)
167 : LSU(Lsu), Resources(
std::move(RM)), BusyResourceUnits(0),
168 NumDispatchedToThePendingSet(0), HadTokenStall(
false) {
169 initializeStrategy(std::move(SelectStrategy));
203 void issueInstruction(
211 bool mustIssueImmediately(
const InstRef &IR)
const;
235 return Resources->resolveResourceMask(Mask);
270 assert(
find(WaitSet, IR) == WaitSet.end() &&
"Already in the wait set!");
271 assert(
find(ReadySet, IR) == ReadySet.end() &&
"Already in the ready set!");
272 assert(
find(IssuedSet, IR) == IssuedSet.end() &&
"Already executing!");
279 #endif // LLVM_MCA_SCHEDULER_H Instruction * getInstruction()
SchedulerStrategy()=default
virtual bool compare(const InstRef &Lhs, const InstRef &Rhs) const =0
Returns true if Lhs should take priority over Rhs.
bool compare(const InstRef &Lhs, const InstRef &Rhs) const override
Returns true if Lhs should take priority over Rhs.
A resource manager for processor resource units and groups.
This class represents lattice values for constants.
Default instruction selection strategy used by class Scheduler.
void sanityCheck(const InstRef &IR) const
bool isWaitSetEmpty() const
An InstRef contains both a SourceMgr index and Instruction pair.
A Load/Store unit class that models load/store queues and that implements a simple weak memory consis...
unsigned getSourceIndex() const
unsigned getResourceID(uint64_t Mask) const
Convert a resource mask into a valid llvm processor resource identifier.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Abstract base interface for LS (load/store) units in llvm-mca.
Scheduler(const MCSchedModel &Model, LSUnitBase &Lsu, std::unique_ptr< SchedulerStrategy > SelectStrategy)
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
Class Scheduler is responsible for issuing instructions to pipeline resources.
bool isReadySetEmpty() const
This file defines a base class for describing a simulated hardware unit.
Helper functions used by various pipeline components.
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
virtual ~SchedulerStrategy()
The classes here represent processor resource units and their management strategy.
bool hadTokenStall() const
Scheduler(const MCSchedModel &Model, LSUnitBase &Lsu)
unsigned getNumUsers() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Scheduler(std::unique_ptr< ResourceManager > RM, LSUnitBase &Lsu, std::unique_ptr< SchedulerStrategy > SelectStrategy)
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Machine model for scheduling, bundling, and heuristics.
Statically lint checks LLVM IR