Path: blob/main/contrib/llvm-project/llvm/tools/llvm-mca/Views/SummaryView.h
35290 views
//===--------------------- SummaryView.h ------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7/// \file8///9/// This file implements the summary view.10///11/// The goal of the summary view is to give a very quick overview of the12/// performance throughput. Below is an example of summary view:13///14///15/// Iterations: 30016/// Instructions: 90017/// Total Cycles: 61018/// Dispatch Width: 219/// IPC: 1.4820/// Block RThroughput: 2.021///22/// The summary view collects a few performance numbers. The two main23/// performance indicators are 'Total Cycles' and IPC (Instructions Per Cycle).24///25//===----------------------------------------------------------------------===//2627#ifndef LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H28#define LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H2930#include "llvm/MC/MCSchedule.h"31#include "llvm/MCA/View.h"32#include "llvm/Support/raw_ostream.h"3334namespace llvm {35namespace mca {3637/// A view that collects and prints a few performance numbers.38class SummaryView : public View {39const llvm::MCSchedModel &SM;40llvm::ArrayRef<llvm::MCInst> Source;41const unsigned DispatchWidth;42unsigned LastInstructionIdx;43unsigned TotalCycles;44// The total number of micro opcodes contributed by a block of instructions.45unsigned NumMicroOps;4647struct DisplayValues {48unsigned Instructions;49unsigned Iterations;50unsigned TotalInstructions;51unsigned TotalCycles;52unsigned DispatchWidth;53unsigned TotalUOps;54double IPC;55double UOpsPerCycle;56double BlockRThroughput;57};5859// For each processor resource, this vector stores the cumulative number of60// resource cycles consumed by the analyzed code block.61llvm::SmallVector<unsigned, 8> ProcResourceUsage;6263// Each processor resource is associated with a so-called processor resource64// mask. This vector allows to correlate processor resource IDs with processor65// resource masks. There is exactly one element per each processor resource66// declared by the scheduling model.67llvm::SmallVector<uint64_t, 8> ProcResourceMasks;6869// Used to map resource indices to actual processor resource IDs.70llvm::SmallVector<unsigned, 8> ResIdx2ProcResID;7172/// Compute the data we want to print out in the object DV.73void collectData(DisplayValues &DV) const;7475public:76SummaryView(const llvm::MCSchedModel &Model, llvm::ArrayRef<llvm::MCInst> S,77unsigned Width);7879void onCycleEnd() override { ++TotalCycles; }80void onEvent(const HWInstructionEvent &Event) override;81void printView(llvm::raw_ostream &OS) const override;82StringRef getNameAsString() const override { return "SummaryView"; }83json::Value toJSON() const override;84};85} // namespace mca86} // namespace llvm8788#endif899091