1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 10:32:48 +02:00

[llvm-mca] [NFC] Formatting code

Applied clang-format to all files. Discarded BottleneckAnalysis.h
80-column width violation since it contains an example of report.
Caught some typos and minor style details.

Reviewed By: andreadb

Differential Revision: https://reviews.llvm.org/D105900
This commit is contained in:
Marcos Horro 2021-07-13 19:07:03 +02:00
parent d721cdd01e
commit 820e57ea62
13 changed files with 48 additions and 50 deletions

View File

@ -59,7 +59,7 @@ json::Object PipelinePrinter::getJSONTargetInfo() const {
for (unsigned J = 0; J < NumUnits; ++J) {
std::string ResourceName = ProcResource.Name;
if (NumUnits > 1) {
ResourceName += ".";
ResourceName += ".";
ResourceName += J;
}

View File

@ -198,8 +198,8 @@ void DependencyGraph::initializeRootSet(
}
}
void DependencyGraph::propagateThroughEdges(
SmallVectorImpl<unsigned> &RootSet, unsigned Iterations) {
void DependencyGraph::propagateThroughEdges(SmallVectorImpl<unsigned> &RootSet,
unsigned Iterations) {
SmallVector<unsigned, 8> ToVisit;
// A critical sequence is computed as the longest path from a node of the
@ -221,14 +221,14 @@ void DependencyGraph::propagateThroughEdges(
// The `unvisited nodes` set initially contains all the nodes from the
// RootSet. A node N is added to the `unvisited nodes` if all its
// predecessors have been visited already.
//
//
// For simplicity, every node tracks the number of unvisited incoming edges in
// field `NumVisitedPredecessors`. When the value of that field drops to
// zero, then the corresponding node is added to a `ToVisit` set.
//
// At the end of every iteration of the outer loop, set `ToVisit` becomes our
// new `unvisited nodes` set.
//
//
// The algorithm terminates when the set of unvisited nodes (i.e. our RootSet)
// is empty. This algorithm works under the assumption that the graph is
// acyclic.
@ -267,8 +267,9 @@ void DependencyGraph::getCriticalSequence(
// that node is the last instruction of our critical sequence.
// Field N.Depth would tell us the total length of the sequence.
//
// To obtain the sequence of critical edges, we simply follow the chain of critical
// predecessors starting from node N (field DGNode::CriticalPredecessor).
// To obtain the sequence of critical edges, we simply follow the chain of
// critical predecessors starting from node N (field
// DGNode::CriticalPredecessor).
const auto It = std::max_element(
Nodes.begin(), Nodes.end(),
[](const DGNode &Lhs, const DGNode &Rhs) { return Lhs.Cost < Rhs.Cost; });

View File

@ -33,9 +33,9 @@
/// In particular, this occurs when there is a delta between the number of uOps
/// dispatched and the number of uOps issued to the underlying pipelines.
///
/// The bottleneck analysis view is also responsible for identifying and printing
/// the most "critical" sequence of dependent instructions according to the
/// simulated run.
/// The bottleneck analysis view is also responsible for identifying and
/// printing the most "critical" sequence of dependent instructions according to
/// the simulated run.
///
/// Below is the critical sequence computed for the dot-product example on
/// btver2:
@ -62,13 +62,14 @@
/// and edges of the graph represent data dependencies or processor resource
/// interferences.
///
/// Edges are dynamically 'discovered' by observing instruction state transitions
/// and backend pressure increase events. Edges are internally ranked based on
/// their "criticality". A dependency is considered to be critical if it takes a
/// long time to execute, and if it contributes to backend pressure increases.
/// Criticality is internally measured in terms of cycles; it is computed for
/// every edge in the graph as a function of the edge latency and the number of
/// backend pressure increase cycles contributed by that edge.
/// Edges are dynamically 'discovered' by observing instruction state
/// transitions and backend pressure increase events. Edges are internally
/// ranked based on their "criticality". A dependency is considered to be
/// critical if it takes a long time to execute, and if it contributes to
/// backend pressure increases. Criticality is internally measured in terms of
/// cycles; it is computed for every edge in the graph as a function of the edge
/// latency and the number of backend pressure increase cycles contributed by
/// that edge.
///
/// At the end of simulation, costs are propagated to nodes through the edges of
/// the graph, and the most expensive path connecting the root-set (a
@ -217,8 +218,8 @@ struct DependencyEdge {
// Loop carried dependencies are carefully expanded by the bottleneck analysis
// to guarantee that the graph stays acyclic. To this end, extra nodes are
// pre-allocated at construction time to describe instructions from "past and
// future" iterations. The graph is kept acyclic mainly because it simplifies the
// complexity of the algorithm that computes the critical sequence.
// future" iterations. The graph is kept acyclic mainly because it simplifies
// the complexity of the algorithm that computes the critical sequence.
class DependencyGraph {
struct DGNode {
unsigned NumPredecessors;
@ -239,7 +240,8 @@ class DependencyGraph {
void pruneEdges(unsigned Iterations);
void initializeRootSet(SmallVectorImpl<unsigned> &RootSet) const;
void propagateThroughEdges(SmallVectorImpl<unsigned> &RootSet, unsigned Iterations);
void propagateThroughEdges(SmallVectorImpl<unsigned> &RootSet,
unsigned Iterations);
#ifndef NDEBUG
void dumpDependencyEdge(raw_ostream &OS, const DependencyEdge &DE,

View File

@ -1,5 +1,4 @@
//===--------------------- DispatchStatistics.cpp ---------------------*- C++
//-*-===//
//===--------------------- DispatchStatistics.cpp ---------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.

View File

@ -1,4 +1,4 @@
//===----------------------- View.cpp ---------------------------*- C++ -*-===//
//===----------------------- InstructionView.cpp ----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -21,7 +21,8 @@ namespace mca {
InstructionView::~InstructionView() = default;
StringRef InstructionView::printInstructionString(const llvm::MCInst &MCI) const {
StringRef
InstructionView::printInstructionString(const llvm::MCInst &MCI) const {
InstructionString = "";
MCIP.printInst(&MCI, 0, "", STI, InstrStream);
InstrStream.flush();

View File

@ -1,4 +1,4 @@
//===----------------------- InstrucionView.h -----------------------------*- C++ -*-===//
//===----------------------- InstructionView.h ------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -16,8 +16,8 @@
#define LLVM_TOOLS_LLVM_MCA_INSTRUCTIONVIEW_H
#include "Views/View.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/raw_ostream.h"
namespace llvm {
namespace mca {
@ -34,15 +34,12 @@ class InstructionView : public View {
public:
void printView(llvm::raw_ostream &) const override {}
InstructionView(const llvm::MCSubtargetInfo &STI,
llvm::MCInstPrinter &Printer,
llvm::ArrayRef<llvm::MCInst> S)
llvm::MCInstPrinter &Printer, llvm::ArrayRef<llvm::MCInst> S)
: STI(STI), MCIP(Printer), Source(S), InstrStream(InstructionString) {}
virtual ~InstructionView();
StringRef getNameAsString() const override {
return "Instructions";
}
StringRef getNameAsString() const override { return "Instructions"; }
// Return a reference to a string representing a given machine instruction.
// The result should be used or copied before the next call to

View File

@ -65,7 +65,7 @@ void RegisterFileStatistics::updateMoveElimInfo(const Instruction &Inst) {
for (size_t I = 0, E = Inst.getDefs().size(); I < E; ++I) {
const WriteState &WS = Inst.getDefs()[I];
const ReadState &RS = Inst.getUses()[E - (I+1)];
const ReadState &RS = Inst.getUses()[E - (I + 1)];
MoveEliminationInfo &Info =
MoveElimInfo[Inst.getDefs()[0].getRegisterFileID()];

View File

@ -71,7 +71,8 @@ void RetireControlUnitStatistics::printView(raw_ostream &OS) const {
}
unsigned AvgUsage = (double)SumOfUsedEntries / NumCycles;
double MaxUsagePercentage = ((double)MaxUsedEntries / TotalROBEntries) * 100.0;
double MaxUsagePercentage =
((double)MaxUsedEntries / TotalROBEntries) * 100.0;
double NormalizedMaxPercentage = floor((MaxUsagePercentage * 10) + 0.5) / 10;
double AvgUsagePercentage = ((double)AvgUsage / TotalROBEntries) * 100.0;
double NormalizedAvgPercentage = floor((AvgUsagePercentage * 10) + 0.5) / 10;

View File

@ -1,4 +1,4 @@
//===--------------------- SummaryView.cpp -------------------*- C++ -*-===//
//===--------------------- SummaryView.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -24,9 +24,8 @@ namespace mca {
SummaryView::SummaryView(const MCSchedModel &Model, ArrayRef<MCInst> S,
unsigned Width)
: SM(Model), Source(S), DispatchWidth(Width?Width: Model.IssueWidth),
LastInstructionIdx(0),
TotalCycles(0), NumMicroOps(0),
: SM(Model), Source(S), DispatchWidth(Width ? Width : Model.IssueWidth),
LastInstructionIdx(0), TotalCycles(0), NumMicroOps(0),
ProcResourceUsage(Model.getNumProcResourceKinds(), 0),
ProcResourceMasks(Model.getNumProcResourceKinds()),
ResIdx2ProcResID(Model.getNumProcResourceKinds(), 0) {

View File

@ -1,4 +1,4 @@
//===--------------------- SummaryView.h ---------------------*- C++ -*-===//
//===--------------------- SummaryView.h ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.

View File

@ -125,7 +125,7 @@ class TimelineView : public InstructionView {
unsigned LastCycle;
struct TimelineViewEntry {
int CycleDispatched; // A negative value is an "invalid cycle".
int CycleDispatched; // A negative value is an "invalid cycle".
unsigned CycleReady;
unsigned CycleIssued;
unsigned CycleExecuted;

View File

@ -17,8 +17,8 @@
#include "llvm/MC/MCInstPrinter.h"
#include "llvm/MCA/HWEventListener.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/raw_ostream.h"
namespace llvm {
namespace mca {

View File

@ -95,15 +95,13 @@ static cl::opt<std::string>
cl::desc("Target a specific cpu type (-mcpu=help for details)"),
cl::value_desc("cpu-name"), cl::cat(ToolOptions), cl::init("native"));
static cl::opt<std::string>
MATTR("mattr",
cl::desc("Additional target features."),
cl::cat(ToolOptions));
static cl::opt<std::string> MATTR("mattr",
cl::desc("Additional target features."),
cl::cat(ToolOptions));
static cl::opt<bool>
PrintJson("json",
cl::desc("Print the output in json format"),
cl::cat(ToolOptions), cl::init(false));
static cl::opt<bool> PrintJson("json",
cl::desc("Print the output in json format"),
cl::cat(ToolOptions), cl::init(false));
static cl::opt<int>
OutputAsmVariant("output-asm-variant",
@ -573,8 +571,8 @@ int main(int argc, char **argv) {
mca::PipelinePrinter Printer(*P, *Region, RegionIdx, *STI);
if (PrintJson) {
auto IV = std::make_unique<mca::InstructionView>(*STI, *IP, Insts);
Printer.addView(std::move(IV));
Printer.addView(
std::make_unique<mca::InstructionView>(*STI, *IP, Insts));
}
// Create the views for this pipeline, execute, and emit a report.