[llvm] r328335 - [llvm-mca] Make the resource cost a double.

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 23 10:36:07 PDT 2018


Author: adibiagio
Date: Fri Mar 23 10:36:07 2018
New Revision: 328335

URL: http://llvm.org/viewvc/llvm-project?rev=328335&view=rev
Log:
[llvm-mca] Make the resource cost a double.

This is done in preparation for the fix for PR36874.
The number of cycles consumed for each pipe is now a double quantity. This
allows reuse of the resource pressure view to print out instruction tables.

Modified:
    llvm/trunk/tools/llvm-mca/HWEventListener.h
    llvm/trunk/tools/llvm-mca/Scheduler.cpp
    llvm/trunk/tools/llvm-mca/Scheduler.h

Modified: llvm/trunk/tools/llvm-mca/HWEventListener.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/HWEventListener.h?rev=328335&r1=328334&r2=328335&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/HWEventListener.h (original)
+++ llvm/trunk/tools/llvm-mca/HWEventListener.h Fri Mar 23 10:36:07 2018
@@ -61,11 +61,11 @@ class HWInstructionIssuedEvent : public
 public:
   using ResourceRef = std::pair<uint64_t, uint64_t>;
   HWInstructionIssuedEvent(unsigned Index,
-                           llvm::ArrayRef<std::pair<ResourceRef, unsigned>> UR)
+                           llvm::ArrayRef<std::pair<ResourceRef, double>> UR)
       : HWInstructionEvent(HWInstructionEvent::Issued, Index),
         UsedResources(UR) {}
 
-  llvm::ArrayRef<std::pair<ResourceRef, unsigned>> UsedResources;
+  llvm::ArrayRef<std::pair<ResourceRef, double>> UsedResources;
 };
 
 class HWInstructionDispatchedEvent : public HWInstructionEvent {

Modified: llvm/trunk/tools/llvm-mca/Scheduler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/Scheduler.cpp?rev=328335&r1=328334&r2=328335&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/Scheduler.cpp (original)
+++ llvm/trunk/tools/llvm-mca/Scheduler.cpp Fri Mar 23 10:36:07 2018
@@ -11,9 +11,9 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "Scheduler.h"
 #include "Backend.h"
 #include "HWEventListener.h"
-#include "Scheduler.h"
 #include "Support.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
@@ -180,7 +180,7 @@ bool ResourceManager::mustIssueImmediate
 
 void ResourceManager::issueInstruction(
     unsigned Index, const InstrDesc &Desc,
-    SmallVectorImpl<std::pair<ResourceRef, unsigned>> &Pipes) {
+    SmallVectorImpl<std::pair<ResourceRef, double>> &Pipes) {
   for (const std::pair<uint64_t, ResourceUsage> &R : Desc.Resources) {
     const CycleSegment &CS = R.second.CS;
     if (!CS.size()) {
@@ -196,7 +196,8 @@ void ResourceManager::issueInstruction(
       // Replace the resource mask with a valid processor resource index.
       const ResourceState &RS = *Resources[Pipe.first];
       Pipe.first = RS.getProcResourceID();
-      Pipes.emplace_back(std::pair<ResourceRef, unsigned>(Pipe, CS.size()));
+      Pipes.emplace_back(
+          std::pair<ResourceRef, double>(Pipe, static_cast<double>(CS.size())));
     } else {
       assert((countPopulation(R.first) > 1) && "Expected a group!");
       // Mark this group as reserved.
@@ -338,7 +339,7 @@ void Scheduler::issueInstruction(Instruc
   // two resources). We use a small vector here, and conservatively
   // initialize its capacity to 4. This should address the majority of
   // the cases.
-  SmallVector<std::pair<ResourceRef, unsigned>, 4> UsedResources;
+  SmallVector<std::pair<ResourceRef, double>, 4> UsedResources;
   Resources->issueInstruction(InstrIndex, D, UsedResources);
   // Notify the instruction that it started executing.
   // This updates the internal state of each write.
@@ -417,7 +418,7 @@ void Scheduler::updateIssuedQueue() {
 }
 
 void Scheduler::notifyInstructionIssued(
-    unsigned Index, ArrayRef<std::pair<ResourceRef, unsigned>> Used) {
+    unsigned Index, ArrayRef<std::pair<ResourceRef, double>> Used) {
   DEBUG({
     dbgs() << "[E] Instruction Issued: " << Index << '\n';
     for (const std::pair<ResourceRef, unsigned> &Resource : Used) {

Modified: llvm/trunk/tools/llvm-mca/Scheduler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/Scheduler.h?rev=328335&r1=328334&r2=328335&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/Scheduler.h (original)
+++ llvm/trunk/tools/llvm-mca/Scheduler.h Fri Mar 23 10:36:07 2018
@@ -363,7 +363,7 @@ public:
 
   void issueInstruction(
       unsigned Index, const InstrDesc &Desc,
-      llvm::SmallVectorImpl<std::pair<ResourceRef, unsigned>> &Pipes);
+      llvm::SmallVectorImpl<std::pair<ResourceRef, double>> &Pipes);
 
   void cycleEvent(llvm::SmallVectorImpl<ResourceRef> &ResourcesFreed);
 
@@ -420,7 +420,7 @@ class Scheduler {
 
   void notifyInstructionIssued(
       unsigned Index,
-      llvm::ArrayRef<std::pair<ResourceRef, unsigned>> Used);
+      llvm::ArrayRef<std::pair<ResourceRef, double>> Used);
   void notifyInstructionExecuted(unsigned Index);
   void notifyInstructionReady(unsigned Index);
   void notifyResourceAvailable(const ResourceRef &RR);




More information about the llvm-commits mailing list