|
LLVM 24.0.0git
|
CandidateHeuristics contains state and implementations to facilitate making per instruction scheduling decisions; it contains methods used in tryCandidate to decide which instruction to schedule next. More...
#include "Target/AMDGPU/AMDGPUCoExecSchedStrategy.h"
Classes | |
| struct | StallCosts |
Protected Member Functions | |
| void | collectRegionSummary () |
| Walk over the region and collect characteristics for the various heuristics. | |
| unsigned | getMaxBlockingCycles (const MCSchedClassDesc *SC, const MachineInstr *MI) |
| unsigned | getHWUICyclesForSU (SUnit *SU) |
Compute the blocking cycles for the appropriate HardwareUnit given an SU. | |
| unsigned | getHWUICyclesForMI (MachineInstr *MI) |
Compute the blocking cycles for the appropriate HardwareUnit given an MI. | |
| unsigned | getCarriedLatency (SUnit *SU) |
Estimate the block carried latency from loads for a given SU. | |
| StallCosts | getStallCosts (SUnit *SU, SchedBoundary &Zone) |
Protected Attributes | |
| ScheduleDAGMI * | DAG |
| const SIInstrInfo * | SII |
| const SIRegisterInfo * | SRI |
| const TargetSchedModel * | SchedModel |
| SmallVector< HardwareUnitInfo, 8 > | HWUInfo |
| DenseMap< MachineInstr *, unsigned > | CarriedLatencies |
CandidateHeuristics contains state and implementations to facilitate making per instruction scheduling decisions; it contains methods used in tryCandidate to decide which instruction to schedule next.
Definition at line 214 of file AMDGPUCoExecSchedStrategy.h.
|
default |
References DAG, SchedModel, and TRI.
|
protected |
Walk over the region and collect characteristics for the various heuristics.
Definition at line 717 of file AMDGPUCoExecSchedStrategy.cpp.
References CarriedLatencies, llvm::AMDGPU::classifyFlavor(), DAG, dumpRegionSummary(), getCarriedLatency(), getHWUICyclesForSU(), HWUInfo, LLVM_DEBUG, MI, SchedModel, and SII.
Referenced by initialize().
| void CandidateHeuristics::dumpRegionSummary | ( | ) |
Definition at line 737 of file AMDGPUCoExecSchedStrategy.cpp.
References DAG, llvm::dbgs(), llvm::AMDGPU::getFlavorName(), llvm::MachineBasicBlock::getNumber(), and HWUInfo.
Referenced by collectRegionSummary().
Estimate the block carried latency from loads for a given SU.
This is essentially global scheduling info that our local scheduling infrastructure lacks the necessary infrastructure to accurately measure. Thus, this method just attempts to find a reasonable upper bound for carried load latency to avoid long stalls.
Definition at line 638 of file AMDGPUCoExecSchedStrategy.cpp.
References assert(), BlockCarriedLatency, llvm::AMDGPU::classifyFlavor(), DAG, llvm::AMDGPU::DS, llvm::AMDGPU::Fence, getHWUICyclesForMI(), llvm::SUnit::getInstr(), I, llvm::SlotIndex::isEarlierInstr(), llvm::Latency, MBB, MI, and SII.
Referenced by collectRegionSummary().
|
protected |
Compute the blocking cycles for the appropriate HardwareUnit given an MI.
Definition at line 597 of file AMDGPUCoExecSchedStrategy.cpp.
References assert(), getMaxBlockingCycles(), MI, and SchedModel.
Referenced by getCarriedLatency().
Compute the blocking cycles for the appropriate HardwareUnit given an SU.
Definition at line 589 of file AMDGPUCoExecSchedStrategy.cpp.
References assert(), DAG, llvm::SUnit::getInstr(), getMaxBlockingCycles(), MI, SchedModel, and SII.
Referenced by collectRegionSummary(), getStallCosts(), and updateForScheduling().
| HardwareUnitInfo * CandidateHeuristics::getHWUIFromFlavor | ( | AMDGPU::InstructionFlavor | Flavor | ) |
Given a Flavor , find the corresponding HardwareUnit.
Definition at line 563 of file AMDGPUCoExecSchedStrategy.cpp.
References HWUInfo.
Referenced by getStallCosts(), and updateForScheduling().
|
protected |
SC. Definition at line 572 of file AMDGPUCoExecSchedStrategy.cpp.
References MI, SchedModel, and SII.
Referenced by getHWUICyclesForMI(), and getHWUICyclesForSU().
|
protected |
Definition at line 810 of file AMDGPUCoExecSchedStrategy.cpp.
References llvm::CandidateHeuristics::StallCosts::Buffer, llvm::CandidateHeuristics::StallCosts::Carried, CarriedLatencies, llvm::AMDGPU::classifyFlavor(), DAG, llvm::AMDGPU::DS, llvm::CandidateHeuristics::StallCosts::Effective, llvm::AMDGPU::Fence, llvm::CandidateHeuristics::StallCosts::Fence, llvm::HardwareUnitInfo::getBufferAvailableCycle(), llvm::HardwareUnitInfo::getBufferSize(), llvm::SchedBoundary::getCurrCycle(), getHWUICyclesForSU(), getHWUIFromFlavor(), llvm::SUnit::getInstr(), llvm::HardwareUnitInfo::getLastScheduledSU(), llvm::SchedBoundary::getLatencyStallCycles(), getStructuralStallCycles(), llvm::SchedBoundary::isTop(), llvm::CandidateHeuristics::StallCosts::Latency, llvm::CandidateHeuristics::StallCosts::Ready, llvm::CandidateHeuristics::StallCosts::Structural, and llvm::SUnit::TopReadyCycle.
Referenced by tryEffectiveStall(), and tryMemoryPipeline().
| unsigned CandidateHeuristics::getStructuralStallCycles | ( | SchedBoundary & | Zone, |
| SUnit * | SU ) |
Definition at line 775 of file AMDGPUCoExecSchedStrategy.cpp.
References assert(), DAG, llvm::SchedBoundary::getCurrCycle(), llvm::SUnit::getInstr(), llvm::SchedBoundary::getNextResourceCycle(), llvm::SUnit::hasReservedResource, llvm::SchedBoundary::HazardRec, llvm::SchedBoundary::isTop(), llvm::make_range(), MI, SchedModel, and llvm::AMDGPU::Stall.
Referenced by getStallCosts().
| void CandidateHeuristics::initialize | ( | ScheduleDAGMI * | DAG, |
| const TargetSchedModel * | SchedModel, | ||
| const TargetRegisterInfo * | TRI ) |
Definition at line 609 of file AMDGPUCoExecSchedStrategy.cpp.
References assert(), collectRegionSummary(), DAG, llvm::AMDGPU::DefaultBufferSizes::DS, llvm::AMDGPU::DS, HWUInfo, I, llvm::AMDGPU::MultiCycleVALU, llvm::AMDGPU::NUM_FLAVORS, SchedModel, SII, SRI, llvm::AMDGPU::TRANS, TRI, and llvm::AMDGPU::WMMA.
| void CandidateHeuristics::sortHWUIResources | ( | ) |
Sort the HardwarUnitInfo vector.
After sorting, the HWUI that are highest priority are first. Priority is determined by maximizing coexecution and keeping the critical HardwareUnit busy.
Definition at line 754 of file AMDGPUCoExecSchedStrategy.cpp.
References A(), B(), HWUInfo, and llvm::sort().
| bool CandidateHeuristics::tryCriticalResource | ( | GenericSchedulerBase::SchedCandidate & | TryCand, |
| GenericSchedulerBase::SchedCandidate & | Cand, | ||
| SchedBoundary * | Zone ) const |
Check for critical resource consumption.
Prefer the candidate that uses the most prioritized HardwareUnit. If both candidates use the same HarwareUnit, prefer the candidate with higher priority on that HardwareUnit.
Definition at line 1022 of file AMDGPUCoExecSchedStrategy.cpp.
References llvm::HardwareUnitInfo::contains(), llvm::AMDGPU::DS, llvm::HardwareUnitInfo::getHigherPriority(), llvm::HardwareUnitInfo::getType(), HWUInfo, I, llvm::GenericSchedulerBase::SchedCandidate::Reason, llvm::GenericSchedulerBase::RegCritical, llvm::GenericSchedulerBase::SchedCandidate::SU, and tryCriticalResourceDependency().
| bool CandidateHeuristics::tryCriticalResourceDependency | ( | GenericSchedulerBase::SchedCandidate & | TryCand, |
| GenericSchedulerBase::SchedCandidate & | Cand, | ||
| SchedBoundary * | Zone ) const |
Check for dependencies of instructions that use prioritized HardwareUnits.
Prefer the candidate that is a dependency of an instruction that uses the most prioritized HardwareUnit. If both candidates enable the same HardwareUnit, prefer the candidate that enables the higher priority instruction on that HardwareUnit.
Definition at line 935 of file AMDGPUCoExecSchedStrategy.cpp.
References llvm::AMDGPU::classifyFlavor(), DAG, llvm::AMDGPU::DS, llvm::Enabled, llvm::SUnit::getHeight(), llvm::SUnit::getInstr(), llvm::HardwareUnitInfo::getNextTargetSU(), llvm::HardwareUnitInfo::getType(), HWUInfo, I, llvm::GenericSchedulerBase::SchedCandidate::Reason, llvm::GenericSchedulerBase::RegCritical, SII, llvm::GenericSchedulerBase::SchedCandidate::SU, and llvm::AMDGPU::WMMA.
Referenced by tryCriticalResource().
| bool CandidateHeuristics::tryEffectiveStall | ( | GenericSchedulerBase::SchedCandidate & | TryCand, |
| GenericSchedulerBase::SchedCandidate & | Cand, | ||
| SchedBoundary & | Zone ) |
Definition at line 873 of file AMDGPUCoExecSchedStrategy.cpp.
References llvm::CandidateHeuristics::StallCosts::Effective, getStallCosts(), llvm::SchedBoundary::isTop(), LLVM_DEBUG, llvm::GenericSchedulerBase::Stall, llvm::GenericSchedulerBase::SchedCandidate::SU, and llvm::tryLess().
| bool CandidateHeuristics::tryMemoryPipeline | ( | GenericSchedulerBase::SchedCandidate & | TryCand, |
| GenericSchedulerBase::SchedCandidate & | Cand, | ||
| SchedBoundary & | Zone ) |
Prioritize instructions involved the memory pipeline.
Currently we don't have any modelling of pipelined loads, so we control the layout of the pipeline per iteration by giving the user some control over the stalls (e.g. between s_barrier_signal and s_barrier_wait) and scheduling the pipeline instructions as soon as they are ready.
TODO – add better modelling and heuristics for pipelining based scheduling.
Definition at line 899 of file AMDGPUCoExecSchedStrategy.cpp.
References llvm::AMDGPU::classifyFlavor(), llvm::AMDGPU::DMA, llvm::CandidateHeuristics::StallCosts::Effective, llvm::AMDGPU::Fence, llvm::SUnit::getInstr(), getStallCosts(), llvm::GenericSchedulerBase::SchedCandidate::Reason, llvm::GenericSchedulerBase::RegCritical, SII, and llvm::GenericSchedulerBase::SchedCandidate::SU.
| void CandidateHeuristics::updateForScheduling | ( | SUnit * | SU | ) |
Update the state to reflect that SU is going to be scheduled.
Definition at line 602 of file AMDGPUCoExecSchedStrategy.cpp.
References assert(), llvm::AMDGPU::classifyFlavor(), getHWUICyclesForSU(), getHWUIFromFlavor(), llvm::SUnit::getInstr(), llvm::HardwareUnitInfo::markScheduled(), and SII.
|
protected |
Definition at line 231 of file AMDGPUCoExecSchedStrategy.h.
Referenced by collectRegionSummary(), and getStallCosts().
|
protected |
Definition at line 226 of file AMDGPUCoExecSchedStrategy.h.
Referenced by CandidateHeuristics(), collectRegionSummary(), dumpRegionSummary(), getCarriedLatency(), getHWUICyclesForSU(), getStallCosts(), getStructuralStallCycles(), initialize(), and tryCriticalResourceDependency().
|
protected |
Definition at line 230 of file AMDGPUCoExecSchedStrategy.h.
Referenced by collectRegionSummary(), dumpRegionSummary(), getHWUIFromFlavor(), initialize(), sortHWUIResources(), tryCriticalResource(), and tryCriticalResourceDependency().
|
protected |
Definition at line 229 of file AMDGPUCoExecSchedStrategy.h.
Referenced by CandidateHeuristics(), collectRegionSummary(), getHWUICyclesForMI(), getHWUICyclesForSU(), getMaxBlockingCycles(), getStructuralStallCycles(), and initialize().
|
protected |
Definition at line 227 of file AMDGPUCoExecSchedStrategy.h.
Referenced by collectRegionSummary(), getCarriedLatency(), getHWUICyclesForSU(), getMaxBlockingCycles(), initialize(), tryCriticalResourceDependency(), tryMemoryPipeline(), and updateForScheduling().
|
protected |
Definition at line 228 of file AMDGPUCoExecSchedStrategy.h.
Referenced by initialize().