1 //===--------------------- SummaryView.h ---------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file implements the summary view.
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:
22 /// Block RThroughput: 2.0
24 /// The summary view collects a few performance numbers. The two main
25 /// performance indicators are 'Total Cycles' and IPC (Instructions Per Cycle).
27 //===----------------------------------------------------------------------===//
29 #ifndef LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H
30 #define LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H
32 #include "SourceMgr.h"
34 #include "llvm/ADT/DenseMap.h"
35 #include "llvm/MC/MCSchedule.h"
36 #include "llvm/Support/raw_ostream.h"
40 /// A view that collects and prints a few performance numbers.
41 class SummaryView : public View {
42 const llvm::MCSchedModel &SM;
43 const SourceMgr &Source;
44 const unsigned DispatchWidth;
46 // The total number of micro opcodes contributed by a block of instructions.
48 // For each processor resource, this vector stores the cumulative number of
49 // resource cycles consumed by the analyzed code block.
50 llvm::SmallVector<unsigned, 8> ProcResourceUsage;
52 // Each processor resource is associated with a so-called processor resource
53 // mask. This vector allows to correlate processor resource IDs with processor
54 // resource masks. There is exactly one element per each processor resource
55 // declared by the scheduling model.
56 llvm::SmallVector<uint64_t, 8> ProcResourceMasks;
58 // Compute the reciprocal throughput for the analyzed code block.
59 // The reciprocal block throughput is computed as the MAX between:
60 // - NumMicroOps / DispatchWidth
61 // - Total Resource Cycles / #Units (for every resource consumed).
62 double getBlockRThroughput() const;
65 SummaryView(const llvm::MCSchedModel &Model, const SourceMgr &S,
68 void onCycleEnd() override { ++TotalCycles; }
70 void onEvent(const HWInstructionEvent &Event) override;
72 void printView(llvm::raw_ostream &OS) const override;