]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/llvm-mca/Views/SummaryView.h
MFC r345703:
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / llvm-mca / Views / SummaryView.h
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 /// Block RThroughput: 2.0
23 ///
24 /// The summary view collects a few performance numbers. The two main
25 /// performance indicators are 'Total Cycles' and IPC (Instructions Per Cycle).
26 ///
27 //===----------------------------------------------------------------------===//
28
29 #ifndef LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H
30 #define LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H
31
32 #include "Views/View.h"
33 #include "llvm/ADT/DenseMap.h"
34 #include "llvm/MC/MCSchedule.h"
35 #include "llvm/Support/raw_ostream.h"
36
37 namespace llvm {
38 namespace mca {
39
40 /// A view that collects and prints a few performance numbers.
41 class SummaryView : public View {
42   const llvm::MCSchedModel &SM;
43   llvm::ArrayRef<llvm::MCInst> Source;
44   const unsigned DispatchWidth;
45   unsigned LastInstructionIdx;
46   unsigned TotalCycles;
47   // The total number of micro opcodes contributed by a block of instructions.
48   unsigned NumMicroOps;
49   // For each processor resource, this vector stores the cumulative number of
50   // resource cycles consumed by the analyzed code block.
51   llvm::SmallVector<unsigned, 8> ProcResourceUsage;
52
53   // Each processor resource is associated with a so-called processor resource
54   // mask. This vector allows to correlate processor resource IDs with processor
55   // resource masks. There is exactly one element per each processor resource
56   // declared by the scheduling model.
57   llvm::SmallVector<uint64_t, 8> ProcResourceMasks;
58
59   // Compute the reciprocal throughput for the analyzed code block.
60   // The reciprocal block throughput is computed as the MAX between:
61   //   - NumMicroOps / DispatchWidth
62   //   - Total Resource Cycles / #Units   (for every resource consumed).
63   double getBlockRThroughput() const;
64
65 public:
66   SummaryView(const llvm::MCSchedModel &Model, llvm::ArrayRef<llvm::MCInst> S,
67               unsigned Width);
68
69   void onCycleEnd() override { ++TotalCycles; }
70   void onEvent(const HWInstructionEvent &Event) override;
71
72   void printView(llvm::raw_ostream &OS) const override;
73 };
74 } // namespace mca
75 } // namespace llvm
76
77 #endif