diff options
author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-04-11 11:37:46 +0000 |
---|---|---|
committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-04-11 11:37:46 +0000 |
commit | 1cc29c045e07dd2f9adda3a5569df6e249613135 (patch) | |
tree | 81d5f1ee54ad066629152e6f8fb42d9d6c4481e7 /llvm/tools/llvm-mca/BackendStatistics.cpp | |
parent | d928201ac5ef2d61492720bd0f7323f225ffdb3e (diff) | |
download | bcm5719-llvm-1cc29c045e07dd2f9adda3a5569df6e249613135.tar.gz bcm5719-llvm-1cc29c045e07dd2f9adda3a5569df6e249613135.zip |
[llvm-mca] Move the logic that prints scheduler statistics from BackendStatistics to its own view.
Added flag -scheduler-stats to print scheduler related statistics.
llvm-svn: 329792
Diffstat (limited to 'llvm/tools/llvm-mca/BackendStatistics.cpp')
-rw-r--r-- | llvm/tools/llvm-mca/BackendStatistics.cpp | 77 |
1 files changed, 2 insertions, 75 deletions
diff --git a/llvm/tools/llvm-mca/BackendStatistics.cpp b/llvm/tools/llvm-mca/BackendStatistics.cpp index c189a3afa0e..4e378b16beb 100644 --- a/llvm/tools/llvm-mca/BackendStatistics.cpp +++ b/llvm/tools/llvm-mca/BackendStatistics.cpp @@ -21,42 +21,11 @@ using namespace llvm; namespace mca { void BackendStatistics::onInstructionEvent(const HWInstructionEvent &Event) { - switch (Event.Type) { - default: - break; - case HWInstructionEvent::Retired: { + if (Event.Type == HWInstructionEvent::Retired) ++NumRetired; - break; - } - case HWInstructionEvent::Issued: - ++NumIssued; - } -} - -void BackendStatistics::onReservedBuffers(ArrayRef<unsigned> Buffers) { - for (const unsigned Buffer : Buffers) { - if (BufferedResources.find(Buffer) != BufferedResources.end()) { - BufferUsage &BU = BufferedResources[Buffer]; - BU.SlotsInUse++; - BU.MaxUsedSlots = std::max(BU.MaxUsedSlots, BU.SlotsInUse); - continue; - } - - BufferedResources.insert( - std::pair<unsigned, BufferUsage>(Buffer, {1U, 1U})); - } -} - -void BackendStatistics::onReleasedBuffers(ArrayRef<unsigned> Buffers) { - for (const unsigned Buffer : Buffers) { - assert(BufferedResources.find(Buffer) != BufferedResources.end() && - "Buffered resource not in map?"); - BufferUsage &BU = BufferedResources[Buffer]; - BU.SlotsInUse--; - } } -void BackendStatistics::printRetireUnitStatistics(llvm::raw_ostream &OS) const { +void BackendStatistics::printView(llvm::raw_ostream &OS) const { std::string Buffer; raw_string_ostream TempStream(Buffer); TempStream << "\n\nRetire Control Unit - " @@ -78,46 +47,4 @@ void BackendStatistics::printRetireUnitStatistics(llvm::raw_ostream &OS) const { OS << Buffer; } -void BackendStatistics::printSchedulerStatistics(llvm::raw_ostream &OS) const { - std::string Buffer; - raw_string_ostream TempStream(Buffer); - TempStream << "\n\nSchedulers - number of cycles where we saw N instructions " - "issued:\n"; - TempStream << "[# issued], [# cycles]\n"; - for (const std::pair<unsigned, unsigned> &Entry : IssuedPerCycle) { - TempStream << " " << Entry.first << ", " << Entry.second << " (" - << format("%.1f", ((double)Entry.second / NumCycles) * 100) - << "%)\n"; - } - - TempStream.flush(); - OS << Buffer; -} - -void BackendStatistics::printSchedulerUsage(raw_ostream &OS, - const MCSchedModel &SM) const { - std::string Buffer; - raw_string_ostream TempStream(Buffer); - TempStream << "\n\nScheduler's queue usage:\n"; - // Early exit if no buffered resources were consumed. - if (BufferedResources.empty()) { - TempStream << "No scheduler resources used.\n"; - TempStream.flush(); - OS << Buffer; - return; - } - - for (unsigned I = 0, E = SM.getNumProcResourceKinds(); I < E; ++I) { - const MCProcResourceDesc &ProcResource = *SM.getProcResource(I); - if (ProcResource.BufferSize <= 0) - continue; - - const BufferUsage &BU = BufferedResources.lookup(I); - TempStream << ProcResource.Name << ", " << BU.MaxUsedSlots << '/' - << ProcResource.BufferSize << '\n'; - } - - TempStream.flush(); - OS << Buffer; -} } // namespace mca |