[llvm-mca] Renamed BackendStatistics to RetireControlUnitStatistics.

Also, removed flag -verbose in favor of flag -retire-stats.

llvm-svn: 329794
This commit is contained in:
Andrea Di Biagio 2018-04-11 12:12:53 +00:00
parent b46fe1126f
commit d9344b8000
6 changed files with 87 additions and 32 deletions

View File

@ -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.

View File

@ -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%)

View File

@ -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

View File

@ -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 - "

View File

@ -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<unsigned, unsigned>;
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;

View File

@ -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<bool>
cl::init(false));
static cl::opt<bool>
PrintiSchedulerStats("scheduler-stats",
PrintSchedulerStats("scheduler-stats",
cl::desc("Print scheduler statistics"),
cl::init(false));
static cl::opt<bool>
PrintRetireStats("retire-stats",
cl::desc("Print retire control unit statistics"),
cl::init(false));
static cl::opt<bool>
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<mca::DispatchStatistics>(*STI));
if (PrintiSchedulerStats)
if (PrintSchedulerStats)
Printer.addView(llvm::make_unique<mca::SchedulerStatistics>(*STI));
if (PrintModeVerbose)
Printer.addView(llvm::make_unique<mca::BackendStatistics>(*STI));
if (PrintRetireStats)
Printer.addView(llvm::make_unique<mca::RetireControlUnitStatistics>());
if (PrintRegisterFileStats)
Printer.addView(llvm::make_unique<mca::RegisterFileStatistics>(*STI));