Andrea Di Biagio | 0cc66c7 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 1 | //===--------------------- SummaryView.h ---------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// \file |
| 10 | /// |
| 11 | /// This file implements the summary view. |
| 12 | /// |
| 13 | /// The goal of the summary view is to give a very quick overview of the |
| 14 | /// performance throughput. Below is an example of summary view: |
| 15 | /// |
| 16 | /// |
| 17 | /// Iterations: 300 |
| 18 | /// Instructions: 900 |
| 19 | /// Total Cycles: 610 |
| 20 | /// Dispatch Width: 2 |
| 21 | /// IPC: 1.48 |
| 22 | /// |
| 23 | /// |
| 24 | /// Instruction Info: |
| 25 | /// [1]: #uOps |
| 26 | /// [2]: Latency |
| 27 | /// [3]: RThroughput |
| 28 | /// [4]: MayLoad |
| 29 | /// [5]: MayStore |
| 30 | /// [6]: HasSideEffects |
| 31 | /// |
| 32 | /// [1] [2] [3] [4] [5] [6] Instructions: |
| 33 | /// 1 2 1.00 vmulps %xmm0, %xmm1, %xmm2 |
| 34 | /// 1 3 1.00 vhaddps %xmm2, %xmm2, %xmm3 |
| 35 | /// 1 3 1.00 vhaddps %xmm3, %xmm3, %xmm4 |
| 36 | /// |
| 37 | /// The summary view is structured in two sections. |
| 38 | /// |
| 39 | /// The first section collects a a few performance numbers. The two main |
| 40 | /// performance indicators are 'Total Cycles' and IPC (Instructions Per Cycle). |
| 41 | /// |
| 42 | /// The second section shows the latency and reciprocal throughput of every |
| 43 | /// instruction in the sequence. This section also reports extra informaton |
| 44 | /// related to the number of micro opcodes, and opcode properties (i.e. |
| 45 | /// 'MayLoad', 'MayStore', 'HasSideEffects) |
| 46 | /// |
| 47 | //===----------------------------------------------------------------------===// |
| 48 | |
| 49 | #ifndef LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H |
| 50 | #define LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H |
| 51 | |
Andrea Di Biagio | b522975 | 2018-03-13 17:24:32 +0000 | [diff] [blame] | 52 | #include "SourceMgr.h" |
Andrea Di Biagio | 0cc66c7 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 53 | #include "View.h" |
| 54 | #include "llvm/MC/MCInstPrinter.h" |
Andrea Di Biagio | b522975 | 2018-03-13 17:24:32 +0000 | [diff] [blame] | 55 | #include "llvm/MC/MCSubtargetInfo.h" |
| 56 | #include "llvm/MC/MCInstrInfo.h" |
Andrea Di Biagio | 0cc66c7 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 57 | #include "llvm/Support/raw_ostream.h" |
| 58 | |
| 59 | #define DEBUG_TYPE "llvm-mca" |
| 60 | |
| 61 | namespace mca { |
| 62 | |
| 63 | /// \brief A printer class that knows how to collects statistics on the |
| 64 | /// code analyzed by the llvm-mca tool. |
| 65 | /// |
| 66 | /// This class knows how to print out the analysis information collected |
| 67 | /// during the execution of the code. Internally, it delegates to other |
| 68 | /// classes the task of printing out timeline information as well as |
| 69 | /// resource pressure. |
| 70 | class SummaryView : public View { |
Andrea Di Biagio | b522975 | 2018-03-13 17:24:32 +0000 | [diff] [blame] | 71 | const llvm::MCSubtargetInfo &STI; |
| 72 | const llvm::MCInstrInfo &MCII; |
| 73 | const SourceMgr &Source; |
Andrea Di Biagio | 0cc66c7 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 74 | llvm::MCInstPrinter &MCIP; |
Andrea Di Biagio | b522975 | 2018-03-13 17:24:32 +0000 | [diff] [blame] | 75 | |
Andrea Di Biagio | 0cc66c7 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 76 | const unsigned DispatchWidth; |
| 77 | unsigned TotalCycles; |
| 78 | |
| 79 | void printSummary(llvm::raw_ostream &OS) const; |
| 80 | void printInstructionInfo(llvm::raw_ostream &OS) const; |
| 81 | |
| 82 | public: |
Andrea Di Biagio | b522975 | 2018-03-13 17:24:32 +0000 | [diff] [blame] | 83 | SummaryView(const llvm::MCSubtargetInfo &sti, const llvm::MCInstrInfo &mcii, |
| 84 | const SourceMgr &S, llvm::MCInstPrinter &IP, unsigned Width) |
| 85 | : STI(sti), MCII(mcii), Source(S), MCIP(IP), DispatchWidth(Width), |
| 86 | TotalCycles(0) {} |
Andrea Di Biagio | 0cc66c7 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 87 | |
| 88 | void onCycleEnd(unsigned /* unused */) override { ++TotalCycles; } |
| 89 | |
| 90 | void printView(llvm::raw_ostream &OS) const override { |
| 91 | printSummary(OS); |
| 92 | printInstructionInfo(OS); |
| 93 | } |
| 94 | }; |
| 95 | |
| 96 | } // namespace mca |
| 97 | |
| 98 | #endif |