RetireControlUnitStatistics.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //===--------------------- RetireControlUnitStatistics.h --------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. /// \file
  9. ///
  10. /// This file defines class RetireControlUnitStatistics: a view that knows how
  11. /// to print general statistics related to the retire control unit.
  12. ///
  13. /// Example:
  14. /// ========
  15. ///
  16. /// Retire Control Unit - number of cycles where we saw N instructions retired:
  17. /// [# retired], [# cycles]
  18. /// 0, 109 (17.9%)
  19. /// 1, 102 (16.7%)
  20. /// 2, 399 (65.4%)
  21. ///
  22. /// Total ROB Entries: 64
  23. /// Max Used ROB Entries: 35 ( 54.7% )
  24. /// Average Used ROB Entries per cy: 32 ( 50.0% )
  25. ///
  26. //===----------------------------------------------------------------------===//
  27. #ifndef LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H
  28. #define LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H
  29. #include "llvm/MC/MCSchedule.h"
  30. #include "llvm/MCA/View.h"
  31. #include <map>
  32. namespace llvm {
  33. namespace mca {
  34. class RetireControlUnitStatistics : public View {
  35. using Histogram = std::map<unsigned, unsigned>;
  36. Histogram RetiredPerCycle;
  37. unsigned NumRetired;
  38. unsigned NumCycles;
  39. unsigned TotalROBEntries;
  40. unsigned EntriesInUse;
  41. unsigned MaxUsedEntries;
  42. unsigned SumOfUsedEntries;
  43. public:
  44. RetireControlUnitStatistics(const MCSchedModel &SM);
  45. void onEvent(const HWInstructionEvent &Event) override;
  46. void onCycleEnd() override;
  47. void printView(llvm::raw_ostream &OS) const override;
  48. StringRef getNameAsString() const override {
  49. return "RetireControlUnitStatistics";
  50. }
  51. bool isSerializable() const override { return false; }
  52. };
  53. } // namespace mca
  54. } // namespace llvm
  55. #endif