blob: f1281c3a5a486e805660b010005529cbeadf81a6 [file] [log] [blame]
Andrea Di Biagio821f6502018-04-10 14:55:14 +00001//===--------------------- DispatchStatistics.cpp ---------------------*- C++
2//-*-===//
3//
4// The LLVM Compiler Infrastructure
5//
6// This file is distributed under the University of Illinois Open Source
7// License. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10/// \file
11///
12/// This file implements the DispatchStatistics interface.
13///
14//===----------------------------------------------------------------------===//
15
16#include "DispatchStatistics.h"
17#include "llvm/Support/Format.h"
18
19using namespace llvm;
20
21namespace mca {
22
23void DispatchStatistics::onInstructionEvent(const HWInstructionEvent &Event) {
24 if (Event.Type == HWInstructionEvent::Dispatched)
25 ++NumDispatched;
26}
27
28void DispatchStatistics::printDispatchHistogram(llvm::raw_ostream &OS) const {
29 std::string Buffer;
30 raw_string_ostream TempStream(Buffer);
31 TempStream << "\n\nDispatch Logic - "
32 << "number of cycles where we saw N instructions dispatched:\n";
33 TempStream << "[# dispatched], [# cycles]\n";
34 for (const std::pair<unsigned, unsigned> &Entry : DispatchGroupSizePerCycle) {
35 TempStream << " " << Entry.first << ", " << Entry.second
36 << " ("
37 << format("%.1f", ((double)Entry.second / NumCycles) * 100.0)
38 << "%)\n";
39 }
40
41 TempStream.flush();
42 OS << Buffer;
43}
44
45void DispatchStatistics::printDispatchStalls(raw_ostream &OS) const {
46 std::string Buffer;
47 raw_string_ostream TempStream(Buffer);
48 TempStream << "\n\nDynamic Dispatch Stall Cycles:\n";
49 TempStream << "RAT - Register unavailable: "
50 << HWStalls[HWStallEvent::RegisterFileStall];
51 TempStream << "\nRCU - Retire tokens unavailable: "
52 << HWStalls[HWStallEvent::RetireControlUnitStall];
53 TempStream << "\nSCHEDQ - Scheduler full: "
54 << HWStalls[HWStallEvent::SchedulerQueueFull];
55 TempStream << "\nLQ - Load queue full: "
56 << HWStalls[HWStallEvent::LoadQueueFull];
57 TempStream << "\nSQ - Store queue full: "
58 << HWStalls[HWStallEvent::StoreQueueFull];
59 TempStream << "\nGROUP - Static restrictions on the dispatch group: "
60 << HWStalls[HWStallEvent::DispatchGroupStall];
61 TempStream << '\n';
62 TempStream.flush();
63 OS << Buffer;
64}
65
66} // namespace mca