[llvm] r353728 - [MCA][Scheduler] Track resources that were found busy when issuing an instruction.

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 11 09:55:47 PST 2019


Author: adibiagio
Date: Mon Feb 11 09:55:47 2019
New Revision: 353728

URL: http://llvm.org/viewvc/llvm-project?rev=353728&view=rev
Log:
[MCA][Scheduler] Track resources that were found busy when issuing an instruction.

This is a follow up of r353706. When the scheduler fails to issue a ready
instruction to the underlying pipelines, it now updates a mask of 'busy resource
units'. That information will be used in future to obtain the set of
"problematic" resources in the case of bottlenecks caused by resource pressure.
No functional change intended.

Modified:
    llvm/trunk/include/llvm/MCA/HardwareUnits/Scheduler.h
    llvm/trunk/lib/MCA/HardwareUnits/Scheduler.cpp

Modified: llvm/trunk/include/llvm/MCA/HardwareUnits/Scheduler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MCA/HardwareUnits/Scheduler.h?rev=353728&r1=353727&r2=353728&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MCA/HardwareUnits/Scheduler.h (original)
+++ llvm/trunk/include/llvm/MCA/HardwareUnits/Scheduler.h Mon Feb 11 09:55:47 2019
@@ -96,6 +96,13 @@ class Scheduler : public HardwareUnit {
   std::vector<InstRef> ReadySet;
   std::vector<InstRef> IssuedSet;
 
+  // A mask of busy resource units. It defaults to the empty set (i.e. a zero
+  // mask), and it is cleared at the beginning of every cycle.
+  // It is updated every time the scheduler fails to issue an instruction from
+  // the ready set due to unavailable pipeline resources.
+  // Each bit of the mask represents an unavailable resource.
+  uint64_t BusyResourceUnits;
+
   /// Verify the given selection strategy and set the Strategy member
   /// accordingly.  If no strategy is provided, the DefaultSchedulerStrategy is
   /// used.
@@ -126,7 +133,7 @@ public:
 
   Scheduler(std::unique_ptr<ResourceManager> RM, LSUnit &Lsu,
             std::unique_ptr<SchedulerStrategy> SelectStrategy)
-      : LSU(Lsu), Resources(std::move(RM)) {
+      : LSU(Lsu), Resources(std::move(RM)), BusyResourceUnits(0) {
     initializeStrategy(std::move(SelectStrategy));
   }
 
@@ -194,6 +201,10 @@ public:
   /// resources are not available.
   InstRef select();
 
+  /// Returns a mask of busy resources. Each bit of the mask identifies a unique
+  /// processor resource unit. In the absence of bottlenecks caused by resource
+  /// pressure, the mask value returned by this method is always zero.
+  uint64_t getBusyResourceUnits() const { return BusyResourceUnits; }
   bool arePipelinesFullyUsed() const {
     return !Resources->getAvailableProcResUnits();
   }

Modified: llvm/trunk/lib/MCA/HardwareUnits/Scheduler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MCA/HardwareUnits/Scheduler.cpp?rev=353728&r1=353727&r2=353728&view=diff
==============================================================================
--- llvm/trunk/lib/MCA/HardwareUnits/Scheduler.cpp (original)
+++ llvm/trunk/lib/MCA/HardwareUnits/Scheduler.cpp Mon Feb 11 09:55:47 2019
@@ -140,6 +140,7 @@ InstRef Scheduler::select() {
         Strategy->compare(IR, ReadySet[QueueIndex])) {
       const InstrDesc &D = IR.getInstruction()->getDesc();
       uint64_t BusyResourceMask = Resources->checkAvailability(D);
+      BusyResourceUnits |= BusyResourceMask;
       if (!BusyResourceMask)
         QueueIndex = I;
     }
@@ -196,6 +197,8 @@ void Scheduler::cycleEvent(SmallVectorIm
     IR.getInstruction()->cycleEvent();
 
   promoteToReadySet(Ready);
+
+  BusyResourceUnits = 0;
 }
 
 bool Scheduler::mustIssueImmediately(const InstRef &IR) const {




More information about the llvm-commits mailing list