1 //===--------------------- DispatchStatistics.cpp ---------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
12 /// This file implements the DispatchStatistics interface.
14 //===----------------------------------------------------------------------===//
16 #include "Views/DispatchStatistics.h"
17 #include "llvm/Support/Format.h"
22 void DispatchStatistics::onEvent(const HWStallEvent &Event) {
23 if (Event.Type < HWStallEvent::LastGenericEvent)
24 HWStalls[Event.Type]++;
27 void DispatchStatistics::onEvent(const HWInstructionEvent &Event) {
28 if (Event.Type != HWInstructionEvent::Dispatched)
31 const auto &DE = static_cast<const HWInstructionDispatchedEvent &>(Event);
32 NumDispatched += DE.MicroOpcodes;
35 void DispatchStatistics::printDispatchHistogram(raw_ostream &OS) const {
37 raw_string_ostream TempStream(Buffer);
38 TempStream << "\n\nDispatch Logic - "
39 << "number of cycles where we saw N micro opcodes dispatched:\n";
40 TempStream << "[# dispatched], [# cycles]\n";
41 for (const std::pair<unsigned, unsigned> &Entry : DispatchGroupSizePerCycle) {
42 double Percentage = ((double)Entry.second / NumCycles) * 100.0;
43 TempStream << " " << Entry.first << ", " << Entry.second
44 << " (" << format("%.1f", floor((Percentage * 10) + 0.5) / 10)
52 static void printStalls(raw_ostream &OS, unsigned NumStalls,
59 double Percentage = ((double)NumStalls / NumCycles) * 100.0;
60 OS << NumStalls << " ("
61 << format("%.1f", floor((Percentage * 10) + 0.5) / 10) << "%)";
64 void DispatchStatistics::printDispatchStalls(raw_ostream &OS) const {
66 raw_string_ostream SS(Buffer);
67 SS << "\n\nDynamic Dispatch Stall Cycles:\n";
68 SS << "RAT - Register unavailable: ";
69 printStalls(SS, HWStalls[HWStallEvent::RegisterFileStall], NumCycles);
70 SS << "\nRCU - Retire tokens unavailable: ";
71 printStalls(SS, HWStalls[HWStallEvent::RetireControlUnitStall], NumCycles);
72 SS << "\nSCHEDQ - Scheduler full: ";
73 printStalls(SS, HWStalls[HWStallEvent::SchedulerQueueFull], NumCycles);
74 SS << "\nLQ - Load queue full: ";
75 printStalls(SS, HWStalls[HWStallEvent::LoadQueueFull], NumCycles);
76 SS << "\nSQ - Store queue full: ";
77 printStalls(SS, HWStalls[HWStallEvent::StoreQueueFull], NumCycles);
78 SS << "\nGROUP - Static restrictions on the dispatch group: ";
79 printStalls(SS, HWStalls[HWStallEvent::DispatchGroupStall], NumCycles);