@@ -38,11 +38,6 @@ using namespace llvm;
38
38
#include " AMDGPUGenSubtargetInfo.inc"
39
39
#undef AMDGPUSubtarget
40
40
41
- static cl::opt<bool >
42
- EnablePowerSched (" amdgpu-enable-power-sched" ,
43
- cl::desc (" Enable scheduling to minimize mAI power bursts" ),
44
- cl::init(false ));
45
-
46
41
static cl::opt<bool > EnableVGPRIndexMode (
47
42
" amdgpu-vgpr-index-mode" ,
48
43
cl::desc (" Use GPR indexing mode instead of movrel for vector indexing" ),
@@ -586,117 +581,6 @@ void GCNSubtarget::adjustSchedDependency(
586
581
}
587
582
}
588
583
589
- namespace {
590
- struct FillMFMAShadowMutation : ScheduleDAGMutation {
591
- const SIInstrInfo *TII;
592
-
593
- ScheduleDAGMI *DAG;
594
-
595
- FillMFMAShadowMutation (const SIInstrInfo *tii) : TII(tii) {}
596
-
597
- bool isSALU (const SUnit *SU) const {
598
- const MachineInstr *MI = SU->getInstr ();
599
- return MI && TII->isSALU (*MI) && !MI->isTerminator ();
600
- }
601
-
602
- bool isVALU (const SUnit *SU) const {
603
- const MachineInstr *MI = SU->getInstr ();
604
- return MI && TII->isVALU (*MI);
605
- }
606
-
607
- // Link as many SALU instructions in chain as possible. Return the size
608
- // of the chain. Links up to MaxChain instructions.
609
- unsigned linkSALUChain (SUnit *From, SUnit *To, unsigned MaxChain,
610
- SmallPtrSetImpl<SUnit *> &Visited) const {
611
- SmallVector<SUnit *, 8 > Worklist ({To});
612
- unsigned Linked = 0 ;
613
-
614
- while (!Worklist.empty () && MaxChain-- > 0 ) {
615
- SUnit *SU = Worklist.pop_back_val ();
616
- if (!Visited.insert (SU).second )
617
- continue ;
618
-
619
- LLVM_DEBUG (dbgs () << " Inserting edge from\n " ; DAG->dumpNode (*From);
620
- dbgs () << " to\n " ; DAG->dumpNode (*SU); dbgs () << ' \n ' );
621
-
622
- if (SU != From && From != &DAG->ExitSU && DAG->canAddEdge (SU, From))
623
- if (DAG->addEdge (SU, SDep (From, SDep::Artificial)))
624
- ++Linked;
625
-
626
- for (SDep &SI : From->Succs ) {
627
- SUnit *SUv = SI.getSUnit ();
628
- if (SUv != From && SU != &DAG->ExitSU && isVALU (SUv) &&
629
- DAG->canAddEdge (SUv, SU))
630
- DAG->addEdge (SUv, SDep (SU, SDep::Artificial));
631
- }
632
-
633
- for (SDep &SI : SU->Succs ) {
634
- SUnit *Succ = SI.getSUnit ();
635
- if (Succ != SU && isSALU (Succ))
636
- Worklist.push_back (Succ);
637
- }
638
- }
639
-
640
- return Linked;
641
- }
642
-
643
- void apply (ScheduleDAGInstrs *DAGInstrs) override {
644
- const GCNSubtarget &ST = DAGInstrs->MF .getSubtarget <GCNSubtarget>();
645
- if (!ST.hasMAIInsts ())
646
- return ;
647
- DAG = static_cast <ScheduleDAGMI *>(DAGInstrs);
648
- const TargetSchedModel *TSchedModel = DAGInstrs->getSchedModel ();
649
- if (!TSchedModel || DAG->SUnits .empty ())
650
- return ;
651
-
652
- // Scan for MFMA long latency instructions and try to add a dependency
653
- // of available SALU instructions to give them a chance to fill MFMA
654
- // shadow. That is desirable to fill MFMA shadow with SALU instructions
655
- // rather than VALU to prevent power consumption bursts and throttle.
656
- auto LastSALU = DAG->SUnits .begin ();
657
- auto E = DAG->SUnits .end ();
658
- SmallPtrSet<SUnit *, 32 > Visited;
659
- for (SUnit &SU : DAG->SUnits ) {
660
- MachineInstr &MAI = *SU.getInstr ();
661
- if (!TII->isMAI (MAI) ||
662
- MAI.getOpcode () == AMDGPU::V_ACCVGPR_WRITE_B32_e64 ||
663
- MAI.getOpcode () == AMDGPU::V_ACCVGPR_READ_B32_e64)
664
- continue ;
665
-
666
- unsigned Lat = TSchedModel->computeInstrLatency (&MAI) - 1 ;
667
-
668
- LLVM_DEBUG (dbgs () << " Found MFMA: " ; DAG->dumpNode (SU);
669
- dbgs () << " Need " << Lat
670
- << " instructions to cover latency.\n " );
671
-
672
- // Find up to Lat independent scalar instructions as early as
673
- // possible such that they can be scheduled after this MFMA.
674
- for (; Lat && LastSALU != E; ++LastSALU) {
675
- if (Visited.count (&*LastSALU))
676
- continue ;
677
-
678
- if (&SU == &DAG->ExitSU || &SU == &*LastSALU || !isSALU (&*LastSALU) ||
679
- !DAG->canAddEdge (&*LastSALU, &SU))
680
- continue ;
681
-
682
- Lat -= linkSALUChain (&SU, &*LastSALU, Lat, Visited);
683
- }
684
- }
685
- }
686
- };
687
- } // namespace
688
-
689
- void GCNSubtarget::getPostRAMutations (
690
- std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const {
691
- Mutations.push_back (std::make_unique<FillMFMAShadowMutation>(&InstrInfo));
692
- }
693
-
694
- std::unique_ptr<ScheduleDAGMutation>
695
- GCNSubtarget::createFillMFMAShadowMutation (const TargetInstrInfo *TII) const {
696
- return EnablePowerSched ? std::make_unique<FillMFMAShadowMutation>(&InstrInfo)
697
- : nullptr ;
698
- }
699
-
700
584
unsigned GCNSubtarget::getNSAThreshold (const MachineFunction &MF) const {
701
585
if (getGeneration () >= AMDGPUSubtarget::GFX12)
702
586
return 0 ; // Not MIMG encoding.
0 commit comments