]> granicus.if.org Git - llvm/commitdiff
[llvm-mca] Emit a message when no bottlenecks are identified.
authorMatt Davis <Matthew.Davis@sony.com>
Thu, 7 Mar 2019 19:34:44 +0000 (19:34 +0000)
committerMatt Davis <Matthew.Davis@sony.com>
Thu, 7 Mar 2019 19:34:44 +0000 (19:34 +0000)
Summary:
Since bottleneck hints are enabled via user request, it can be
confusing if no bottleneck information is presented.  Such is the
case when no bottlenecks are identified.  This patch emits a message
in that case.

Reviewers: andreadb

Reviewed By: andreadb

Subscribers: tschuett, gbedwell, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59098

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

test/tools/llvm-mca/X86/BtVer2/bottleneck-hints-none.s [new file with mode: 0644]
tools/llvm-mca/Views/SummaryView.cpp
tools/llvm-mca/Views/SummaryView.h
tools/llvm-mca/llvm-mca.cpp

diff --git a/test/tools/llvm-mca/X86/BtVer2/bottleneck-hints-none.s b/test/tools/llvm-mca/X86/BtVer2/bottleneck-hints-none.s
new file mode 100644 (file)
index 0000000..1eb888d
--- /dev/null
@@ -0,0 +1,16 @@
+# NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py
+# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -bottleneck-analysis -all-views=false -summary-view -iterations 1 < %s | FileCheck %s -implicit-check-not 'Cycles with backend pressure increase'
+
+add %eax, %ebx
+
+# CHECK:      Iterations:        1
+# CHECK-NEXT: Instructions:      1
+# CHECK-NEXT: Total Cycles:      4
+# CHECK-NEXT: Total uOps:        1
+
+# CHECK:      Dispatch Width:    2
+# CHECK-NEXT: uOps Per Cycle:    0.25
+# CHECK-NEXT: IPC:               0.25
+# CHECK-NEXT: Block RThroughput: 0.5
+
+# CHECK:      No resource or data dependency bottlenecks discovered.
index 44b1139c94f773a9b9bf3611c9eebc5c13663805..e3d85507dc83a777c4fd27a50efaf2dc975a3712 100644 (file)
@@ -23,7 +23,7 @@ namespace mca {
 #define DEBUG_TYPE "llvm-mca"
 
 SummaryView::SummaryView(const MCSchedModel &Model, ArrayRef<MCInst> S,
-                         unsigned Width)
+                         unsigned Width, bool EmitBottleneckAnalysis)
     : SM(Model), Source(S), DispatchWidth(Width), LastInstructionIdx(0),
       TotalCycles(0), NumMicroOps(0), BPI({0, 0, 0, 0, 0}),
       ResourcePressureDistribution(Model.getNumProcResourceKinds(), 0),
@@ -32,7 +32,8 @@ SummaryView::SummaryView(const MCSchedModel &Model, ArrayRef<MCInst> S,
       ResIdx2ProcResID(Model.getNumProcResourceKinds(), 0),
       PressureIncreasedBecauseOfResources(false),
       PressureIncreasedBecauseOfDataDependencies(false),
-      SeenStallCycles(false) {
+      SeenStallCycles(false),
+      ShouldEmitBottleneckAnalysis(EmitBottleneckAnalysis) {
   computeProcResourceMasks(SM, ProcResourceMasks);
   for (unsigned I = 1, E = SM.getNumProcResourceKinds(); I < E; ++I) {
     unsigned Index = getResourceStateIndex(ProcResourceMasks[I]);
@@ -111,8 +112,10 @@ void SummaryView::onEvent(const HWPressureEvent &Event) {
 }
 
 void SummaryView::printBottleneckHints(raw_ostream &OS) const {
-  if (!SeenStallCycles || !BPI.PressureIncreaseCycles)
+  if (!SeenStallCycles || !BPI.PressureIncreaseCycles) {
+    OS << "\nNo resource or data dependency bottlenecks discovered.\n";
     return;
+  }
 
   double PressurePerCycle =
       (double)BPI.PressureIncreaseCycles * 100 / TotalCycles;
@@ -181,8 +184,8 @@ void SummaryView::printView(raw_ostream &OS) const {
   TempStream << "\nBlock RThroughput: "
              << format("%.1f", floor((BlockRThroughput * 10) + 0.5) / 10)
              << '\n';
-
-  printBottleneckHints(TempStream);
+  if (ShouldEmitBottleneckAnalysis)
+    printBottleneckHints(TempStream);
   TempStream.flush();
   OS << Buffer;
 }
index dbccdd39ceac7b5ed3c2c5d66efbbaf360f08c5b..ff3f69215000dc21d61e06356574aa9d2e6922c3 100644 (file)
@@ -84,6 +84,9 @@ class SummaryView : public View {
   // True if throughput was affected by dispatch stalls.
   bool SeenStallCycles;
 
+  // True if the bottleneck analysis should be displayed.
+  bool ShouldEmitBottleneckAnalysis;
+
   // Compute the reciprocal throughput for the analyzed code block.
   // The reciprocal block throughput is computed as the MAX between:
   //   - NumMicroOps / DispatchWidth
@@ -95,7 +98,7 @@ class SummaryView : public View {
 
 public:
   SummaryView(const llvm::MCSchedModel &Model, llvm::ArrayRef<llvm::MCInst> S,
-              unsigned Width);
+              unsigned Width, bool EmitBottleneckAnalysis);
 
   void onCycleEnd() override {
     ++TotalCycles;
index c7c1a4f1d768451fb5eb5385dd79543e891797a1..17b19d1818f75712a31283b9d2075de01f419729 100644 (file)
@@ -469,7 +469,8 @@ int main(int argc, char **argv) {
     mca::PipelinePrinter Printer(*P);
 
     if (PrintSummaryView)
-      Printer.addView(llvm::make_unique<mca::SummaryView>(SM, Insts, Width));
+      Printer.addView(llvm::make_unique<mca::SummaryView>(
+          SM, Insts, Width, EnableBottleneckAnalysis));
 
     if (PrintInstructionInfoView)
       Printer.addView(