[PATCH] D59098: [llvm-mca] Emit a message when no bottlenecks are identified.

Matt Davis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 7 09:02:18 PST 2019


mattd created this revision.
mattd added a reviewer: andreadb.
Herald added subscribers: gbedwell, tschuett.
Herald added a project: LLVM.

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.


https://reviews.llvm.org/D59098

Files:
  llvm/test/tools/llvm-mca/X86/BtVer2/bottleneck-hints-none.s
  llvm/tools/llvm-mca/Views/SummaryView.cpp
  llvm/tools/llvm-mca/Views/SummaryView.h
  llvm/tools/llvm-mca/llvm-mca.cpp


Index: llvm/tools/llvm-mca/llvm-mca.cpp
===================================================================
--- llvm/tools/llvm-mca/llvm-mca.cpp
+++ llvm/tools/llvm-mca/llvm-mca.cpp
@@ -469,7 +469,8 @@
     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(
Index: llvm/tools/llvm-mca/Views/SummaryView.h
===================================================================
--- llvm/tools/llvm-mca/Views/SummaryView.h
+++ llvm/tools/llvm-mca/Views/SummaryView.h
@@ -84,6 +84,9 @@
   // 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 @@
 
 public:
   SummaryView(const llvm::MCSchedModel &Model, llvm::ArrayRef<llvm::MCInst> S,
-              unsigned Width);
+              unsigned Width, bool EmitBottleneckAnalysis);
 
   void onCycleEnd() override {
     ++TotalCycles;
Index: llvm/tools/llvm-mca/Views/SummaryView.cpp
===================================================================
--- llvm/tools/llvm-mca/Views/SummaryView.cpp
+++ llvm/tools/llvm-mca/Views/SummaryView.cpp
@@ -23,7 +23,7 @@
 #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 @@
       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::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 @@
   TempStream << "\nBlock RThroughput: "
              << format("%.1f", floor((BlockRThroughput * 10) + 0.5) / 10)
              << '\n';
-
-  printBottleneckHints(TempStream);
+  if (ShouldEmitBottleneckAnalysis)
+    printBottleneckHints(TempStream);
   TempStream.flush();
   OS << Buffer;
 }
Index: llvm/test/tools/llvm-mca/X86/BtVer2/bottleneck-hints-none.s
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-mca/X86/BtVer2/bottleneck-hints-none.s
@@ -0,0 +1,6 @@
+# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -bottleneck-analysis -iterations 1 < %s \
+# RUN:   | FileCheck %s -implicit-check-not 'Cycles with backend pressure increase'
+
+add %eax, %ebx
+
+# CHECK: No resource or data dependency bottlenecks discovered.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59098.189726.patch
Type: text/x-patch
Size: 3733 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190307/3d98036c/attachment.bin>


More information about the llvm-commits mailing list