1 //===--------------------- RetireControlUnitStatistics.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 defines class RetireControlUnitStatistics: a view that knows how 12 /// to print general statistics related to the retire control unit. 13 /// 14 /// Example: 15 /// ======== 16 /// 17 /// Retire Control Unit - number of cycles where we saw N instructions retired: 18 /// [# retired], [# cycles] 19 /// 0, 9 (6.9%) 20 /// 1, 6 (4.6%) 21 /// 2, 1 (0.8%) 22 /// 4, 3 (2.3%) 23 /// 24 //===----------------------------------------------------------------------===// 25 26 #ifndef LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H 27 #define LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H 28 29 #include "View.h" 30 #include "llvm/MC/MCSubtargetInfo.h" 31 #include <map> 32 33 namespace mca { 34 35 class RetireControlUnitStatistics : public View { 36 using Histogram = std::map<unsigned, unsigned>; 37 Histogram RetiredPerCycle; 38 39 unsigned NumRetired; 40 unsigned NumCycles; 41 updateHistograms()42 void updateHistograms() { 43 RetiredPerCycle[NumRetired]++; 44 NumRetired = 0; 45 } 46 47 public: RetireControlUnitStatistics()48 RetireControlUnitStatistics() : NumRetired(0), NumCycles(0) {} 49 50 void onEvent(const HWInstructionEvent &Event) override; 51 onCycleBegin()52 void onCycleBegin() override { NumCycles++; } 53 onCycleEnd()54 void onCycleEnd() override { updateHistograms(); } 55 56 void printView(llvm::raw_ostream &OS) const override; 57 }; 58 } // namespace mca 59 60 #endif 61