30#define DEBUG_TYPE "igrouplp"
36 cl::desc(
"Whether to use the exponential time solver to fit "
37 "the instructions to the pipeline as closely as "
43 cl::desc(
"The maximum number of scheduling group conflicts "
44 "which we attempt to solve with the exponential time "
45 "exact solver. Problem sizes greater than this will"
46 "be solved by the less accurate greedy algorithm. Selecting "
47 "solver by size is superseded by manually selecting "
48 "the solver (e.g. by amdgpu-igrouplp-exact-solver"));
52 cl::desc(
"The amount of branches that we are willing to explore with"
53 "the exact algorithm before giving up."));
57 cl::desc(
"Whether to use the cost heuristic to make choices as we "
58 "traverse the search space using the exact solver. Defaulted "
59 "to on, and if turned off, we will use the node order -- "
60 "attempting to put the later nodes in the later sched groups. "
61 "Experimentally, results are mixed, so this should be set on a "
62 "case-by-case basis."));
66enum class SchedGroupMask {
79 ALL = ALU | VALU | SALU | MFMA | VMEM | VMEM_READ | VMEM_WRITE | DS |
80 DS_READ | DS_WRITE | TRANS,
89class InstructionRule {
95 std::optional<SmallVector<SUnit *, 4>> Cache;
105 bool NeedsCache =
false)
112 virtual ~InstructionRule() =
default;
125 SchedGroupMask SGMask;
128 std::optional<unsigned> MaxSize;
141 static unsigned NumSchedGroups;
158 bool canAddSU(
SUnit &SU)
const;
163 void link(
SUnit &SU,
bool MakePred =
false);
167 int link(
SUnit &SU,
bool MakePred,
168 std::vector<std::pair<SUnit *, SUnit *>> &AddedEdges);
177 void link(SchedGroup &OtherGroup);
180 bool isFull()
const {
return MaxSize && Collection.
size() >= *MaxSize; }
186 void addRule(std::shared_ptr<InstructionRule> NewRule) {
191 bool allowedByRules(
const SUnit *SU,
193 for (
auto &Rule : Rules) {
194 if (!Rule.get()->apply(SU, Collection, SyncPipe))
201 void add(
SUnit &SU) {
203 <<
format_hex((
int)SGMask, 10,
true) <<
" adding "
209 void pop() { Collection.
pop_back(); }
212 void initSchedGroup();
219 void initSchedGroup(std::vector<SUnit>::reverse_iterator RIter,
220 SUnitsToCandidateSGsMap &SyncedInstrs);
222 void initSchedGroup(SUnitsToCandidateSGsMap &SyncedInstrs);
224 int getSyncID() {
return SyncID; }
226 int getSGID() {
return SGID; }
228 SchedGroupMask getMask() {
return SGMask; }
230 SchedGroup(SchedGroupMask SGMask, std::optional<unsigned> MaxSize,
232 : SGMask(SGMask), MaxSize(MaxSize), DAG(DAG),
TII(
TII) {
233 SGID = NumSchedGroups++;
236 SchedGroup(SchedGroupMask SGMask, std::optional<unsigned> MaxSize,
int SyncID,
238 : SGMask(SGMask), MaxSize(MaxSize), SyncID(SyncID), DAG(DAG),
TII(
TII) {
239 SGID = NumSchedGroups++;
249 while (!SU.
Preds.empty())
253 while (!SU.
Succs.empty())
254 for (
auto &S : SU.
Succs)
255 for (
auto &SP : S.getSUnit()->Preds)
256 if (SP.getSUnit() == &SU)
257 S.getSUnit()->removePred(SP);
260using SUToCandSGsPair = std::pair<SUnit *, SmallVector<int, 4>>;
272class PipelineSolver {
285 bool NeedsSolver =
false;
289 unsigned computeProblemSize();
300 int CurrConflInstNo = 0;
302 int CurrSyncGroupIdx = 0;
304 int BeginSyncGroupIdx = 0;
310 bool IsBottomUp =
true;
313 void advancePosition();
316 void retreatPosition();
325 template <
typename T>
326 void greedyFind(std::vector<std::pair<SUnit *, SUnit *>> &AddedEdges,
T I,
332 template <
typename T>
339 template <
typename T>
void linkSchedGroups(
T I,
T E);
343 std::vector<std::pair<SUnit *, SUnit *>> &AddedEdges);
347 template <
typename T>
348 int linkSUnit(
SUnit *SU,
int SGID,
349 std::vector<std::pair<SUnit *, SUnit *>> &AddedEdges,
T I,
T E);
351 void removeEdges(
const std::vector<std::pair<SUnit *, SUnit *>> &AddedEdges);
353 void convertSyncMapsToArrays();
365 : DAG(DAG), SyncedInstrs(SyncedInstrs),
366 SyncedSchedGroups(SyncedSchedGroups), IsBottomUp(IsBottomUp) {
368 for (
auto &PipelineInstrs : SyncedInstrs) {
369 if (PipelineInstrs.second.
size() > 0) {
378 convertSyncMapsToArrays();
380 CurrPipeline = BestPipeline;
382 while (
static_cast<size_t>(BeginSyncGroupIdx) < PipelineInstrs.
size() &&
383 PipelineInstrs[BeginSyncGroupIdx].
size() == 0)
386 if (
static_cast<size_t>(BeginSyncGroupIdx) >= PipelineInstrs.
size())
391void PipelineSolver::reset() {
393 for (
auto &SyncPipeline : CurrPipeline) {
394 for (
auto &SG : SyncPipeline) {
396 SG.Collection.
clear();
400 if (SchedBarr != TempCollection.
end())
401 SG.Collection.push_back(*SchedBarr);
405 CurrSyncGroupIdx = BeginSyncGroupIdx;
410void PipelineSolver::convertSyncMapsToArrays() {
411 for (
auto &SyncPipe : SyncedSchedGroups) {
412 BestPipeline.insert(BestPipeline.begin(), SyncPipe.second);
415 int PipelineIDx = SyncedInstrs.size() - 1;
416 PipelineInstrs.resize(SyncedInstrs.size());
417 for (
auto &SyncInstrMap : SyncedInstrs) {
418 for (
auto &SUsToCandSGs : SyncInstrMap.second) {
419 if (PipelineInstrs[PipelineIDx].
size() == 0) {
420 PipelineInstrs[PipelineIDx].push_back(
421 std::pair(SUsToCandSGs.first, SUsToCandSGs.second));
424 auto SortPosition = PipelineInstrs[PipelineIDx].begin();
427 while (SortPosition != PipelineInstrs[PipelineIDx].end() &&
428 SUsToCandSGs.first->NodeNum > SortPosition->first->NodeNum)
430 PipelineInstrs[PipelineIDx].insert(
431 SortPosition, std::pair(SUsToCandSGs.first, SUsToCandSGs.second));
437template <
typename T>
void PipelineSolver::linkSchedGroups(
T I,
T E) {
438 for (;
I != E; ++
I) {
440 for (
auto J = std::next(
I); J != E; ++J) {
447void PipelineSolver::makePipeline() {
449 for (
auto &SyncPipeline : BestPipeline) {
451 for (
auto &SG : SyncPipeline) {
454 SUnit *SGBarr =
nullptr;
455 for (
auto &SU : SG.Collection) {
463 resetEdges(*SGBarr, DAG);
464 SG.link(*SGBarr,
false);
468 for (
auto &SyncPipeline : BestPipeline) {
469 IsBottomUp ? linkSchedGroups(SyncPipeline.rbegin(), SyncPipeline.rend())
470 : linkSchedGroups(SyncPipeline.begin(), SyncPipeline.end());
475int PipelineSolver::linkSUnit(
476 SUnit *SU,
int SGID, std::vector<std::pair<SUnit *, SUnit *>> &AddedEdges,
478 bool MakePred =
false;
481 if (
I->getSGID() == SGID) {
486 AddedCost += Group.link(*SU, MakePred, AddedEdges);
492int PipelineSolver::addEdges(
494 std::vector<std::pair<SUnit *, SUnit *>> &AddedEdges) {
504 return IsBottomUp ? linkSUnit(SU, SGID, AddedEdges, SyncPipeline.
rbegin(),
506 : linkSUnit(SU, SGID, AddedEdges, SyncPipeline.
begin(),
510void PipelineSolver::removeEdges(
511 const std::vector<std::pair<SUnit *, SUnit *>> &EdgesToRemove) {
514 for (
auto &PredSuccPair : EdgesToRemove) {
515 SUnit *Pred = PredSuccPair.first;
516 SUnit *Succ = PredSuccPair.second;
519 Succ->
Preds, [&Pred](
SDep &
P) { return P.getSUnit() == Pred; });
527void PipelineSolver::advancePosition() {
530 if (
static_cast<size_t>(CurrConflInstNo) >=
531 PipelineInstrs[CurrSyncGroupIdx].
size()) {
535 while (
static_cast<size_t>(CurrSyncGroupIdx) < PipelineInstrs.size() &&
536 PipelineInstrs[CurrSyncGroupIdx].size() == 0)
541void PipelineSolver::retreatPosition() {
542 assert(CurrConflInstNo >= 0);
543 assert(CurrSyncGroupIdx >= 0);
545 if (CurrConflInstNo > 0) {
550 if (CurrConflInstNo == 0) {
553 if (CurrSyncGroupIdx == BeginSyncGroupIdx)
558 while (PipelineInstrs[CurrSyncGroupIdx].
size() == 0)
561 CurrConflInstNo = PipelineInstrs[CurrSyncGroupIdx].size() - 1;
565bool PipelineSolver::checkOptimal() {
566 if (
static_cast<size_t>(CurrSyncGroupIdx) == PipelineInstrs.size()) {
567 if (BestCost == -1 || CurrCost < BestCost) {
568 BestPipeline = CurrPipeline;
575 bool DoneExploring =
false;
576 if (MaxBranchesExplored > 0 && BranchesExplored >= MaxBranchesExplored)
577 DoneExploring =
true;
579 return (DoneExploring || BestCost == 0);
583void PipelineSolver::populateReadyList(
585 SUToCandSGsPair CurrSU = PipelineInstrs[CurrSyncGroupIdx][CurrConflInstNo];
586 auto SyncPipeline = CurrPipeline[CurrSyncGroupIdx];
587 assert(CurrSU.second.size() >= 1);
589 for (;
I != E; ++
I) {
590 std::vector<std::pair<SUnit *, SUnit *>> AddedEdges;
593 return SG.getSGID() == CandSGID;
598 if (
Match->isFull()) {
599 ReadyList.push_back(std::pair(*
I, MissPenalty));
603 int TempCost = addEdges(SyncPipeline, CurrSU.first, CandSGID, AddedEdges);
604 ReadyList.push_back(std::pair(*
I, TempCost));
605 removeEdges(AddedEdges);
607 ReadyList.push_back(std::pair(*
I, -1));
611 std::sort(ReadyList.begin(), ReadyList.end(),
612 [](std::pair<int, int>
A, std::pair<int, int>
B) {
613 return A.second < B.second;
617 assert(ReadyList.size() == CurrSU.second.size());
620bool PipelineSolver::solveExact() {
624 if (
static_cast<size_t>(CurrSyncGroupIdx) == PipelineInstrs.size())
627 assert(
static_cast<size_t>(CurrSyncGroupIdx) < PipelineInstrs.size());
628 assert(
static_cast<size_t>(CurrConflInstNo) <
629 PipelineInstrs[CurrSyncGroupIdx].
size());
630 SUToCandSGsPair CurrSU = PipelineInstrs[CurrSyncGroupIdx][CurrConflInstNo];
632 <<
") in Pipeline # " << CurrSyncGroupIdx <<
"\n");
637 IsBottomUp ? populateReadyList(ReadyList, CurrSU.second.
rbegin(),
638 CurrSU.second.rend())
639 : populateReadyList(ReadyList, CurrSU.second.
begin(),
640 CurrSU.second.end());
642 auto I = ReadyList.
begin();
643 auto E = ReadyList.
end();
644 for (;
I != E; ++
I) {
648 if (BestCost != -1 && (CurrCost +
I->second > BestCost))
651 int CandSGID =
I->first;
653 std::vector<std::pair<SUnit *, SUnit *>> AddedEdges;
654 auto &SyncPipeline = CurrPipeline[CurrSyncGroupIdx];
656 for (
auto &SG : SyncPipeline) {
657 if (SG.getSGID() == CandSGID)
664 if (!
Match->allowedByRules(CurrSU.first, SyncPipeline))
668 << (
int)
Match->getMask() <<
"and ID " << CandSGID
670 Match->add(*CurrSU.first);
671 AddedCost = addEdges(SyncPipeline, CurrSU.first, CandSGID, AddedEdges);
672 LLVM_DEBUG(
dbgs() <<
"Cost of Assignment: " << AddedCost <<
"\n");
673 CurrCost += AddedCost;
676 bool FinishedExploring =
false;
679 if (CurrCost < BestCost || BestCost == -1) {
681 FinishedExploring = BestCost != 0;
682 if (!FinishedExploring)
688 CurrCost -= AddedCost;
689 removeEdges(AddedEdges);
691 CurrPipeline[CurrSyncGroupIdx] = SyncPipeline;
692 if (FinishedExploring)
699 CurrCost += MissPenalty;
702 LLVM_DEBUG(
dbgs() <<
"NOT Assigned (" << CurrSU.first->NodeNum <<
")\n");
704 bool FinishedExploring =
false;
705 if (CurrCost < BestCost || BestCost == -1) {
707 bool FinishedExploring = BestCost != 0;
708 if (!FinishedExploring)
714 CurrCost -= MissPenalty;
715 return FinishedExploring;
719void PipelineSolver::greedyFind(
720 std::vector<std::pair<SUnit *, SUnit *>> &AddedEdges,
T I,
T E) {
721 SUToCandSGsPair CurrSU = PipelineInstrs[CurrSyncGroupIdx][CurrConflInstNo];
722 int BestNodeCost = -1;
724 SchedGroup *BestGroup =
nullptr;
725 int BestGroupID = -1;
726 auto &SyncPipeline = CurrPipeline[CurrSyncGroupIdx];
728 <<
") in Pipeline # " << CurrSyncGroupIdx <<
"\n");
734 for (;
I != E; ++
I) {
735 std::vector<std::pair<SUnit *, SUnit *>> AddedEdges;
738 return SG.getSGID() == CandSGID;
742 LLVM_DEBUG(
dbgs() <<
"Trying SGID # " << CandSGID <<
" with Mask "
743 << (
int)
Match->getMask() <<
"\n");
745 if (
Match->isFull()) {
749 if (!
Match->allowedByRules(CurrSU.first, SyncPipeline)) {
750 LLVM_DEBUG(
dbgs() <<
"SGID # " << CandSGID <<
" has conflicting rule\n");
753 TempCost = addEdges(SyncPipeline, CurrSU.first, CandSGID, AddedEdges);
755 if (TempCost < BestNodeCost || BestNodeCost == -1) {
757 BestNodeCost = TempCost;
758 BestGroupID = CandSGID;
760 removeEdges(AddedEdges);
761 if (BestNodeCost == 0)
765 if (BestGroupID != -1) {
766 BestGroup->add(*CurrSU.first);
767 addEdges(SyncPipeline, CurrSU.first, BestGroupID, AddedEdges);
768 LLVM_DEBUG(
dbgs() <<
"Best Group has ID: " << BestGroupID <<
" and Mask"
769 << (
int)BestGroup->getMask() <<
"\n");
770 BestCost += TempCost;
772 BestCost += MissPenalty;
774 CurrPipeline[CurrSyncGroupIdx] = SyncPipeline;
777bool PipelineSolver::solveGreedy() {
779 std::vector<std::pair<SUnit *, SUnit *>> AddedEdges;
781 while (
static_cast<size_t>(CurrSyncGroupIdx) < PipelineInstrs.size()) {
782 SUToCandSGsPair CurrSU = PipelineInstrs[CurrSyncGroupIdx][CurrConflInstNo];
784 ? greedyFind(AddedEdges, CurrSU.second.rbegin(), CurrSU.second.rend())
785 : greedyFind(AddedEdges, CurrSU.second.begin(), CurrSU.second.end());
788 BestPipeline = CurrPipeline;
789 removeEdges(AddedEdges);
793unsigned PipelineSolver::computeProblemSize() {
794 unsigned ProblemSize = 0;
795 for (
auto &PipeConflicts : PipelineInstrs) {
796 ProblemSize += PipeConflicts.size();
802void PipelineSolver::solve() {
806 unsigned ProblemSize = computeProblemSize();
809 bool BelowCutoff = (CutoffForExact > 0) && ProblemSize <= CutoffForExact;
810 MissPenalty = (ProblemSize / 2) + 1;
813 if (EnableExactSolver || BelowCutoff) {
817 LLVM_DEBUG(
dbgs() <<
"Greedy produced best cost of " << BestCost <<
"\n");
821 LLVM_DEBUG(
dbgs() <<
"Exact produced best cost of " << BestCost <<
"\n");
833enum IGLPStrategyID :
int {
834 MFMASmallGemmOptID = 0,
835 MFMASmallGemmSingleWaveOptID = 1,
836 MFMAExpInterleave = 2
848 virtual bool applyIGLPStrategy(
857 bool IsBottomUp =
true;
862 virtual ~IGLPStrategy() =
default;
865class MFMASmallGemmOpt final :
public IGLPStrategy {
868 bool applyIGLPStrategy(
879 : IGLPStrategy(DAG,
TII) {
884bool MFMASmallGemmOpt::applyIGLPStrategy(
889 unsigned MFMACount = 0;
891 if (
TII->isMFMAorWMMA(
I))
894 const unsigned PipelineSyncID = 0;
895 SchedGroup *SG =
nullptr;
896 for (
unsigned I = 0;
I < MFMACount * 3; ++
I) {
897 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
898 SchedGroupMask::DS, 2, PipelineSyncID, DAG,
TII);
899 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
901 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
902 SchedGroupMask::MFMA, 1, PipelineSyncID, DAG,
TII);
903 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
909class MFMAExpInterleaveOpt final :
public IGLPStrategy {
912 static unsigned TransPipeCount;
914 static unsigned MFMAPipeCount;
916 static unsigned AddPipeCount;
918 static unsigned MFMAEnablement;
920 static unsigned ExpRequirement;
922 static unsigned MFMAChains;
924 static unsigned MFMAChainLength;
929 static bool HasChainBetweenCvt;
931 static std::optional<unsigned> FirstPipeDSR;
940 class IsPipeExp final :
public InstructionRule {
945 auto DAG = SyncPipe[0].DAG;
947 if (Cache->empty()) {
949 auto E = DAG->
SUnits.rend();
950 for (;
I != E;
I++) {
951 if (
TII->isMFMAorWMMA(*
I->getInstr()))
952 Cache->push_back(&*
I);
958 auto Reaches =
any_of(*Cache, [&SU, &DAG](
SUnit *TargetSU) {
964 IsPipeExp(
const SIInstrInfo *
TII,
unsigned SGID,
bool NeedsCache =
false)
965 : InstructionRule(
TII, SGID, NeedsCache) {}
970 class EnablesNthMFMA final :
public InstructionRule {
977 bool FoundTrans =
false;
978 unsigned Counter = 1;
979 auto DAG = SyncPipe[0].DAG;
981 if (Cache->empty()) {
985 auto E = DAG->
SUnits.end();
986 for (;
I != E;
I++) {
987 if (FoundTrans &&
TII->isMFMAorWMMA(*
I->getInstr())) {
989 Cache->push_back(&*
I);
994 if (!FoundTrans &&
TII->isTRANS(
I->getInstr()->getOpcode()))
1005 bool NeedsCache =
false)
1011 class EnablesNthMFMAInChain final :
public InstructionRule {
1019 auto DAG = SyncPipe[0].DAG;
1021 if (!SU || !
TII->isMFMAorWMMA(*ChainSeed->
getInstr()))
1024 if (Cache->empty()) {
1025 auto TempSU = ChainSeed;
1030 for (
auto &Succ : TempSU->Succs) {
1031 if (
TII->isMFMAorWMMA(*Succ.getSUnit()->getInstr())) {
1032 TempSU = Succ.getSUnit();
1041 Cache->push_back(TempSU);
1050 EnablesNthMFMAInChain(
unsigned Number,
SUnit *ChainSeed,
1052 bool NeedsCache =
false)
1054 ChainSeed(ChainSeed) {}
1060 class LessThanNSuccs final :
public InstructionRule {
1063 bool HasIntermediary =
false;
1068 if (!SyncPipe.
size())
1071 auto SuccSize = std::count_if(
1073 [](
const SDep &Succ) { return Succ.getKind() == SDep::Data; });
1074 if (SuccSize >= Size)
1077 if (HasIntermediary) {
1078 for (
auto Succ : SU->
Succs) {
1079 auto SuccSize = std::count_if(
1081 [](
const SDep &SuccSucc) {
1082 return SuccSucc.getKind() == SDep::Data;
1084 if (SuccSize >= Size)
1091 LessThanNSuccs(
unsigned Size,
const SIInstrInfo *
TII,
unsigned SGID,
1092 bool HasIntermediary =
false,
bool NeedsCache =
false)
1093 : InstructionRule(
TII, SGID, NeedsCache), Size(Size),
1094 HasIntermediary(HasIntermediary) {}
1101 class GreaterThanOrEqualToNSuccs final :
public InstructionRule {
1104 bool HasIntermediary =
false;
1109 if (!SyncPipe.
size())
1112 auto SuccSize = std::count_if(
1114 [](
const SDep &Succ) { return Succ.getKind() == SDep::Data; });
1115 if (SuccSize >= Size)
1118 if (HasIntermediary) {
1119 for (
auto Succ : SU->
Succs) {
1120 auto SuccSize = std::count_if(
1122 [](
const SDep &SuccSucc) {
1123 return SuccSucc.getKind() == SDep::Data;
1125 if (SuccSize >= Size)
1132 GreaterThanOrEqualToNSuccs(
unsigned Size,
const SIInstrInfo *
TII,
1133 unsigned SGID,
bool HasIntermediary =
false,
1134 bool NeedsCache =
false)
1135 : InstructionRule(
TII, SGID, NeedsCache), Size(Size),
1136 HasIntermediary(HasIntermediary) {}
1140 class IsCvt final :
public InstructionRule {
1145 return Opc == AMDGPU::V_CVT_F16_F32_e32 ||
1146 Opc == AMDGPU::V_CVT_I32_F32_e32;
1148 IsCvt(
const SIInstrInfo *
TII,
unsigned SGID,
bool NeedsCache =
false)
1149 : InstructionRule(
TII, SGID, NeedsCache) {}
1153 class IsFMA final :
public InstructionRule {
1160 IsFMA(
const SIInstrInfo *
TII,
unsigned SGID,
bool NeedsCache =
false)
1161 : InstructionRule(
TII, SGID, NeedsCache) {}
1165 class IsPipeAdd final :
public InstructionRule {
1171 IsPipeAdd(
const SIInstrInfo *
TII,
unsigned SGID,
bool NeedsCache =
false)
1172 : InstructionRule(
TII, SGID, NeedsCache) {}
1177 class IsSuccOfPrevNthGroup final :
public InstructionRule {
1179 unsigned Distance = 1;
1184 SchedGroup *OtherGroup =
nullptr;
1185 if (!SyncPipe.
size())
1188 for (
auto &PipeSG : SyncPipe) {
1189 if ((
unsigned)PipeSG.getSGID() == SGID - Distance)
1190 OtherGroup = &PipeSG;
1195 if (!OtherGroup->Collection.size())
1198 for (
auto &OtherEle : OtherGroup->Collection) {
1199 for (
auto &Succ : OtherEle->Succs) {
1200 if (Succ.getSUnit() == SU && Succ.getKind() ==
SDep::Data)
1208 unsigned SGID,
bool NeedsCache =
false)
1209 : InstructionRule(
TII, SGID, NeedsCache), Distance(Distance) {}
1214 class IsReachableFromPrevNthGroup final :
public InstructionRule {
1216 unsigned Distance = 1;
1221 SchedGroup *OtherGroup =
nullptr;
1222 if (!SyncPipe.
size())
1225 for (
auto &PipeSG : SyncPipe) {
1226 if ((
unsigned)PipeSG.getSGID() == SGID - Distance)
1227 OtherGroup = &PipeSG;
1232 if (!OtherGroup->Collection.size())
1235 auto DAG = SyncPipe[0].DAG;
1237 for (
auto &OtherEle : OtherGroup->Collection)
1243 IsReachableFromPrevNthGroup(
unsigned Distance,
const SIInstrInfo *
TII,
1244 unsigned SGID,
bool NeedsCache =
false)
1245 : InstructionRule(
TII, SGID, NeedsCache), Distance(Distance) {}
1249 class OccursAtOrAfterNode final :
public InstructionRule {
1260 bool NeedsCache =
false)
1266 class IsExactMFMA final :
public InstructionRule {
1274 if (!SU || !
TII->isMFMAorWMMA(*ChainSeed->
getInstr()))
1277 if (Cache->empty()) {
1278 auto TempSU = ChainSeed;
1283 for (
auto &Succ : TempSU->Succs) {
1284 if (
TII->isMFMAorWMMA(*Succ.getSUnit()->getInstr())) {
1285 TempSU = Succ.getSUnit();
1294 Cache->push_back(TempSU);
1300 return (*Cache)[0] == SU;
1304 unsigned SGID,
bool NeedsCache =
false)
1306 ChainSeed(ChainSeed) {}
1312 class OccursAfterExp final :
public InstructionRule {
1318 auto DAG = SyncPipe[0].DAG;
1319 if (Cache->empty()) {
1320 for (
auto &SU : DAG->
SUnits)
1329 return SU->
NodeNum > (*Cache)[0]->NodeNum;
1333 bool NeedsCache =
false)
1334 : InstructionRule(
TII, SGID, NeedsCache) {}
1338 bool applyIGLPStrategy(
1347 : IGLPStrategy(DAG,
TII) {
1352unsigned MFMAExpInterleaveOpt::TransPipeCount = 0;
1353unsigned MFMAExpInterleaveOpt::MFMAPipeCount = 0;
1354unsigned MFMAExpInterleaveOpt::AddPipeCount = 0;
1355unsigned MFMAExpInterleaveOpt::MFMAEnablement = 0;
1356unsigned MFMAExpInterleaveOpt::ExpRequirement = 0;
1357unsigned MFMAExpInterleaveOpt::MFMAChains = 0;
1358unsigned MFMAExpInterleaveOpt::MFMAChainLength = 0;
1359bool MFMAExpInterleaveOpt::HasCvt =
false;
1360bool MFMAExpInterleaveOpt::HasChainBetweenCvt =
false;
1361std::optional<unsigned> MFMAExpInterleaveOpt::FirstPipeDSR = std::nullopt;
1370 auto isBitPack = [](
unsigned Opc) {
1371 return Opc == AMDGPU::V_PACK_B32_F16_e64 || Opc == AMDGPU::V_PERM_B32_e64;
1374 auto isCvt = [](
unsigned Opc) {
1375 return Opc == AMDGPU::V_CVT_F16_F32_e32 || Opc == AMDGPU::V_CVT_I32_F32_e32;
1378 auto isAdd = [](
unsigned Opc) {
return Opc == AMDGPU::V_ADD_F32_e32; };
1383 if (
TII->isTRANS(Opc)) {
1385 if (SU.
Succs.size() >= 7)
1387 for (
auto &Succ : SU.
Succs) {
1388 if (Succ.getSUnit()->Succs.size() >= 7)
1407 if (!(PackSUs.
size() && MFMAPipeCands.
size() && ExpPipeCands.
size()))
1412 std::optional<SUnit *> TempMFMA;
1413 std::optional<SUnit *> TempExp;
1415 for (
auto &PredSU : ExpPipeCands) {
1416 for (
auto &SuccSU : MFMAPipeCands) {
1429 if (!(TempExp && TempMFMA))
1432 HasChainBetweenCvt =
none_of((*TempExp)->Succs, [&isCvt](
SDep &Succ) {
1433 return isCvt(Succ.getSUnit()->getInstr()->getOpcode());
1437 for (
auto &SuccSU : MFMAPipeCands) {
1438 if (MFMAPipeSUs.
size() &&
1439 any_of(MFMAPipeSUs, [&SuccSU](
SUnit *PotentialMatch) {
1440 return PotentialMatch->
NodeNum == SuccSU->NodeNum;
1444 for (
auto &PredSU : ExpPipeCands) {
1452 MFMAPipeCount = MFMAPipeSUs.
size();
1454 assert(TempExp && TempMFMA);
1455 assert(MFMAPipeCount > 0);
1457 std::optional<SUnit *> TempCvt;
1458 for (
auto &SuccSU : CvtSUs) {
1466 if (TempCvt.has_value()) {
1467 for (
auto &SuccSU : MFMAPipeSUs) {
1476 for (
auto &MFMAPipeSU : MFMAPipeSUs) {
1480 return TII->isMFMAorWMMA(*Succ.getSUnit()->getInstr());
1482 MFMAChainSeeds.push_back(MFMAPipeSU);
1490 for (
auto Pred : MFMAChainSeeds[0]->Preds) {
1491 if (
TII->isDS(Pred.getSUnit()->getInstr()->getOpcode()) &&
1492 Pred.getSUnit()->getInstr()->mayLoad())
1493 FirstPipeDSR = Pred.getSUnit()->NodeNum;
1496 MFMAChainLength = MFMAPipeCount / MFMAChains;
1499 unsigned PackSuccCount = std::count_if(
1500 PackSUs.
begin(), PackSUs.
end(), [
this, &TempExp](
SUnit *VPack) {
1501 return DAG->IsReachable(VPack, *TempExp);
1505 unsigned PackPredCount =
1506 std::count_if((*TempMFMA)->Preds.begin(), (*TempMFMA)->Preds.end(),
1507 [&isBitPack](
SDep &Pred) {
1508 auto Opc = Pred.getSUnit()->getInstr()->getOpcode();
1509 return isBitPack(Opc);
1513 std::find_if((*TempMFMA)->Preds.begin(), (*TempMFMA)->Preds.end(),
1514 [&isBitPack](
SDep &Pred) {
1515 auto Opc = Pred.getSUnit()->getInstr()->getOpcode();
1516 return isBitPack(Opc);
1519 if (PackPred == (*TempMFMA)->Preds.end())
1526 std::count_if(PackPred->getSUnit()->Succs.begin(),
1527 PackPred->getSUnit()->Succs.end(), [&
TII](
SDep &Succ) {
1528 return TII->isMFMAorWMMA(*Succ.getSUnit()->getInstr());
1532 MFMAEnablement *= PackSuccCount;
1536 std::count_if(ExpPipeCands.
begin(), ExpPipeCands.
end(),
1537 [
this, &PackPred](
SUnit *ExpBase) {
1538 return DAG->IsReachable(PackPred->getSUnit(), ExpBase);
1541 ExpRequirement *= PackPredCount;
1550 if (
Phase != AMDGPU::SchedulingPhase::PostRA)
1551 MFMAChainSeeds.clear();
1552 if (
Phase != AMDGPU::SchedulingPhase::PostRA && !analyzeDAG(
TII))
1558bool MFMAExpInterleaveOpt::applyIGLPStrategy(
1563 bool IsSmallKernelType =
1564 MFMAEnablement == 2 && ExpRequirement == 4 && TransPipeCount == 32;
1565 bool IsLargeKernelType =
1566 MFMAEnablement == 4 && ExpRequirement == 4 && TransPipeCount == 64;
1568 if (!(IsSmallKernelType || IsLargeKernelType))
1574 unsigned PipelineSyncID = 0;
1575 SchedGroup *SG =
nullptr;
1577 unsigned MFMAChain = 0;
1578 unsigned PositionInChain = 0;
1579 unsigned CurrMFMAForTransPosition = 0;
1581 auto incrementTransPosition = [&MFMAChain, &PositionInChain,
1582 &CurrMFMAForTransPosition]() {
1583 CurrMFMAForTransPosition += MFMAEnablement;
1584 PositionInChain = (CurrMFMAForTransPosition / MFMAChains);
1585 MFMAChain = CurrMFMAForTransPosition % MFMAChains;
1588 auto getNextTransPositionInChain = [&CurrMFMAForTransPosition]() {
1589 auto TempMFMAForTrans = CurrMFMAForTransPosition + MFMAEnablement;
1590 return (TempMFMAForTrans / MFMAChains);
1593 auto getNextTransMFMAChain = [&CurrMFMAForTransPosition]() {
1594 auto TempMFMAForTrans = CurrMFMAForTransPosition + MFMAEnablement;
1595 return TempMFMAForTrans % MFMAChains;
1598 unsigned CurrMFMAPosition = 0;
1599 unsigned MFMAChainForMFMA = 0;
1600 unsigned PositionInChainForMFMA = 0;
1602 auto incrementMFMAPosition = [&CurrMFMAPosition, &MFMAChainForMFMA,
1603 &PositionInChainForMFMA]() {
1605 MFMAChainForMFMA = CurrMFMAPosition % MFMAChains;
1606 PositionInChainForMFMA = CurrMFMAPosition / MFMAChains;
1609 bool IsPostRA =
Phase == AMDGPU::SchedulingPhase::PostRA;
1610 assert(IsPostRA || MFMAChainSeeds.size() == MFMAChains);
1612 bool UsesFMA = IsSmallKernelType || !IsPostRA;
1613 bool UsesDSRead = IsLargeKernelType && !IsPostRA && FirstPipeDSR;
1614 bool UsesCvt = HasCvt && (IsSmallKernelType || !IsPostRA);
1615 bool UsesVALU = IsSmallKernelType;
1620 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1621 SchedGroupMask::VALU, ExpRequirement, PipelineSyncID, DAG,
TII);
1622 if (!IsPostRA && MFMAChains) {
1623 SG->addRule(std::make_shared<EnablesNthMFMAInChain>(
1624 PositionInChain, MFMAChainSeeds[MFMAChain],
TII, SG->getSGID(),
1628 std::make_shared<EnablesNthMFMA>(1,
TII, SG->getSGID(),
true));
1629 SG->addRule(std::make_shared<IsFMA>(
TII, SG->getSGID()));
1630 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1633 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1634 SchedGroupMask::VALU, ExpRequirement, PipelineSyncID, DAG,
TII);
1635 if (!IsPostRA && MFMAChains) {
1636 SG->addRule(std::make_shared<EnablesNthMFMAInChain>(
1637 getNextTransPositionInChain(),
1638 MFMAChainSeeds[getNextTransMFMAChain()],
TII, SG->getSGID(),
true));
1640 SG->addRule(std::make_shared<EnablesNthMFMA>(MFMAEnablement + 1,
TII,
1641 SG->getSGID(),
true));
1642 SG->addRule(std::make_shared<IsFMA>(
TII, SG->getSGID()));
1643 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1647 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1648 SchedGroupMask::DS_READ, 2, PipelineSyncID, DAG,
TII);
1649 SG->addRule(std::make_shared<OccursAtOrAfterNode>(*FirstPipeDSR,
TII,
1651 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1655 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1656 SchedGroupMask::TRANS, ExpRequirement, PipelineSyncID, DAG,
TII);
1657 if (!IsPostRA && MFMAChains)
1658 SG->addRule(std::make_shared<EnablesNthMFMAInChain>(
1659 PositionInChain, MFMAChainSeeds[MFMAChain],
TII, SG->getSGID(),
true));
1661 SG->addRule(std::make_shared<EnablesNthMFMA>(1,
TII, SG->getSGID(),
true));
1662 SG->addRule(std::make_shared<IsPipeExp>(
TII, SG->getSGID(),
true));
1663 SG->addRule(std::make_shared<LessThanNSuccs>(8,
TII, SG->getSGID(),
1664 HasChainBetweenCvt));
1665 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1667 incrementTransPosition();
1670 for (
unsigned I = 0;
I < ExpRequirement;
I++) {
1673 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1674 SchedGroupMask::VALU, 1, PipelineSyncID, DAG,
TII);
1675 SG->addRule(std::make_shared<IsCvt>(
TII, SG->getSGID()));
1676 if (HasChainBetweenCvt)
1677 SG->addRule(std::make_shared<IsReachableFromPrevNthGroup>(
1678 1 + (2 + UsesFMA) *
I,
TII, SG->getSGID()));
1680 SG->addRule(std::make_shared<IsSuccOfPrevNthGroup>(
1681 1 + (2 + UsesFMA) *
I,
TII, SG->getSGID()));
1682 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1687 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1688 SchedGroupMask::VALU, 1, PipelineSyncID, DAG,
TII);
1689 if (!IsPostRA && MFMAChains) {
1690 SG->addRule(std::make_shared<EnablesNthMFMAInChain>(
1691 getNextTransPositionInChain(),
1692 MFMAChainSeeds[getNextTransMFMAChain()],
TII, SG->getSGID(),
true));
1694 SG->addRule(std::make_shared<EnablesNthMFMA>(2 * MFMAEnablement + 1,
1695 TII, SG->getSGID(),
true));
1696 SG->addRule(std::make_shared<IsFMA>(
TII, SG->getSGID()));
1697 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1701 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1702 SchedGroupMask::TRANS, 1, PipelineSyncID, DAG,
TII);
1703 if (!IsPostRA && MFMAChains)
1704 SG->addRule(std::make_shared<EnablesNthMFMAInChain>(
1705 PositionInChain, MFMAChainSeeds[MFMAChain],
TII, SG->getSGID(),
1708 SG->addRule(std::make_shared<EnablesNthMFMA>(MFMAEnablement + 1,
TII,
1709 SG->getSGID(),
true));
1710 SG->addRule(std::make_shared<IsPipeExp>(
TII, SG->getSGID(),
true));
1711 SG->addRule(std::make_shared<LessThanNSuccs>(8,
TII, SG->getSGID(),
1712 HasChainBetweenCvt));
1713 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1718 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1719 SchedGroupMask::TRANS, 1, PipelineSyncID, DAG,
TII);
1720 SG->addRule(std::make_shared<IsPipeExp>(
TII, SG->getSGID(),
true));
1721 SG->addRule(std::make_shared<GreaterThanOrEqualToNSuccs>(
1722 8,
TII, SG->getSGID(), HasChainBetweenCvt));
1723 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1728 unsigned MFMARatio =
1729 MFMAEnablement > ExpRequirement ? MFMAEnablement / ExpRequirement : 1;
1732 MFMAEnablement > ExpRequirement ? 1 : ExpRequirement / MFMAEnablement;
1734 unsigned RemainingExp = TransPipeCount > (2 * ExpRequirement)
1735 ? TransPipeCount - (2 * ExpRequirement)
1737 unsigned ExpLoopCount = RemainingExp / ExpRatio;
1739 unsigned MFMAInLoop = MFMAPipeCount > (MFMAEnablement * 2)
1740 ? MFMAPipeCount - (MFMAEnablement * 2)
1742 unsigned MFMALoopCount = MFMAInLoop / MFMARatio;
1744 AddPipeCount < MFMAPipeCount ? 1 : AddPipeCount / MFMAPipeCount;
1745 unsigned LoopSize = std::min(ExpLoopCount, MFMALoopCount);
1747 for (
unsigned I = 0;
I < LoopSize;
I++) {
1748 if (!(
I * ExpRatio % ExpRequirement))
1749 incrementTransPosition();
1752 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1753 SchedGroupMask::MFMA, MFMARatio, PipelineSyncID, DAG,
TII);
1754 if (!IsPostRA && MFMAChains)
1755 SG->addRule(std::make_shared<IsExactMFMA>(
1756 PositionInChainForMFMA, MFMAChainSeeds[MFMAChainForMFMA],
TII,
1757 SG->getSGID(),
true));
1759 SG->addRule(std::make_shared<OccursAfterExp>(
TII, SG->getSGID(),
true));
1760 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1761 incrementMFMAPosition();
1764 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1765 SchedGroupMask::VALU, VALUOps, PipelineSyncID, DAG,
TII);
1766 SG->addRule(std::make_shared<IsPipeAdd>(
TII, SG->getSGID()));
1767 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1770 if (UsesDSRead && !(
I % 4)) {
1771 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1772 SchedGroupMask::DS_READ, 2, PipelineSyncID, DAG,
TII);
1773 SG->addRule(std::make_shared<OccursAtOrAfterNode>(*FirstPipeDSR,
TII,
1775 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1779 for (
unsigned J = 0; J < ExpRatio; J++) {
1780 auto MFMAOffset = (1 + UsesVALU) * MFMARatio * (
I + 1);
1781 auto MaxMFMAOffset =
1782 (1 + UsesVALU) * ExpRequirement * MFMARatio / ExpRatio;
1786 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1787 SchedGroupMask::VALU, 1, PipelineSyncID, DAG,
TII);
1788 SG->addRule(std::make_shared<IsCvt>(
TII, SG->getSGID()));
1789 auto BaseDiff = (2 + UsesFMA) * (ExpRequirement - 1) + 1;
1790 auto DSROffset =
I / 4 + 1;
1791 auto MaxDSROffset = MaxMFMAOffset / 4;
1793 auto ExpOffset =
I * ExpRatio + J >= ExpRequirement ? 0 : 1;
1794 auto CurrentOffset = UsesDSRead * std::min(MaxDSROffset, DSROffset) +
1795 std::min(MaxMFMAOffset, MFMAOffset) + BaseDiff +
1797 if (HasChainBetweenCvt)
1798 SG->addRule(std::make_shared<IsReachableFromPrevNthGroup>(
1799 CurrentOffset,
TII, SG->getSGID()));
1801 SG->addRule(std::make_shared<IsSuccOfPrevNthGroup>(CurrentOffset,
TII,
1803 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1808 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1809 SchedGroupMask::VALU, 1, PipelineSyncID, DAG,
TII);
1810 if (!IsPostRA && MFMAChains)
1811 SG->addRule(std::make_shared<EnablesNthMFMAInChain>(
1812 getNextTransPositionInChain(),
1813 MFMAChainSeeds[getNextTransMFMAChain()],
TII, SG->getSGID(),
1816 SG->addRule(std::make_shared<EnablesNthMFMA>(
1817 (((
I * ExpRatio + J) / ExpRequirement) + 3) * MFMAEnablement + 1,
1818 TII, SG->getSGID(),
true));
1819 SG->addRule(std::make_shared<IsFMA>(
TII, SG->getSGID()));
1820 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1824 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1825 SchedGroupMask::TRANS, 1, PipelineSyncID, DAG,
TII);
1826 if (!IsPostRA && MFMAChains)
1827 SG->addRule(std::make_shared<EnablesNthMFMAInChain>(
1828 PositionInChain, MFMAChainSeeds[MFMAChain],
TII, SG->getSGID(),
1831 SG->addRule(std::make_shared<EnablesNthMFMA>(
1832 (((
I * ExpRatio + J) / ExpRequirement) + 2) * MFMAEnablement + 1,
1833 TII, SG->getSGID(),
true));
1834 SG->addRule(std::make_shared<IsPipeExp>(
TII, SG->getSGID(),
true));
1835 SG->addRule(std::make_shared<LessThanNSuccs>(8,
TII, SG->getSGID(),
1836 HasChainBetweenCvt));
1837 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1842 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
1843 SchedGroupMask::MFMA, MFMAEnablement * 2, PipelineSyncID, DAG,
TII);
1844 SG->addRule(std::make_shared<OccursAfterExp>(
TII, SG->getSGID(),
true));
1845 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
1849class MFMASmallGemmSingleWaveOpt final :
public IGLPStrategy {
1852 class EnablesInitialMFMA final :
public InstructionRule {
1856 if (!SyncPipe.
size())
1859 if (!Cache->size()) {
1860 for (
auto &Elt : SyncPipe[0].DAG->
SUnits) {
1861 if (
TII->isMFMAorWMMA(*Elt.getInstr())) {
1865 Cache->push_back(&Elt);
1871 auto DAG = SyncPipe[0].DAG;
1872 for (
auto &Elt : *Cache) {
1880 bool NeedsCache =
false)
1881 : InstructionRule(
TII, SGID, NeedsCache) {}
1885 class IsPermForDSW final :
public InstructionRule {
1890 if (
MI->getOpcode() != AMDGPU::V_PERM_B32_e64)
1893 bool FitsInGroup =
false;
1895 if (!Collection.
size()) {
1896 for (
auto &Succ : SU->
Succs) {
1897 SUnit *SuccUnit = Succ.getSUnit();
1900 Cache->push_back(SuccUnit);
1913 return ThisSucc.getSUnit() == Elt;
1918 IsPermForDSW(
const SIInstrInfo *
TII,
unsigned SGID,
bool NeedsCache =
false)
1919 : InstructionRule(
TII, SGID, NeedsCache) {}
1923 class IsSuccOfPrevGroup final :
public InstructionRule {
1927 SchedGroup *OtherGroup =
nullptr;
1928 for (
auto &PipeSG : SyncPipe) {
1929 if ((
unsigned)PipeSG.getSGID() == SGID - 1) {
1930 OtherGroup = &PipeSG;
1936 if (!OtherGroup->Collection.size())
1940 return any_of(OtherGroup->Collection, [&SU](
SUnit *Elt) {
1941 return any_of(Elt->Succs,
1942 [&SU](SDep &Succ) { return Succ.getSUnit() == SU; });
1946 bool NeedsCache =
false)
1947 : InstructionRule(
TII, SGID, NeedsCache) {}
1951 class VMEMSize final :
public InstructionRule {
1956 if (
MI->getOpcode() == TargetOpcode::BUNDLE)
1958 if (!Collection.
size())
1963 auto TRI =
TII->getRegisterInfo();
1964 auto &
MRI =
MI->getParent()->getParent()->getRegInfo();
1965 for (
auto &Elt : Collection) {
1966 auto Op = Elt->getInstr()->getOperand(0);
1968 TRI.getRegSizeInBits(*
TRI.getRegClassForOperandReg(
MRI,
Op));
1972 if (NumBits < 128) {
1974 if (NumBits +
TRI.getRegSizeInBits(*
TRI.getRegClassForOperandReg(
1975 MRI,
MI->getOperand(0))) <=
1983 VMEMSize(
const SIInstrInfo *
TII,
unsigned SGID,
bool NeedsCache =
false)
1984 : InstructionRule(
TII, SGID, NeedsCache) {}
1989 class SharesPredWithPrevNthGroup final :
public InstructionRule {
1991 unsigned Distance = 1;
1996 SchedGroup *OtherGroup =
nullptr;
1997 if (!SyncPipe.
size())
2000 if (!Cache->size()) {
2002 for (
auto &PipeSG : SyncPipe) {
2003 if ((
unsigned)PipeSG.getSGID() == SGID - Distance) {
2004 OtherGroup = &PipeSG;
2010 if (!OtherGroup->Collection.size())
2013 for (
auto &OtherEle : OtherGroup->Collection) {
2014 for (
auto &Pred : OtherEle->Preds) {
2015 if (Pred.getSUnit()->getInstr()->getOpcode() ==
2016 AMDGPU::V_PERM_B32_e64)
2017 Cache->push_back(Pred.getSUnit());
2026 auto DAG = SyncPipe[0].DAG;
2033 SharesPredWithPrevNthGroup(
unsigned Distance,
const SIInstrInfo *
TII,
2034 unsigned SGID,
bool NeedsCache =
false)
2035 : InstructionRule(
TII, SGID, NeedsCache), Distance(Distance) {}
2039 bool applyIGLPStrategy(
2050 : IGLPStrategy(DAG,
TII) {
2055static unsigned DSWCount = 0;
2056static unsigned DSWWithPermCount = 0;
2057static unsigned DSWWithSharedVMEMCount = 0;
2059bool MFMASmallGemmSingleWaveOpt::applyIGLPStrategy(
2063 unsigned MFMACount = 0;
2064 unsigned DSRCount = 0;
2066 bool IsInitial =
Phase == AMDGPU::SchedulingPhase::Initial;
2068 assert((!IsInitial || (DSWCount == 0 && DSWWithPermCount == 0 &&
2069 DSWWithSharedVMEMCount == 0)) &&
2070 "DSWCounters should be zero in pre-RA scheduling!");
2072 for (
auto &SU : DAG->SUnits) {
2073 auto I = SU.getInstr();
2074 if (
TII->isMFMAorWMMA(*
I))
2076 else if (
TII->isDS(*
I)) {
2079 else if (
I->mayStore() && IsInitial) {
2081 for (
auto Pred : SU.Preds) {
2082 if (Pred.getSUnit()->getInstr()->getOpcode() ==
2083 AMDGPU::V_PERM_B32_e64) {
2093 DSWWithPermCount = DSWithPerms.
size();
2094 auto I = DSWithPerms.
begin();
2095 auto E = DSWithPerms.
end();
2105 for (;
I != E;
I++) {
2106 SUnit *Cand =
nullptr;
2107 bool MissedAny =
false;
2108 for (
auto &Pred : (*I)->Preds) {
2109 if (Pred.getSUnit()->getInstr()->getOpcode() != AMDGPU::V_PERM_B32_e64)
2115 for (
auto &Succ : Pred.getSUnit()->Succs) {
2116 auto MI = Succ.getSUnit()->getInstr();
2117 if (!
TII->isVMEM(*
MI) || !
MI->mayLoad())
2120 if (MissedAny || !VMEMLookup.
size()) {
2122 VMEMLookup[
MI] = *
I;
2128 VMEMLookup[
MI] = *
I;
2132 Cand = VMEMLookup[
MI];
2139 if (!MissedAny && Cand) {
2140 DSWWithSharedVMEMCount += 2;
2147 assert(DSWWithSharedVMEMCount <= DSWWithPermCount);
2149 unsigned PipelineSyncID = 0;
2151 if (DSWWithPermCount) {
2152 for (
unsigned I = 0;
I < MFMACount;
I++) {
2153 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2154 SchedGroupMask::MFMA, 1, PipelineSyncID, DAG,
TII);
2155 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2157 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2158 SchedGroupMask::VALU, 2, PipelineSyncID, DAG,
TII);
2159 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2169 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2170 SchedGroupMask::DS_READ, 4, PipelineSyncID, DAG,
TII);
2171 SG->addRule(std::make_shared<EnablesInitialMFMA>(
TII, SG->getSGID(),
true));
2172 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2174 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2175 SchedGroupMask::MFMA, 1, PipelineSyncID, DAG,
TII);
2176 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2179 for (
unsigned I = 0;
I < DSRCount - 4; ++
I) {
2180 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2181 SchedGroupMask::DS_READ, 1, PipelineSyncID, DAG,
TII);
2182 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2184 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2185 SchedGroupMask::MFMA, 1, PipelineSyncID, DAG,
TII);
2186 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2192 for (
unsigned I = 0;
I < DSWWithPermCount - DSWWithSharedVMEMCount; ++
I) {
2193 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2194 SchedGroupMask::VALU, 4, PipelineSyncID, DAG,
TII);
2195 SG->addRule(std::make_shared<IsPermForDSW>(
TII, SG->getSGID(),
true));
2196 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2198 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2199 SchedGroupMask::DS_WRITE, 1, PipelineSyncID, DAG,
TII);
2200 SG->addRule(std::make_shared<IsSuccOfPrevGroup>(
TII, SG->getSGID()));
2201 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2203 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2204 SchedGroupMask::VMEM_READ, 4, PipelineSyncID, DAG,
TII);
2205 SG->addRule(std::make_shared<SharesPredWithPrevNthGroup>(
2206 1,
TII, SG->getSGID(),
true));
2207 SG->addRule(std::make_shared<VMEMSize>(
TII, SG->getSGID()));
2208 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2210 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2211 SchedGroupMask::MFMA, 1, PipelineSyncID, DAG,
TII);
2212 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2214 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2215 SchedGroupMask::VMEM_READ, 4, PipelineSyncID, DAG,
TII);
2216 SG->addRule(std::make_shared<SharesPredWithPrevNthGroup>(
2217 3,
TII, SG->getSGID(),
true));
2218 SG->addRule(std::make_shared<VMEMSize>(
TII, SG->getSGID()));
2219 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2221 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2222 SchedGroupMask::MFMA, 1, PipelineSyncID, DAG,
TII);
2223 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2229 for (
unsigned I = 0;
I < DSWCount - DSWWithPermCount;
I++) {
2230 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2231 SchedGroupMask::DS_WRITE, 1, PipelineSyncID, DAG,
TII);
2232 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2234 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2235 SchedGroupMask::VMEM_READ, 4, PipelineSyncID, DAG,
TII);
2236 SG->addRule(std::make_shared<VMEMSize>(
TII, SG->getSGID()));
2237 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2239 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2240 SchedGroupMask::MFMA, 1, PipelineSyncID, DAG,
TII);
2241 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2249 for (
unsigned I = 0;
I < DSWWithSharedVMEMCount; ++
I) {
2250 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2251 SchedGroupMask::VALU, 4, PipelineSyncID, DAG,
TII);
2252 SG->addRule(std::make_shared<IsPermForDSW>(
TII, SG->getSGID(),
true));
2253 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2255 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2256 SchedGroupMask::DS_WRITE, 1, PipelineSyncID, DAG,
TII);
2257 SG->addRule(std::make_shared<IsSuccOfPrevGroup>(
TII, SG->getSGID()));
2258 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2260 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2261 SchedGroupMask::MFMA, 1, PipelineSyncID, DAG,
TII);
2262 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2264 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2265 SchedGroupMask::VALU, 4, PipelineSyncID, DAG,
TII);
2266 SG->addRule(std::make_shared<IsPermForDSW>(
TII, SG->getSGID(),
true));
2267 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2269 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2270 SchedGroupMask::DS_WRITE, 1, PipelineSyncID, DAG,
TII);
2271 SG->addRule(std::make_shared<IsSuccOfPrevGroup>(
TII, SG->getSGID()));
2272 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2274 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2275 SchedGroupMask::MFMA, 1, PipelineSyncID, DAG,
TII);
2276 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2278 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2279 SchedGroupMask::VMEM_READ, 4, PipelineSyncID, DAG,
TII);
2280 SG->addRule(std::make_shared<SharesPredWithPrevNthGroup>(
2281 2,
TII, SG->getSGID(),
true));
2282 SG->addRule(std::make_shared<VMEMSize>(
TII, SG->getSGID()));
2283 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2285 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2286 SchedGroupMask::MFMA, 1, PipelineSyncID, DAG,
TII);
2287 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2289 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2290 SchedGroupMask::VMEM_READ, 4, PipelineSyncID, DAG,
TII);
2291 SG->addRule(std::make_shared<SharesPredWithPrevNthGroup>(
2292 4,
TII, SG->getSGID(),
true));
2293 SG->addRule(std::make_shared<VMEMSize>(
TII, SG->getSGID()));
2294 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2296 SG = &SyncedSchedGroups[PipelineSyncID].emplace_back(
2297 SchedGroupMask::MFMA, 1, PipelineSyncID, DAG,
TII);
2298 SG->initSchedGroup(SyncedInstrs[SG->getSyncID()]);
2304static std::unique_ptr<IGLPStrategy>
2308 case MFMASmallGemmOptID:
2309 return std::make_unique<MFMASmallGemmOpt>(DAG,
TII);
2310 case MFMASmallGemmSingleWaveOptID:
2311 return std::make_unique<MFMASmallGemmSingleWaveOpt>(DAG,
TII);
2312 case MFMAExpInterleave:
2313 return std::make_unique<MFMAExpInterleaveOpt>(DAG,
TII);
2334 void addSchedBarrierEdges(
SUnit &SU);
2345 SchedGroupMask invertSchedBarrierMask(SchedGroupMask Mask)
const;
2348 void initSchedGroupBarrierPipelineStage(
2349 std::vector<SUnit>::reverse_iterator RIter);
2351 bool initIGLPOpt(
SUnit &SU);
2361 bool IsBottomUp =
true;
2366 IGroupLPDAGMutation() =
default;
2370unsigned SchedGroup::NumSchedGroups = 0;
2382 if (
MI.isMetaInstruction())
2385 else if (((SGMask & SchedGroupMask::ALU) != SchedGroupMask::NONE) &&
2390 else if (((SGMask & SchedGroupMask::VALU) != SchedGroupMask::NONE) &&
2394 else if (((SGMask & SchedGroupMask::SALU) != SchedGroupMask::NONE) &&
2398 else if (((SGMask & SchedGroupMask::MFMA) != SchedGroupMask::NONE) &&
2399 TII->isMFMAorWMMA(
MI))
2402 else if (((SGMask & SchedGroupMask::VMEM) != SchedGroupMask::NONE) &&
2406 else if (((SGMask & SchedGroupMask::VMEM_READ) != SchedGroupMask::NONE) &&
2411 else if (((SGMask & SchedGroupMask::VMEM_WRITE) != SchedGroupMask::NONE) &&
2416 else if (((SGMask & SchedGroupMask::DS) != SchedGroupMask::NONE) &&
2420 else if (((SGMask & SchedGroupMask::DS_READ) != SchedGroupMask::NONE) &&
2421 MI.mayLoad() &&
TII->isDS(
MI))
2424 else if (((SGMask & SchedGroupMask::DS_WRITE) != SchedGroupMask::NONE) &&
2425 MI.mayStore() &&
TII->isDS(
MI))
2428 else if (((SGMask & SchedGroupMask::TRANS) != SchedGroupMask::NONE) &&
2433 dbgs() <<
"For SchedGroup with mask " <<
format_hex((
int)SGMask, 10,
true)
2434 << (Result ?
" could classify " :
" unable to classify ") <<
MI);
2439int SchedGroup::link(
SUnit &SU,
bool MakePred,
2440 std::vector<std::pair<SUnit *, SUnit *>> &AddedEdges) {
2441 int MissedEdges = 0;
2442 for (
auto *
A : Collection) {
2444 if (
A ==
B ||
A->getInstr()->getOpcode() == AMDGPU::SCHED_GROUP_BARRIER)
2454 bool Added = tryAddEdge(
A,
B);
2456 AddedEdges.emplace_back(
A,
B);
2464void SchedGroup::link(
SUnit &SU,
bool MakePred) {
2465 for (
auto *
A : Collection) {
2467 if (
A->getInstr()->getOpcode() == AMDGPU::SCHED_GROUP_BARRIER)
2476void SchedGroup::link(
SUnit &SU,
2478 for (
auto *
A : Collection) {
2487void SchedGroup::link(SchedGroup &OtherGroup) {
2488 for (
auto *
B : OtherGroup.Collection)
2492bool SchedGroup::canAddSU(
SUnit &SU)
const {
2494 if (
MI.getOpcode() != TargetOpcode::BUNDLE)
2495 return canAddMI(
MI);
2500 while (E !=
MBB->
end() && E->isBundledWithPred())
2507void SchedGroup::initSchedGroup() {
2508 for (
auto &SU : DAG->
SUnits) {
2517void SchedGroup::initSchedGroup(std::vector<SUnit>::reverse_iterator RIter,
2518 SUnitsToCandidateSGsMap &SyncedInstrs) {
2519 SUnit &InitSU = *RIter;
2520 for (
auto E = DAG->
SUnits.rend(); RIter != E; ++RIter) {
2526 SyncedInstrs[&SU].push_back(SGID);
2534void SchedGroup::initSchedGroup(SUnitsToCandidateSGsMap &SyncedInstrs) {
2535 auto I = DAG->
SUnits.rbegin();
2536 auto E = DAG->
SUnits.rend();
2537 for (;
I != E; ++
I) {
2542 SyncedInstrs[&SU].push_back(SGID);
2548 if (!TSchedModel || DAGInstrs->
SUnits.empty())
2553 TII =
ST.getInstrInfo();
2555 SyncedSchedGroups.clear();
2556 SyncedInstrs.clear();
2557 bool FoundSB =
false;
2558 bool FoundIGLP =
false;
2559 bool ShouldApplyIGLP =
false;
2560 for (
auto R = DAG->
SUnits.rbegin(), E = DAG->
SUnits.rend();
R != E; ++
R) {
2561 unsigned Opc =
R->getInstr()->getOpcode();
2563 if (Opc == AMDGPU::SCHED_BARRIER) {
2564 addSchedBarrierEdges(*R);
2566 }
else if (Opc == AMDGPU::SCHED_GROUP_BARRIER) {
2567 initSchedGroupBarrierPipelineStage(R);
2569 }
else if (Opc == AMDGPU::IGLP_OPT) {
2570 resetEdges(*R, DAG);
2571 if (!FoundSB && !FoundIGLP) {
2573 ShouldApplyIGLP = initIGLPOpt(*R);
2578 if (FoundSB || (FoundIGLP && ShouldApplyIGLP)) {
2579 PipelineSolver PS(SyncedSchedGroups, SyncedInstrs, DAG, IsBottomUp);
2587void IGroupLPDAGMutation::addSchedBarrierEdges(
SUnit &SchedBarrier) {
2589 assert(
MI.getOpcode() == AMDGPU::SCHED_BARRIER);
2592 resetEdges(SchedBarrier, DAG);
2593 LLVM_DEBUG(
dbgs() <<
"Building SchedGroup for SchedBarrier with Mask: "
2594 <<
MI.getOperand(0).getImm() <<
"\n");
2596 invertSchedBarrierMask((SchedGroupMask)
MI.getOperand(0).getImm());
2597 SchedGroup SG(InvertedMask, std::nullopt, DAG,
TII);
2598 SG.initSchedGroup();
2604 const SUnit *
A,
const SUnit *
B) {
return A->NodeNum >
B->NodeNum; });
2608IGroupLPDAGMutation::invertSchedBarrierMask(SchedGroupMask Mask)
const {
2611 SchedGroupMask InvertedMask = ~Mask;
2614 if ((InvertedMask & SchedGroupMask::ALU) == SchedGroupMask::NONE)
2615 InvertedMask &= ~SchedGroupMask::VALU & ~SchedGroupMask::SALU &
2616 ~SchedGroupMask::MFMA & ~SchedGroupMask::TRANS;
2618 else if ((InvertedMask & SchedGroupMask::VALU) == SchedGroupMask::NONE ||
2619 (InvertedMask & SchedGroupMask::SALU) == SchedGroupMask::NONE ||
2620 (InvertedMask & SchedGroupMask::MFMA) == SchedGroupMask::NONE ||
2621 (InvertedMask & SchedGroupMask::TRANS) == SchedGroupMask::NONE)
2622 InvertedMask &= ~SchedGroupMask::ALU;
2625 if ((InvertedMask & SchedGroupMask::VMEM) == SchedGroupMask::NONE)
2626 InvertedMask &= ~SchedGroupMask::VMEM_READ & ~SchedGroupMask::VMEM_WRITE;
2628 else if ((InvertedMask & SchedGroupMask::VMEM_READ) == SchedGroupMask::NONE ||
2629 (InvertedMask & SchedGroupMask::VMEM_WRITE) == SchedGroupMask::NONE)
2630 InvertedMask &= ~SchedGroupMask::VMEM;
2633 if ((InvertedMask & SchedGroupMask::DS) == SchedGroupMask::NONE)
2634 InvertedMask &= ~SchedGroupMask::DS_READ & ~SchedGroupMask::DS_WRITE;
2636 else if ((InvertedMask & SchedGroupMask::DS_READ) == SchedGroupMask::NONE ||
2637 (InvertedMask & SchedGroupMask::DS_WRITE) == SchedGroupMask::NONE)
2638 InvertedMask &= ~SchedGroupMask::DS;
2640 LLVM_DEBUG(
dbgs() <<
"After Inverting, SchedGroup Mask: " << (
int)InvertedMask
2643 return InvertedMask;
2646void IGroupLPDAGMutation::initSchedGroupBarrierPipelineStage(
2647 std::vector<SUnit>::reverse_iterator RIter) {
2650 resetEdges(*RIter, DAG);
2657 auto &SG = SyncedSchedGroups[SyncID].emplace_back((SchedGroupMask)SGMask,
2660 SG.initSchedGroup(RIter, SyncedInstrs[SG.getSyncID()]);
2663bool IGroupLPDAGMutation::initIGLPOpt(
SUnit &SU) {
2664 IGLPStrategyID StrategyID =
2666 auto S = createIGLPStrategy(StrategyID, DAG,
TII);
2667 if (!S->shouldApplyStrategy(DAG,
Phase))
2670 IsBottomUp = S->IsBottomUp;
2671 return S->applyIGLPStrategy(SyncedInstrs, SyncedSchedGroups,
Phase);
2683std::unique_ptr<ScheduleDAGMutation>
2685 return std::make_unique<IGroupLPDAGMutation>(
Phase);
unsigned const MachineRegisterInfo * MRI
aarch64 falkor hwpf fix Falkor HW Prefetch Fix Late Phase
Provides AMDGPU specific target descriptions.
The AMDGPU TargetMachine interface definition for hw codegen targets.
#define LLVM_MARK_AS_BITMASK_ENUM(LargestValue)
LLVM_MARK_AS_BITMASK_ENUM lets you opt in an individual enum type so you can perform bitwise operatio...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file defines the DenseMap class.
const HexagonInstrInfo * TII
unsigned const TargetRegisterInfo * TRI
Interface definition for SIInstrInfo.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static std::optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
This class represents an Operation in the Expression.
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Instructions::iterator instr_iterator
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
const MachineOperand & getOperand(unsigned i) const
@ Data
Regular data dependence (aka true-dependence).
@ Artificial
Arbitrary strong DAG edge (no real dependence).
Scheduling unit. This is a node in the scheduling DAG.
unsigned NodeNum
Entry # of node in the node vector.
void removePred(const SDep &D)
Removes the specified edge as a pred of the current node if it exists.
SmallVector< SDep, 4 > Succs
All sunit successors.
SmallVector< SDep, 4 > Preds
All sunit predecessors.
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
A ScheduleDAG for scheduling lists of MachineInstr.
const TargetSchedModel * getSchedModel() const
Gets the machine model for instruction scheduling.
bool addEdge(SUnit *SuccSU, const SDep &PredDep)
Add a DAG edge to the given SU with the given predecessor dependence data.
bool IsReachable(SUnit *SU, SUnit *TargetSU)
IsReachable - Checks if SU is reachable from TargetSU.
bool canAddEdge(SUnit *SuccSU, SUnit *PredSU)
True if an edge can be added from PredSU to SuccSU without creating a cycle.
void dump() const override
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
Mutate the DAG as a postpass after normal DAG building.
virtual void apply(ScheduleDAGInstrs *DAG)=0
std::vector< SUnit > SUnits
The scheduling units.
MachineFunction & MF
Machine function.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
reverse_iterator rbegin()
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Provide an instruction scheduling machine model to CodeGen passes.
An efficient, type-erasing, non-owning reference to a callable.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
initializer< Ty > init(const Ty &Val)
void link(std::unique_ptr< LinkGraph > G, std::unique_ptr< JITLinkContext > Ctx)
Link the given graph.
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
std::unique_ptr< ScheduleDAGMutation > createIGroupLPDAGMutation(AMDGPU::SchedulingPhase Phase)
Phase specifes whether or not this is a reentry into the IGroupLPDAGMutation.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.