From f41ad5c59efd7a11d78b9742228dcf858bd33d84 Mon Sep 17 00:00:00 2001 From: Andrea Di Biagio Date: Wed, 11 Apr 2018 12:12:53 +0000 Subject: [llvm-mca] Renamed BackendStatistics to RetireControlUnitStatistics. Also, removed flag -verbose in favor of flag -retire-stats. llvm-svn: 329794 --- llvm/tools/llvm-mca/BackendStatistics.cpp | 50 ---------------- llvm/tools/llvm-mca/BackendStatistics.h | 67 ---------------------- llvm/tools/llvm-mca/CMakeLists.txt | 2 +- .../tools/llvm-mca/RetireControlUnitStatistics.cpp | 51 ++++++++++++++++ llvm/tools/llvm-mca/RetireControlUnitStatistics.h | 61 ++++++++++++++++++++ llvm/tools/llvm-mca/llvm-mca.cpp | 15 +++-- 6 files changed, 123 insertions(+), 123 deletions(-) delete mode 100644 llvm/tools/llvm-mca/BackendStatistics.cpp delete mode 100644 llvm/tools/llvm-mca/BackendStatistics.h create mode 100644 llvm/tools/llvm-mca/RetireControlUnitStatistics.cpp create mode 100644 llvm/tools/llvm-mca/RetireControlUnitStatistics.h (limited to 'llvm/tools/llvm-mca') diff --git a/llvm/tools/llvm-mca/BackendStatistics.cpp b/llvm/tools/llvm-mca/BackendStatistics.cpp deleted file mode 100644 index 4e378b16beb..00000000000 --- a/llvm/tools/llvm-mca/BackendStatistics.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//===--------------------- BackendStatistics.cpp ---------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -/// \file -/// -/// Functionalities used by the BackendPrinter to print out histograms -/// related to number of {issue/retire} per number of cycles. -/// -//===----------------------------------------------------------------------===// - -#include "BackendStatistics.h" -#include "llvm/Support/Format.h" - -using namespace llvm; - -namespace mca { - -void BackendStatistics::onInstructionEvent(const HWInstructionEvent &Event) { - if (Event.Type == HWInstructionEvent::Retired) - ++NumRetired; -} - -void BackendStatistics::printView(llvm::raw_ostream &OS) const { - std::string Buffer; - raw_string_ostream TempStream(Buffer); - TempStream << "\n\nRetire Control Unit - " - << "number of cycles where we saw N instructions retired:\n"; - TempStream << "[# retired], [# cycles]\n"; - - for (const std::pair &Entry : RetiredPerCycle) { - TempStream << " " << Entry.first; - if (Entry.first < 10) - TempStream << ", "; - else - TempStream << ", "; - TempStream << Entry.second << " (" - << format("%.1f", ((double)Entry.second / NumCycles) * 100.0) - << "%)\n"; - } - - TempStream.flush(); - OS << Buffer; -} - -} // namespace mca diff --git a/llvm/tools/llvm-mca/BackendStatistics.h b/llvm/tools/llvm-mca/BackendStatistics.h deleted file mode 100644 index 24b8e5c565b..00000000000 --- a/llvm/tools/llvm-mca/BackendStatistics.h +++ /dev/null @@ -1,67 +0,0 @@ -//===--------------------- BackendStatistics.h ------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -/// \file -/// -/// This file implements a View named BackendStatistics that knows how to -/// collect and print a few statistics related to the retire unit. -/// -/// Example: -/// ======== -/// -/// Retire Control Unit - number of cycles where we saw N instructions retired: -/// [# retired], [# cycles] -/// 0, 9 (6.9%) -/// 1, 6 (4.6%) -/// 2, 1 (0.8%) -/// 4, 3 (2.3%) -/// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TOOLS_LLVM_MCA_BACKENDSTATISTICS_H -#define LLVM_TOOLS_LLVM_MCA_BACKENDSTATISTICS_H - -#include "View.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/MC/MCSubtargetInfo.h" - -namespace mca { - -class BackendStatistics : public View { - const llvm::MCSubtargetInfo &STI; - - using Histogram = llvm::DenseMap; - Histogram RetiredPerCycle; - - unsigned NumRetired; - unsigned NumCycles; - - void updateHistograms() { - RetiredPerCycle[NumRetired]++; - NumRetired = 0; - } - - void printRCUStatistics(llvm::raw_ostream &OS, const Histogram &Histogram, - unsigned Cycles) const; - -public: - BackendStatistics(const llvm::MCSubtargetInfo &sti) - : STI(sti), NumRetired(0), NumCycles(0) {} - - void onInstructionEvent(const HWInstructionEvent &Event) override; - - void onCycleBegin(unsigned Cycle) override { NumCycles++; } - - void onCycleEnd(unsigned Cycle) override { updateHistograms(); } - - void printView(llvm::raw_ostream &OS) const override; -}; -} // namespace mca - -#endif diff --git a/llvm/tools/llvm-mca/CMakeLists.txt b/llvm/tools/llvm-mca/CMakeLists.txt index e0a97a5d4d8..20a9966cedf 100644 --- a/llvm/tools/llvm-mca/CMakeLists.txt +++ b/llvm/tools/llvm-mca/CMakeLists.txt @@ -12,7 +12,6 @@ set(LLVM_LINK_COMPONENTS add_llvm_tool(llvm-mca Backend.cpp BackendPrinter.cpp - BackendStatistics.cpp CodeRegion.cpp Dispatch.cpp DispatchStatistics.cpp @@ -25,6 +24,7 @@ add_llvm_tool(llvm-mca llvm-mca.cpp RegisterFileStatistics.cpp ResourcePressureView.cpp + RetireControlUnitStatistics.cpp Scheduler.cpp SchedulerStatistics.cpp Support.cpp diff --git a/llvm/tools/llvm-mca/RetireControlUnitStatistics.cpp b/llvm/tools/llvm-mca/RetireControlUnitStatistics.cpp new file mode 100644 index 00000000000..5b1a1ded170 --- /dev/null +++ b/llvm/tools/llvm-mca/RetireControlUnitStatistics.cpp @@ -0,0 +1,51 @@ +//===--------------------- RetireControlUnitStatistics.cpp ---------------*- C++ +//-*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// \file +/// +/// This file implements the RetireControlUnitStatistics interface. +/// +//===----------------------------------------------------------------------===// + +#include "RetireControlUnitStatistics.h" +#include "llvm/Support/Format.h" + +using namespace llvm; + +namespace mca { + +void RetireControlUnitStatistics::onInstructionEvent( + const HWInstructionEvent &Event) { + if (Event.Type == HWInstructionEvent::Retired) + ++NumRetired; +} + +void RetireControlUnitStatistics::printView(llvm::raw_ostream &OS) const { + std::string Buffer; + raw_string_ostream TempStream(Buffer); + TempStream << "\n\nRetire Control Unit - " + << "number of cycles where we saw N instructions retired:\n"; + TempStream << "[# retired], [# cycles]\n"; + + for (const std::pair &Entry : RetiredPerCycle) { + TempStream << " " << Entry.first; + if (Entry.first < 10) + TempStream << ", "; + else + TempStream << ", "; + TempStream << Entry.second << " (" + << format("%.1f", ((double)Entry.second / NumCycles) * 100.0) + << "%)\n"; + } + + TempStream.flush(); + OS << Buffer; +} + +} // namespace mca diff --git a/llvm/tools/llvm-mca/RetireControlUnitStatistics.h b/llvm/tools/llvm-mca/RetireControlUnitStatistics.h new file mode 100644 index 00000000000..f3952abe11d --- /dev/null +++ b/llvm/tools/llvm-mca/RetireControlUnitStatistics.h @@ -0,0 +1,61 @@ +//===--------------------- RetireControlUnitStatistics.h ------------------*- +//C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// \file +/// +/// This file defines class RetireControlUnitStatistics: a view that knows how +/// to print general statistics related to the retire control unit. +/// +/// Example: +/// ======== +/// +/// Retire Control Unit - number of cycles where we saw N instructions retired: +/// [# retired], [# cycles] +/// 0, 9 (6.9%) +/// 1, 6 (4.6%) +/// 2, 1 (0.8%) +/// 4, 3 (2.3%) +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H +#define LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H + +#include "View.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/MC/MCSubtargetInfo.h" + +namespace mca { + +class RetireControlUnitStatistics : public View { + using Histogram = llvm::DenseMap; + Histogram RetiredPerCycle; + + unsigned NumRetired; + unsigned NumCycles; + + void updateHistograms() { + RetiredPerCycle[NumRetired]++; + NumRetired = 0; + } + +public: + RetireControlUnitStatistics() : NumRetired(0), NumCycles(0) {} + + void onInstructionEvent(const HWInstructionEvent &Event) override; + + void onCycleBegin(unsigned Cycle) override { NumCycles++; } + + void onCycleEnd(unsigned Cycle) override { updateHistograms(); } + + void printView(llvm::raw_ostream &OS) const override; +}; +} // namespace mca + +#endif diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp index 7b50196f418..3cb62928349 100644 --- a/llvm/tools/llvm-mca/llvm-mca.cpp +++ b/llvm/tools/llvm-mca/llvm-mca.cpp @@ -22,13 +22,13 @@ //===----------------------------------------------------------------------===// #include "BackendPrinter.h" -#include "BackendStatistics.h" #include "CodeRegion.h" #include "DispatchStatistics.h" #include "InstructionInfoView.h" #include "InstructionTables.h" #include "RegisterFileStatistics.h" #include "ResourcePressureView.h" +#include "RetireControlUnitStatistics.h" #include "SchedulerStatistics.h" #include "SummaryView.h" #include "TimelineView.h" @@ -101,10 +101,15 @@ static cl::opt cl::init(false)); static cl::opt - PrintiSchedulerStats("scheduler-stats", + PrintSchedulerStats("scheduler-stats", cl::desc("Print scheduler statistics"), cl::init(false)); +static cl::opt + PrintRetireStats("retire-stats", + cl::desc("Print retire control unit statistics"), + cl::init(false)); + static cl::opt PrintResourcePressureView("resource-pressure", cl::desc("Print the resource pressure view"), @@ -438,11 +443,11 @@ int main(int argc, char **argv) { if (PrintDispatchStats) Printer.addView(llvm::make_unique(*STI)); - if (PrintiSchedulerStats) + if (PrintSchedulerStats) Printer.addView(llvm::make_unique(*STI)); - if (PrintModeVerbose) - Printer.addView(llvm::make_unique(*STI)); + if (PrintRetireStats) + Printer.addView(llvm::make_unique()); if (PrintRegisterFileStats) Printer.addView(llvm::make_unique(*STI)); -- cgit v1.2.3