llvm.org GIT mirror llvm / 848dcbd
[llvm-mca][View] Improved Retire Control Unit Statistics. RetireControlUnitStatistics now reports extra information about the ROB and the avg/maximum number of entries consumed over the entire simulation. Example: Retire Control Unit - number of cycles where we saw N instructions retired: [# retired], [# cycles] 0, 109 (17.9%) 1, 102 (16.7%) 2, 399 (65.4%) Total ROB Entries: 64 Max Used ROB Entries: 35 ( 54.7% ) Average Used ROB Entries per cy: 32 ( 50.0% ) Documentation in llvm/docs/CommandGuide/llvmn-mca.rst has been updated to reflect this change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347493 91177308-0d34-0410-b5e6-96231b3b80d8 Andrea Di Biagio 9 months ago
10 changed file(s) with 87 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
515515 1, 102 (16.7%)
516516 2, 399 (65.4%)
517517
518 Total ROB Entries: 64
519 Max Used ROB Entries: 35 ( 54.7% )
520 Average Used ROB Entries per cy: 32 ( 50.0% )
521
518522
519523 Register File statistics:
520524 Total number of mappings created: 900
5959 # CHECK-NEXT: 1, 9 (40.9%)
6060 # CHECK-NEXT: 3, 1 (4.5%)
6161 # CHECK-NEXT: 4, 1 (4.5%)
62
63 # CHECK: Total ROB Entries: 128
64 # CHECK-NEXT: Max Used ROB Entries: 16 ( 12.5% )
65 # CHECK-NEXT: Average Used ROB Entries per cy: 9 ( 7.0% )
5757 # CHECK-NEXT: [# retired], [# cycles]
5858 # CHECK-NEXT: 0, 23 (74.2%)
5959 # CHECK-NEXT: 2, 8 (25.8%)
60
61 # CHECK: Total ROB Entries: 64
62 # CHECK-NEXT: Max Used ROB Entries: 16 ( 25.0% )
63 # CHECK-NEXT: Average Used ROB Entries per cy: 11 ( 17.2% )
6161 # FULLREPORT-NEXT: 0, 3 (2.9%)
6262 # FULLREPORT-NEXT: 1, 100 (97.1%)
6363
64 # FULLREPORT: Total ROB Entries: 64
65 # FULLREPORT-NEXT: Max Used ROB Entries: 22 ( 34.4% )
66 # FULLREPORT-NEXT: Average Used ROB Entries per cy: 17 ( 26.6% )
67
6468 # FULLREPORT: Register File statistics:
6569 # FULLREPORT-NEXT: Total number of mappings created: 200
6670 # FULLREPORT-NEXT: Max number of mappings used: 44
6262 # ALL-NEXT: 0, 3 (2.9%)
6363 # ALL-NEXT: 1, 100 (97.1%)
6464
65 # ALL: Total ROB Entries: 64
66 # ALL-NEXT: Max Used ROB Entries: 22 ( 34.4% )
67 # ALL-NEXT: Average Used ROB Entries per cy: 17 ( 26.6% )
68
6569 # ALL: Register File statistics:
6670 # ALL-NEXT: Total number of mappings created: 200
6771 # ALL-NEXT: Max number of mappings used: 44
6363 # FULLREPORT-NEXT: 0, 3 (2.9%)
6464 # FULLREPORT-NEXT: 1, 100 (97.1%)
6565
66 # FULLREPORT: Total ROB Entries: 64
67 # FULLREPORT-NEXT: Max Used ROB Entries: 22 ( 34.4% )
68 # FULLREPORT-NEXT: Average Used ROB Entries per cy: 17 ( 26.6% )
69
6670 # FULLREPORT: Register File statistics:
6771 # FULLREPORT-NEXT: Total number of mappings created: 200
6872 # FULLREPORT-NEXT: Max number of mappings used: 44
6262 # ALL-NEXT: 0, 3 (2.9%)
6363 # ALL-NEXT: 1, 100 (97.1%)
6464
65 # ALL: Total ROB Entries: 64
66 # ALL-NEXT: Max Used ROB Entries: 22 ( 34.4% )
67 # ALL-NEXT: Average Used ROB Entries per cy: 17 ( 26.6% )
68
6569 # ALL: Register File statistics:
6670 # ALL-NEXT: Total number of mappings created: 200
6771 # ALL-NEXT: Max number of mappings used: 44
1717 namespace llvm {
1818 namespace mca {
1919
20 RetireControlUnitStatistics::RetireControlUnitStatistics(const MCSchedModel &SM)
21 : NumRetired(0), NumCycles(0), EntriesInUse(0), MaxUsedEntries(0),
22 SumOfUsedEntries(0) {
23 TotalROBEntries = SM.MicroOpBufferSize;
24 if (SM.hasExtraProcessorInfo()) {
25 const MCExtraProcessorInfo &EPI = SM.getExtraProcessorInfo();
26 if (EPI.ReorderBufferSize)
27 TotalROBEntries = EPI.ReorderBufferSize;
28 }
29 }
30
2031 void RetireControlUnitStatistics::onEvent(const HWInstructionEvent &Event) {
21 if (Event.Type == HWInstructionEvent::Retired)
32 if (Event.Type == HWInstructionEvent::Dispatched) {
33 unsigned NumEntries =
34 static_cast(Event).MicroOpcodes;
35 EntriesInUse += NumEntries;
36 }
37
38 if (Event.Type == HWInstructionEvent::Retired) {
39 unsigned ReleasedEntries = Event.IR.getInstruction()->getDesc().NumMicroOps;
40 assert(EntriesInUse >= ReleasedEntries && "Invalid internal state!");
41 EntriesInUse -= ReleasedEntries;
2242 ++NumRetired;
43 }
44 }
45
46 void RetireControlUnitStatistics::onCycleEnd() {
47 // Update histogram
48 RetiredPerCycle[NumRetired]++;
49 NumRetired = 0;
50 ++NumCycles;
51 MaxUsedEntries = std::max(MaxUsedEntries, EntriesInUse);
52 SumOfUsedEntries += EntriesInUse;
2353 }
2454
2555 void RetireControlUnitStatistics::printView(raw_ostream &OS) const {
4070 << "%)\n";
4171 }
4272
73 unsigned AvgUsage = (double)SumOfUsedEntries / NumCycles;
74 double MaxUsagePercentage = ((double)MaxUsedEntries / TotalROBEntries) * 100.0;
75 double NormalizedMaxPercentage = floor((MaxUsagePercentage * 10) + 0.5) / 10;
76 double AvgUsagePercentage = ((double)AvgUsage / TotalROBEntries) * 100.0;
77 double NormalizedAvgPercentage = floor((AvgUsagePercentage * 10) + 0.5) / 10;
78
79 TempStream << "\nTotal ROB Entries: " << TotalROBEntries
80 << "\nMax Used ROB Entries: " << MaxUsedEntries
81 << format(" ( %.1f%% )", NormalizedMaxPercentage)
82 << "\nAverage Used ROB Entries per cy: " << AvgUsage
83 << format(" ( %.1f%% )\n", NormalizedAvgPercentage);
84
4385 TempStream.flush();
4486 OS << Buffer;
4587 }
1515 ///
1616 /// Retire Control Unit - number of cycles where we saw N instructions retired:
1717 /// [# retired], [# cycles]
18 /// 0, 9 (6.9%)
19 /// 1, 6 (4.6%)
20 /// 2, 1 (0.8%)
21 /// 4, 3 (2.3%)
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% )
2225 ///
2326 //===----------------------------------------------------------------------===//
2427
2629 #define LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H
2730
2831 #include "Views/View.h"
29 #include "llvm/MC/MCSubtargetInfo.h"
32 #include "llvm/MC/MCSchedule.h"
3033 #include
3134
3235 namespace llvm {
3841
3942 unsigned NumRetired;
4043 unsigned NumCycles;
41
42 void updateHistograms() {
43 RetiredPerCycle[NumRetired]++;
44 NumRetired = 0;
45 }
44 unsigned TotalROBEntries;
45 unsigned EntriesInUse;
46 unsigned MaxUsedEntries;
47 unsigned SumOfUsedEntries;
4648
4749 public:
48 RetireControlUnitStatistics() : NumRetired(0), NumCycles(0) {}
50 RetireControlUnitStatistics(const MCSchedModel &SM);
4951
5052 void onEvent(const HWInstructionEvent &Event) override;
51 void onCycleBegin() override { NumCycles++; }
52 void onCycleEnd() override { updateHistograms(); }
53
53 void onCycleEnd() override;
5454 void printView(llvm::raw_ostream &OS) const override;
5555 };
56
5657 } // namespace mca
5758 } // namespace llvm
5859
471471 Printer.addView(llvm::make_unique(*STI));
472472
473473 if (PrintRetireStats)
474 Printer.addView(llvm::make_unique());
474 Printer.addView(llvm::make_unique(SM));
475475
476476 if (PrintRegisterFileStats)
477477 Printer.addView(llvm::make_unique(*STI));