From: Andrea Di Biagio Date: Wed, 11 Apr 2018 12:12:53 +0000 (+0000) Subject: [llvm-mca] Renamed BackendStatistics to RetireControlUnitStatistics. X-Git-Tag: android-x86-7.1-r4~2479 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=900cf755f0a5465b55387fa34616237c89d4c331;p=android-x86%2Fexternal-llvm.git [llvm-mca] Renamed BackendStatistics to RetireControlUnitStatistics. Also, removed flag -verbose in favor of flag -retire-stats. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329794 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/CommandGuide/llvm-mca.rst b/docs/CommandGuide/llvm-mca.rst index 3d69e6d40a2..1aafd3b3806 100644 --- a/docs/CommandGuide/llvm-mca.rst +++ b/docs/CommandGuide/llvm-mca.rst @@ -52,7 +52,7 @@ assembly text: __asm volatile("# LLVM-MCA-BEGIN foo"); a += 42; __asm volatile("# LLVM-MCA-END"); - a *= b; + a \*= b; return a; } @@ -136,11 +136,6 @@ option specifies "``-``", then the output will also be sent to standard output. queue. A value of zero for this flag is ignored, and the default store queue size is used instead. -.. option:: -verbose - - Enable verbose output. In particular, this flag enables a number of extra - statistics and performance counters for the retire control unit. - .. option:: -timeline Enable the timeline view. @@ -174,6 +169,10 @@ option specifies "``-``", then the output will also be sent to standard output. Enable extra scheduler statistics. This view collects and analyzes instruction issue events. This view is disabled by default. +.. option:: -retire-stats + + Enable extra retire control unit statistics. This view is disabled by default. + .. option:: -instruction-info Enable the instruction info view. This is enabled by default. diff --git a/test/tools/llvm-mca/X86/BtVer2/rcu-statistics.s b/test/tools/llvm-mca/X86/BtVer2/rcu-statistics.s new file mode 100644 index 00000000000..74c7d7e4244 --- /dev/null +++ b/test/tools/llvm-mca/X86/BtVer2/rcu-statistics.s @@ -0,0 +1,56 @@ +# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -resource-pressure=false -retire-stats -iterations=1 < %s | FileCheck %s + + vsqrtps %xmm0, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + vaddps %xmm0, %xmm1, %xmm2 + +# CHECK: Iterations: 1 +# CHECK-NEXT: Instructions: 16 +# CHECK-NEXT: Total Cycles: 31 +# CHECK-NEXT: Dispatch Width: 2 +# CHECK-NEXT: IPC: 0.52 + +# CHECK: Instruction Info: +# CHECK-NEXT: [1]: #uOps +# CHECK-NEXT: [2]: Latency +# CHECK-NEXT: [3]: RThroughput +# CHECK-NEXT: [4]: MayLoad +# CHECK-NEXT: [5]: MayStore +# CHECK-NEXT: [6]: HasSideEffects + +# CHECK: [1] [2] [3] [4] [5] [6] Instructions: +# CHECK-NEXT: 1 21 21.00 vsqrtps %xmm0, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 +# CHECK-NEXT: 1 3 1.00 vaddps %xmm0, %xmm1, %xmm2 + +# CHECK: Retire Control Unit - number of cycles where we saw N instructions retired: +# CHECK-NEXT: [# retired], [# cycles] +# CHECK-NEXT: 0, 23 (74.2%) +# CHECK-NEXT: 2, 8 (25.8%) + diff --git a/tools/llvm-mca/CMakeLists.txt b/tools/llvm-mca/CMakeLists.txt index e0a97a5d4d8..20a9966cedf 100644 --- a/tools/llvm-mca/CMakeLists.txt +++ b/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/tools/llvm-mca/BackendStatistics.cpp b/tools/llvm-mca/RetireControlUnitStatistics.cpp similarity index 74% rename from tools/llvm-mca/BackendStatistics.cpp rename to tools/llvm-mca/RetireControlUnitStatistics.cpp index 4e378b16beb..5b1a1ded170 100644 --- a/tools/llvm-mca/BackendStatistics.cpp +++ b/tools/llvm-mca/RetireControlUnitStatistics.cpp @@ -1,4 +1,5 @@ -//===--------------------- BackendStatistics.cpp ---------------*- C++ -*-===// +//===--------------------- RetireControlUnitStatistics.cpp ---------------*- C++ +//-*-===// // // The LLVM Compiler Infrastructure // @@ -8,24 +9,24 @@ //===----------------------------------------------------------------------===// /// \file /// -/// Functionalities used by the BackendPrinter to print out histograms -/// related to number of {issue/retire} per number of cycles. +/// This file implements the RetireControlUnitStatistics interface. /// //===----------------------------------------------------------------------===// -#include "BackendStatistics.h" +#include "RetireControlUnitStatistics.h" #include "llvm/Support/Format.h" using namespace llvm; namespace mca { -void BackendStatistics::onInstructionEvent(const HWInstructionEvent &Event) { +void RetireControlUnitStatistics::onInstructionEvent( + const HWInstructionEvent &Event) { if (Event.Type == HWInstructionEvent::Retired) ++NumRetired; } -void BackendStatistics::printView(llvm::raw_ostream &OS) const { +void RetireControlUnitStatistics::printView(llvm::raw_ostream &OS) const { std::string Buffer; raw_string_ostream TempStream(Buffer); TempStream << "\n\nRetire Control Unit - " diff --git a/tools/llvm-mca/BackendStatistics.h b/tools/llvm-mca/RetireControlUnitStatistics.h similarity index 65% rename from tools/llvm-mca/BackendStatistics.h rename to tools/llvm-mca/RetireControlUnitStatistics.h index 24b8e5c565b..f3952abe11d 100644 --- a/tools/llvm-mca/BackendStatistics.h +++ b/tools/llvm-mca/RetireControlUnitStatistics.h @@ -1,4 +1,5 @@ -//===--------------------- BackendStatistics.h ------------------*- C++ -*-===// +//===--------------------- RetireControlUnitStatistics.h ------------------*- +//C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -8,8 +9,8 @@ //===----------------------------------------------------------------------===// /// \file /// -/// This file implements a View named BackendStatistics that knows how to -/// collect and print a few statistics related to the retire unit. +/// This file defines class RetireControlUnitStatistics: a view that knows how +/// to print general statistics related to the retire control unit. /// /// Example: /// ======== @@ -23,19 +24,16 @@ /// //===----------------------------------------------------------------------===// -#ifndef LLVM_TOOLS_LLVM_MCA_BACKENDSTATISTICS_H -#define LLVM_TOOLS_LLVM_MCA_BACKENDSTATISTICS_H +#ifndef LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_H +#define LLVM_TOOLS_LLVM_MCA_RETIRECONTROLUNITSTATISTICS_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; - +class RetireControlUnitStatistics : public View { using Histogram = llvm::DenseMap; Histogram RetiredPerCycle; @@ -47,12 +45,8 @@ class BackendStatistics : public View { 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) {} + RetireControlUnitStatistics() : NumRetired(0), NumCycles(0) {} void onInstructionEvent(const HWInstructionEvent &Event) override; diff --git a/tools/llvm-mca/llvm-mca.cpp b/tools/llvm-mca/llvm-mca.cpp index 7b50196f418..3cb62928349 100644 --- a/tools/llvm-mca/llvm-mca.cpp +++ b/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,11 +101,16 @@ 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"), cl::init(true)); @@ -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));