OSDN Git Service

[llvm-mca] Renamed BackendStatistics to RetireControlUnitStatistics.
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Wed, 11 Apr 2018 12:12:53 +0000 (12:12 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Wed, 11 Apr 2018 12:12:53 +0000 (12:12 +0000)
Also, removed flag -verbose in favor of flag -retire-stats.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329794 91177308-0d34-0410-b5e6-96231b3b80d8

docs/CommandGuide/llvm-mca.rst
test/tools/llvm-mca/X86/BtVer2/rcu-statistics.s [new file with mode: 0644]
tools/llvm-mca/CMakeLists.txt
tools/llvm-mca/RetireControlUnitStatistics.cpp [moved from tools/llvm-mca/BackendStatistics.cpp with 74% similarity]
tools/llvm-mca/RetireControlUnitStatistics.h [moved from tools/llvm-mca/BackendStatistics.h with 65% similarity]
tools/llvm-mca/llvm-mca.cpp

index 3d69e6d..1aafd3b 100644 (file)
@@ -52,7 +52,7 @@ assembly text:
     __asm volatile("# LLVM-MCA-BEGIN foo");
     a += 42;
     __asm volatile("# LLVM-MCA-END");
-    a *= b;
+    a \*= b;
     return a;
   }
 
@@ -136,11 +136,6 @@ option specifies "``-``", then the output will also be sent to standard output.
   queue. A value of zero for this flag is ignored, and the default store queue
   size is used instead.
 
-.. option:: -verbose
-
-  Enable verbose output. In particular, this flag enables a number of extra
-  statistics and performance counters for the retire control unit.
-
 .. option:: -timeline
 
   Enable the timeline view.
@@ -174,6 +169,10 @@ option specifies "``-``", then the output will also be sent to standard output.
   Enable extra scheduler statistics. This view collects and analyzes instruction
   issue events. This view is disabled by default.
 
+.. option:: -retire-stats
+
+  Enable extra retire control unit statistics. This view is disabled by default.
+
 .. option:: -instruction-info
 
   Enable the instruction info view. This is enabled by default.
diff --git a/test/tools/llvm-mca/X86/BtVer2/rcu-statistics.s b/test/tools/llvm-mca/X86/BtVer2/rcu-statistics.s
new file mode 100644 (file)
index 0000000..74c7d7e
--- /dev/null
@@ -0,0 +1,56 @@
+# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -resource-pressure=false -retire-stats -iterations=1 < %s | FileCheck %s
+
+  vsqrtps %xmm0, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+  vaddps  %xmm0, %xmm1, %xmm2
+
+# CHECK:      Iterations:     1
+# CHECK-NEXT: Instructions:   16
+# CHECK-NEXT: Total Cycles:   31
+# CHECK-NEXT: Dispatch Width: 2
+# CHECK-NEXT: IPC:            0.52
+
+# CHECK:      Instruction Info:
+# CHECK-NEXT: [1]: #uOps
+# CHECK-NEXT: [2]: Latency
+# CHECK-NEXT: [3]: RThroughput
+# CHECK-NEXT: [4]: MayLoad
+# CHECK-NEXT: [5]: MayStore
+# CHECK-NEXT: [6]: HasSideEffects
+
+# CHECK:      [1]    [2]    [3]    [4]    [5]    [6]   Instructions:
+# CHECK-NEXT:  1      21    21.00                      vsqrtps %xmm0, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+# CHECK-NEXT:  1      3     1.00                       vaddps  %xmm0, %xmm1, %xmm2
+
+# CHECK:      Retire Control Unit - number of cycles where we saw N instructions retired:
+# CHECK-NEXT: [# retired], [# cycles]
+# CHECK-NEXT:  0,           23  (74.2%)
+# CHECK-NEXT:  2,           8  (25.8%)
+
index e0a97a5..20a9966 100644 (file)
@@ -12,7 +12,6 @@ set(LLVM_LINK_COMPONENTS
 add_llvm_tool(llvm-mca
   Backend.cpp
   BackendPrinter.cpp
-  BackendStatistics.cpp
   CodeRegion.cpp
   Dispatch.cpp
   DispatchStatistics.cpp
@@ -25,6 +24,7 @@ add_llvm_tool(llvm-mca
   llvm-mca.cpp
   RegisterFileStatistics.cpp
   ResourcePressureView.cpp
+  RetireControlUnitStatistics.cpp
   Scheduler.cpp
   SchedulerStatistics.cpp
   Support.cpp
similarity index 74%
rename from tools/llvm-mca/BackendStatistics.cpp
rename to tools/llvm-mca/RetireControlUnitStatistics.cpp
index 4e378b1..5b1a1de 100644 (file)
@@ -1,4 +1,5 @@
-//===--------------------- BackendStatistics.cpp ---------------*- C++ -*-===//
+//===--------------------- RetireControlUnitStatistics.cpp ---------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,24 +9,24 @@
 //===----------------------------------------------------------------------===//
 /// \file
 ///
-/// Functionalities used by the BackendPrinter to print out histograms
-/// related to number of {issue/retire} per number of cycles.
+/// This file implements the RetireControlUnitStatistics interface.
 ///
 //===----------------------------------------------------------------------===//
 
-#include "BackendStatistics.h"
+#include "RetireControlUnitStatistics.h"
 #include "llvm/Support/Format.h"
 
 using namespace llvm;
 
 namespace mca {
 
-void BackendStatistics::onInstructionEvent(const HWInstructionEvent &Event) {
+void RetireControlUnitStatistics::onInstructionEvent(
+    const HWInstructionEvent &Event) {
   if (Event.Type == HWInstructionEvent::Retired)
     ++NumRetired;
 }
 
-void BackendStatistics::printView(llvm::raw_ostream &OS) const {
+void RetireControlUnitStatistics::printView(llvm::raw_ostream &OS) const {
   std::string Buffer;
   raw_string_ostream TempStream(Buffer);
   TempStream << "\n\nRetire Control Unit - "
similarity index 65%
rename from tools/llvm-mca/BackendStatistics.h
rename to tools/llvm-mca/RetireControlUnitStatistics.h
index 24b8e5c..f3952ab 100644 (file)
@@ -1,4 +1,5 @@
-//===--------------------- BackendStatistics.h ------------------*- C++ -*-===//
+//===--------------------- RetireControlUnitStatistics.h ------------------*-
+//C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,8 +9,8 @@
 //===----------------------------------------------------------------------===//
 /// \file
 ///
-/// This file implements a View named BackendStatistics that knows how to
-/// collect and print a few statistics related to the retire unit.
+/// This file defines class RetireControlUnitStatistics: a view that knows how
+/// to print general statistics related to the retire control unit.
 ///
 /// Example:
 /// ========
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVM_MCA_BACKENDSTATISTICS_H
-#define LLVM_TOOLS_LLVM_MCA_BACKENDSTATISTICS_H
+#ifndef LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H
+#define LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H
 
 #include "View.h"
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 
 namespace mca {
 
-class BackendStatistics : public View {
-  const llvm::MCSubtargetInfo &STI;
-
+class RetireControlUnitStatistics : public View {
   using Histogram = llvm::DenseMap<unsigned, unsigned>;
   Histogram RetiredPerCycle;
 
@@ -47,12 +45,8 @@ class BackendStatistics : public View {
     NumRetired = 0;
   }
 
-  void printRCUStatistics(llvm::raw_ostream &OS, const Histogram &Histogram,
-                          unsigned Cycles) const;
-
 public:
-  BackendStatistics(const llvm::MCSubtargetInfo &sti)
-      : STI(sti), NumRetired(0), NumCycles(0) {}
+  RetireControlUnitStatistics() : NumRetired(0), NumCycles(0) {}
 
   void onInstructionEvent(const HWInstructionEvent &Event) override;
 
index 7b50196..3cb6292 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "BackendPrinter.h"
-#include "BackendStatistics.h"
 #include "CodeRegion.h"
 #include "DispatchStatistics.h"
 #include "InstructionInfoView.h"
 #include "InstructionTables.h"
 #include "RegisterFileStatistics.h"
 #include "ResourcePressureView.h"
+#include "RetireControlUnitStatistics.h"
 #include "SchedulerStatistics.h"
 #include "SummaryView.h"
 #include "TimelineView.h"
@@ -101,11 +101,16 @@ static cl::opt<bool>
                        cl::init(false));
 
 static cl::opt<bool>
-    PrintiSchedulerStats("scheduler-stats",
+    PrintSchedulerStats("scheduler-stats",
                          cl::desc("Print scheduler statistics"),
                          cl::init(false));
 
 static cl::opt<bool>
+    PrintRetireStats("retire-stats",
+                      cl::desc("Print retire control unit statistics"),
+                      cl::init(false));
+
+static cl::opt<bool>
     PrintResourcePressureView("resource-pressure",
                               cl::desc("Print the resource pressure view"),
                               cl::init(true));
@@ -438,11 +443,11 @@ int main(int argc, char **argv) {
     if (PrintDispatchStats)
       Printer.addView(llvm::make_unique<mca::DispatchStatistics>(*STI));
 
-    if (PrintiSchedulerStats)
+    if (PrintSchedulerStats)
       Printer.addView(llvm::make_unique<mca::SchedulerStatistics>(*STI));
 
-    if (PrintModeVerbose)
-      Printer.addView(llvm::make_unique<mca::BackendStatistics>(*STI));
+    if (PrintRetireStats)
+      Printer.addView(llvm::make_unique<mca::RetireControlUnitStatistics>());
 
     if (PrintRegisterFileStats)
       Printer.addView(llvm::make_unique<mca::RegisterFileStatistics>(*STI));