22 #define DEBUG_TYPE "misched"
41 void GCNMaxOccupancySchedStrategy::initCandidate(SchedCandidate &Cand,
SUnit *SU,
48 int SGPRCriticalLimit,
49 int VGPRCriticalLimit) {
58 std::vector<unsigned> Pressure;
59 std::vector<unsigned> MaxPressure;
80 const int MaxVGPRPressureInc = 16;
81 bool ShouldTrackVGPRs = VGPRPressure + MaxVGPRPressureInc >= VGPRExcessLimit;
82 bool ShouldTrackSGPRs = !ShouldTrackVGPRs && SGPRPressure >= SGPRExcessLimit;
91 const int ErrorMargin = 3;
92 VGPRExcessLimit -= ErrorMargin;
93 SGPRExcessLimit -= ErrorMargin;
99 if (ShouldTrackVGPRs && NewVGPRPressure >= VGPRExcessLimit) {
101 Cand.RPDelta.Excess.
setUnitInc(NewVGPRPressure - VGPRExcessLimit);
104 if (ShouldTrackSGPRs && NewSGPRPressure >= SGPRExcessLimit) {
106 Cand.RPDelta.Excess.
setUnitInc(NewSGPRPressure = SGPRExcessLimit);
114 VGPRCriticalLimit -= ErrorMargin;
115 SGPRCriticalLimit -= ErrorMargin;
117 int SGPRDelta = NewSGPRPressure - SGPRCriticalLimit;
118 int VGPRDelta = NewVGPRPressure - VGPRCriticalLimit;
120 if (SGPRDelta >= 0 || VGPRDelta >= 0) {
121 if (SGPRDelta > VGPRDelta) {
123 Cand.RPDelta.CriticalMax.
setUnitInc(SGPRDelta);
126 Cand.RPDelta.CriticalMax.
setUnitInc(VGPRDelta);
133 void GCNMaxOccupancySchedStrategy::pickNodeFromQueue(
SchedBoundary &Zone,
134 const CandPolicy &ZonePolicy,
136 SchedCandidate &Cand) {
140 unsigned SGPRPressure = Pressure[SRI->getSGPRPressureSet()];
141 unsigned VGPRPressure = Pressure[SRI->getVGPRPressureSet()];
142 unsigned SGPRExcessLimit =
144 unsigned VGPRExcessLimit =
147 unsigned SGPRCriticalLimit = SRI->getMaxNumSGPRs(ST, MaxWaves,
true);
148 unsigned VGPRCriticalLimit = SRI->getMaxNumVGPRs(MaxWaves);
151 for (
SUnit *SU : Q) {
153 SchedCandidate TryCand(ZonePolicy);
154 initCandidate(TryCand, SU, Zone.
isTop(), RPTracker, SRI,
155 SGPRPressure, VGPRPressure,
156 SGPRExcessLimit, VGPRExcessLimit,
157 SGPRCriticalLimit, VGPRCriticalLimit);
159 SchedBoundary *ZoneArg = Cand.AtTop == TryCand.AtTop ? &Zone :
nullptr;
161 if (TryCand.Reason !=
NoCand) {
163 if (TryCand.ResDelta == SchedResourceDelta())
165 Cand.setBest(TryCand);
182 SUnit *GCNMaxOccupancySchedStrategy::pickNodeBidirectional(
bool &IsTopNode) {
195 CandPolicy BotPolicy;
199 CandPolicy TopPolicy;
226 dbgs() <<
"Top Cand: ";
228 dbgs() <<
"Bot Cand: ";
254 if (TopRank > BotRank) {
262 dbgs() <<
"Picking: ";
266 IsTopNode = Cand.AtTop;
301 SU = pickNodeBidirectional(IsTopNode);
Interface definition for SIRegisterInfo.
SUnit * pickNode(bool &IsTopNode) override
Pick the best node to balance the schedule. Implements MachineSchedStrategy.
AMDGPU specific subclass of TargetSubtarget.
Each Scheduling boundary is associated with ready queues.
const MachineSchedContext * Context
MachineInstr * getInstr() const
getInstr - Return the representative MachineInstr for this SUnit.
void traceCandidate(const SchedCandidate &Cand)
static int getBidirectionalReasonRank(GenericSchedulerBase::CandReason Reason)
void reset(const CandPolicy &NewPolicy)
unsigned getNumAllocatableRegs(const TargetRegisterClass *RC) const
getNumAllocatableRegs - Returns the number of actually allocatable registers in RC in the current fun...
MachineBasicBlock::iterator top() const
const RegPressureTracker & getTopRPTracker() const
const RegPressureTracker & getBotRPTracker() const
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const
Return the maximum number of waves per SIMD for kernels using SGPRs SGPRs.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineSchedPolicy RegionPolicy
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with etc Experimental Use value profile to guide fuzzing Number of simultaneous worker processes to run the jobs If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
unsigned getVGPRPressureSet() const
RegisterClassInfo * RegClassInfo
CandReason
Represent the type of SchedCandidate found within a single queue.
Helpers for implementing custom MachineSchedStrategy classes.
void removeReady(SUnit *SU)
Remove SU from the ready set for this boundary.
static unsigned getMaxWaves(unsigned SGPRs, unsigned VGPRs, const MachineFunction &MF)
unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const
Return the maximum number of waves per SIMD for kernels using VGPRs VGPRs.
void tryCandidate(SchedCandidate &Cand, SchedCandidate &TryCand, SchedBoundary *Zone)
Apply a set of heursitics to a new candidate.
Track the current register pressure at some position in the instruction stream, and remember the high...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Policy for scheduling the next instruction in the candidate's zone.
const TargetSchedModel * SchedModel
const TargetRegisterInfo * TRI
void setPolicy(CandPolicy &Policy, bool IsPostRA, SchedBoundary &CurrZone, SchedBoundary *OtherZone)
Set the CandPolicy given a scheduling zone given the current resources and latencies inside and outsi...
unsigned getOccupancyWithLocalMemSize(uint32_t Bytes) const
Inverse of getMaxLocalMemWithWaveCount.
GenericScheduler shrinks the unscheduled zone using heuristics to balance the schedule.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
PressureChange CriticalMax
MachineBasicBlock::iterator bottom() const
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
Interface definition for SIInstrInfo.
SUnit * pickOnlyChoice()
Call this before applying any other heuristics to the Available queue.
SchedCandidate BotCand
Candidate last picked from Bot boundary.
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
Capture a change in pressure for a single pressure set.
void getUpwardPressure(const MachineInstr *MI, std::vector< unsigned > &PressureResult, std::vector< unsigned > &MaxPressureResult)
Get the pressure of each PSet after traversing this instruction bottom-up.
unsigned getSGPRPressureSet() const
const std::vector< unsigned > & getRegSetPressureAtPos() const
Get the register set pressure at the current position, which may be less than the pressure across the...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
GCNMaxOccupancySchedStrategy(const MachineSchedContext *C)
SchedCandidate TopCand
Candidate last picked from Top boundary.
bool isBottomReady() const
void getDownwardPressure(const MachineInstr *MI, std::vector< unsigned > &PressureResult, std::vector< unsigned > &MaxPressureResult)
Get the pressure of each PSet after traversing this instruction top-down.
SUnit - Scheduling unit. This is a node in the scheduling DAG.