[llvm] r328358 - [llvm-mca] Split the InstructionInfoView from the SummaryView.
Andrea Di Biagio via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 23 12:40:04 PDT 2018
Author: adibiagio
Date: Fri Mar 23 12:40:04 2018
New Revision: 328358
URL: http://llvm.org/viewvc/llvm-project?rev=328358&view=rev
Log:
[llvm-mca] Split the InstructionInfoView from the SummaryView.
Added:
llvm/trunk/tools/llvm-mca/InstructionInfoView.cpp
llvm/trunk/tools/llvm-mca/InstructionInfoView.h
Modified:
llvm/trunk/tools/llvm-mca/CMakeLists.txt
llvm/trunk/tools/llvm-mca/SummaryView.cpp
llvm/trunk/tools/llvm-mca/SummaryView.h
llvm/trunk/tools/llvm-mca/llvm-mca.cpp
Modified: llvm/trunk/tools/llvm-mca/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/CMakeLists.txt?rev=328358&r1=328357&r2=328358&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-mca/CMakeLists.txt Fri Mar 23 12:40:04 2018
@@ -17,6 +17,7 @@ add_llvm_tool(llvm-mca
HWEventListener.cpp
InstrBuilder.cpp
Instruction.cpp
+ InstructionInfoView.cpp
LSUnit.cpp
llvm-mca.cpp
ResourcePressureView.cpp
Added: llvm/trunk/tools/llvm-mca/InstructionInfoView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/InstructionInfoView.cpp?rev=328358&view=auto
==============================================================================
--- llvm/trunk/tools/llvm-mca/InstructionInfoView.cpp (added)
+++ llvm/trunk/tools/llvm-mca/InstructionInfoView.cpp Fri Mar 23 12:40:04 2018
@@ -0,0 +1,75 @@
+//===--------------------- InstructionInfoView.cpp -------------------*- C++
+//-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+/// \file
+///
+/// This file implements the InstructionView API.
+///
+//===----------------------------------------------------------------------===//
+
+#include "InstructionInfoView.h"
+
+namespace mca {
+
+using namespace llvm;
+
+void InstructionInfoView::printView(raw_ostream &OS) const {
+ std::string Buffer;
+ raw_string_ostream TempStream(Buffer);
+ const MCSchedModel &SM = STI.getSchedModel();
+ unsigned Instructions = Source.size();
+
+ TempStream << "\n\nInstruction Info:\n";
+ TempStream << "[1]: #uOps\n[2]: Latency\n[3]: RThroughput\n"
+ << "[4]: MayLoad\n[5]: MayStore\n[6]: HasSideEffects\n\n";
+
+ TempStream << "[1] [2] [3] [4] [5] [6]\tInstructions:\n";
+ for (unsigned I = 0, E = Instructions; I < E; ++I) {
+ const MCInst &Inst = Source.getMCInstFromIndex(I);
+ const MCInstrDesc &MCDesc = MCII.get(Inst.getOpcode());
+ const MCSchedClassDesc &SCDesc =
+ *SM.getSchedClassDesc(MCDesc.getSchedClass());
+
+ unsigned NumMicroOpcodes = SCDesc.NumMicroOps;
+ unsigned Latency = MCSchedModel::computeInstrLatency(STI, SCDesc);
+ Optional<double> RThroughput =
+ MCSchedModel::getReciprocalThroughput(STI, SCDesc);
+
+ TempStream << ' ' << NumMicroOpcodes << " ";
+ if (NumMicroOpcodes < 10)
+ TempStream << " ";
+ else if (NumMicroOpcodes < 100)
+ TempStream << ' ';
+ TempStream << Latency << " ";
+ if (Latency < 10)
+ TempStream << " ";
+ else if (Latency < 100)
+ TempStream << ' ';
+
+ if (RThroughput.hasValue()) {
+ double RT = RThroughput.getValue();
+ TempStream << format("%.2f", RT) << ' ';
+ if (RT < 10.0)
+ TempStream << " ";
+ else if (RT < 100.0)
+ TempStream << ' ';
+ } else {
+ TempStream << " - ";
+ }
+ TempStream << (MCDesc.mayLoad() ? " * " : " ");
+ TempStream << (MCDesc.mayStore() ? " * " : " ");
+ TempStream << (MCDesc.hasUnmodeledSideEffects() ? " * " : " ");
+ MCIP.printInst(&Inst, TempStream, "", STI);
+ TempStream << '\n';
+ }
+
+ TempStream.flush();
+ OS << Buffer;
+}
+} // namespace mca.
Added: llvm/trunk/tools/llvm-mca/InstructionInfoView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/InstructionInfoView.h?rev=328358&view=auto
==============================================================================
--- llvm/trunk/tools/llvm-mca/InstructionInfoView.h (added)
+++ llvm/trunk/tools/llvm-mca/InstructionInfoView.h Fri Mar 23 12:40:04 2018
@@ -0,0 +1,66 @@
+//===--------------------- InstructionInfoView.h ----------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+/// \file
+///
+/// This file implements the instruction info view.
+///
+/// The goal fo the instruction info view is to print the latency and reciprocal
+/// throughput information for every instruction in the input sequence.
+/// This section also reports extra information related to the number of micro
+/// opcodes, and opcode properties (i.e. 'MayLoad', 'MayStore', 'HasSideEffects)
+///
+/// Example:
+///
+/// Instruction Info:
+/// [1]: #uOps
+/// [2]: Latency
+/// [3]: RThroughput
+/// [4]: MayLoad
+/// [5]: MayStore
+/// [6]: HasSideEffects
+///
+/// [1] [2] [3] [4] [5] [6] Instructions:
+/// 1 2 1.00 vmulps %xmm0, %xmm1, %xmm2
+/// 1 3 1.00 vhaddps %xmm2, %xmm2, %xmm3
+/// 1 3 1.00 vhaddps %xmm3, %xmm3, %xmm4
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVM_MCA_INSTRUCTIONINFOVIEW_H
+#define LLVM_TOOLS_LLVM_MCA_INSTRUCTIONINFOVIEW_H
+
+#include "SourceMgr.h"
+#include "View.h"
+#include "llvm/MC/MCInstPrinter.h"
+#include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/Support/raw_ostream.h"
+
+#define DEBUG_TYPE "llvm-mca"
+
+namespace mca {
+
+/// \brief A view that prints out generic instruction information.
+class InstructionInfoView : public View {
+ const llvm::MCSubtargetInfo &STI;
+ const llvm::MCInstrInfo &MCII;
+ const SourceMgr &Source;
+ llvm::MCInstPrinter &MCIP;
+
+public:
+ InstructionInfoView(const llvm::MCSubtargetInfo &sti,
+ const llvm::MCInstrInfo &mcii, const SourceMgr &S,
+ llvm::MCInstPrinter &IP)
+ : STI(sti), MCII(mcii), Source(S), MCIP(IP) {}
+
+ void printView(llvm::raw_ostream &OS) const override;
+};
+} // namespace mca
+
+#endif
Modified: llvm/trunk/tools/llvm-mca/SummaryView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/SummaryView.cpp?rev=328358&r1=328357&r2=328358&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/SummaryView.cpp (original)
+++ llvm/trunk/tools/llvm-mca/SummaryView.cpp Fri Mar 23 12:40:04 2018
@@ -14,13 +14,15 @@
//===----------------------------------------------------------------------===//
#include "SummaryView.h"
-#include "llvm/CodeGen/TargetSchedule.h"
+#include "llvm/Support/Format.h"
namespace mca {
+#define DEBUG_TYPE "llvm-mca"
+
using namespace llvm;
-void SummaryView::printSummary(raw_ostream &OS) const {
+void SummaryView::printView(raw_ostream &OS) const {
unsigned Iterations = Source.getNumIterations();
unsigned Instructions = Source.size();
unsigned TotalInstructions = Instructions * Iterations;
@@ -36,59 +38,5 @@ void SummaryView::printSummary(raw_ostre
TempStream.flush();
OS << Buffer;
}
-
-void SummaryView::printInstructionInfo(raw_ostream &OS) const {
- std::string Buffer;
- raw_string_ostream TempStream(Buffer);
- const MCSchedModel &SM = STI.getSchedModel();
- unsigned Instructions = Source.size();
-
- TempStream << "\n\nInstruction Info:\n";
- TempStream << "[1]: #uOps\n[2]: Latency\n[3]: RThroughput\n"
- << "[4]: MayLoad\n[5]: MayStore\n[6]: HasSideEffects\n\n";
-
- TempStream << "[1] [2] [3] [4] [5] [6]\tInstructions:\n";
- for (unsigned I = 0, E = Instructions; I < E; ++I) {
- const MCInst &Inst = Source.getMCInstFromIndex(I);
- const MCInstrDesc &MCDesc = MCII.get(Inst.getOpcode());
- const MCSchedClassDesc &SCDesc =
- *SM.getSchedClassDesc(MCDesc.getSchedClass());
-
- unsigned NumMicroOpcodes = SCDesc.NumMicroOps;
- unsigned Latency = MCSchedModel::computeInstrLatency(STI, SCDesc);
- Optional<double> RThroughput =
- MCSchedModel::getReciprocalThroughput(STI, SCDesc);
-
- TempStream << ' ' << NumMicroOpcodes << " ";
- if (NumMicroOpcodes < 10)
- TempStream << " ";
- else if (NumMicroOpcodes < 100)
- TempStream << ' ';
- TempStream << Latency << " ";
- if (Latency < 10)
- TempStream << " ";
- else if (Latency < 100)
- TempStream << ' ';
-
- if (RThroughput.hasValue()) {
- double RT = RThroughput.getValue();
- TempStream << format("%.2f", RT) << ' ';
- if (RT < 10.0)
- TempStream << " ";
- else if (RT < 100.0)
- TempStream << ' ';
- } else {
- TempStream << " - ";
- }
- TempStream << (MCDesc.mayLoad() ? " * " : " ");
- TempStream << (MCDesc.mayStore() ? " * " : " ");
- TempStream << (MCDesc.hasUnmodeledSideEffects() ? " * " : " ");
- MCIP.printInst(&Inst, TempStream, "", STI);
- TempStream << '\n';
- }
-
- TempStream.flush();
- OS << Buffer;
-}
} // namespace mca.
Modified: llvm/trunk/tools/llvm-mca/SummaryView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/SummaryView.h?rev=328358&r1=328357&r2=328358&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/SummaryView.h (original)
+++ llvm/trunk/tools/llvm-mca/SummaryView.h Fri Mar 23 12:40:04 2018
@@ -21,29 +21,9 @@
/// IPC: 1.48
///
///
-/// Instruction Info:
-/// [1]: #uOps
-/// [2]: Latency
-/// [3]: RThroughput
-/// [4]: MayLoad
-/// [5]: MayStore
-/// [6]: HasSideEffects
-///
-/// [1] [2] [3] [4] [5] [6] Instructions:
-/// 1 2 1.00 vmulps %xmm0, %xmm1, %xmm2
-/// 1 3 1.00 vhaddps %xmm2, %xmm2, %xmm3
-/// 1 3 1.00 vhaddps %xmm3, %xmm3, %xmm4
-///
-/// The summary view is structured in two sections.
-///
-/// The first section collects a a few performance numbers. The two main
+/// The summary view collects a few performance numbers. The two main
/// performance indicators are 'Total Cycles' and IPC (Instructions Per Cycle).
///
-/// The second section shows the latency and reciprocal throughput of every
-/// instruction in the sequence. This section also reports extra informaton
-/// related to the number of micro opcodes, and opcode properties (i.e.
-/// 'MayLoad', 'MayStore', 'HasSideEffects)
-///
//===----------------------------------------------------------------------===//
#ifndef LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H
@@ -51,48 +31,24 @@
#include "SourceMgr.h"
#include "View.h"
-#include "llvm/MC/MCInstPrinter.h"
-#include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/MC/MCInstrInfo.h"
#include "llvm/Support/raw_ostream.h"
-#define DEBUG_TYPE "llvm-mca"
-
namespace mca {
-/// \brief A printer class that knows how to collects statistics on the
-/// code analyzed by the llvm-mca tool.
-///
-/// This class knows how to print out the analysis information collected
-/// during the execution of the code. Internally, it delegates to other
-/// classes the task of printing out timeline information as well as
-/// resource pressure.
+/// \brief A view that collects and prints a few performance numbers.
class SummaryView : public View {
- const llvm::MCSubtargetInfo &STI;
- const llvm::MCInstrInfo &MCII;
const SourceMgr &Source;
- llvm::MCInstPrinter &MCIP;
-
const unsigned DispatchWidth;
unsigned TotalCycles;
- void printSummary(llvm::raw_ostream &OS) const;
- void printInstructionInfo(llvm::raw_ostream &OS) const;
-
public:
- SummaryView(const llvm::MCSubtargetInfo &sti, const llvm::MCInstrInfo &mcii,
- const SourceMgr &S, llvm::MCInstPrinter &IP, unsigned Width)
- : STI(sti), MCII(mcii), Source(S), MCIP(IP), DispatchWidth(Width),
- TotalCycles(0) {}
+ SummaryView(const SourceMgr &S, unsigned Width)
+ : Source(S), DispatchWidth(Width), TotalCycles(0) {}
void onCycleEnd(unsigned /* unused */) override { ++TotalCycles; }
- void printView(llvm::raw_ostream &OS) const override {
- printSummary(OS);
- printInstructionInfo(OS);
- }
+ void printView(llvm::raw_ostream &OS) const override;
};
-
} // namespace mca
#endif
Modified: llvm/trunk/tools/llvm-mca/llvm-mca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/llvm-mca.cpp?rev=328358&r1=328357&r2=328358&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/llvm-mca.cpp (original)
+++ llvm/trunk/tools/llvm-mca/llvm-mca.cpp Fri Mar 23 12:40:04 2018
@@ -23,6 +23,7 @@
#include "BackendPrinter.h"
#include "BackendStatistics.h"
+#include "InstructionInfoView.h"
#include "ResourcePressureView.h"
#include "SummaryView.h"
#include "TimelineView.h"
@@ -332,8 +333,10 @@ int main(int argc, char **argv) {
std::unique_ptr<mca::BackendPrinter> Printer =
llvm::make_unique<mca::BackendPrinter>(*B);
+ Printer->addView(llvm::make_unique<mca::SummaryView>(*S, Width));
+
Printer->addView(
- llvm::make_unique<mca::SummaryView>(*STI, *MCII, *S, *IP, Width));
+ llvm::make_unique<mca::InstructionInfoView>(*STI, *MCII, *S, *IP));
if (PrintModeVerbose)
Printer->addView(llvm::make_unique<mca::BackendStatistics>(*STI));
More information about the llvm-commits
mailing list