aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-mca/SummaryView.h
blob: 0484057fb1043bf2cd1a25a6887a4fcdb722bd0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//===--------------------- SummaryView.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 summary view.
///
/// The goal of the summary view is to give a very quick overview of the
/// performance throughput. Below is an example of summary view:
///
///
/// Iterations:     300
/// Instructions:   900
/// Total Cycles:   610
/// Dispatch Width: 2
/// IPC:            1.48
///
///
/// The summary view collects a few performance numbers. The two main
/// performance indicators are 'Total Cycles' and IPC (Instructions Per Cycle).
///
//===----------------------------------------------------------------------===//

#ifndef LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H
#define LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H

#include "SourceMgr.h"
#include "View.h"
#include "llvm/Support/raw_ostream.h"

namespace mca {

/// A view that collects and prints a few performance numbers.
class SummaryView : public View {
  const SourceMgr &Source;
  const unsigned DispatchWidth;
  unsigned TotalCycles;

public:
  SummaryView(const SourceMgr &S, unsigned Width)
      : Source(S), DispatchWidth(Width), TotalCycles(0) {}

  void onCycleEnd() override { ++TotalCycles; }

  void printView(llvm::raw_ostream &OS) const override;
};
} // namespace mca

#endif