1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
Commit Graph

332 Commits

Author SHA1 Message Date
Andrea Di Biagio
8050b0610b [llvm-mca] Move the logic that computes the register file usage to the BackendStatistics view.
With this patch, the "instruction dispatched" event now provides information
related to the number of microarchitectural registers used in each register
file. Similarly, the "instruction retired" event is now able to tell how may
registers are freed in each register file.

Currently, the BackendStatistics view is the only consumer of register
usage/pressure information. BackendStatistics uses that info to print out a few
general statistics (i.e. max number of mappings used; total mapping created).
Before this patch, the BackendStatistics was forced to query the Backend to
obtain the register pressure information.

This helps removes that dependency. Now views are completely independent from
the Backend.  As a consequence, it should be easier to address PR36663 and
further modularize the pipeline.

Added a couple of test cases in the BtVer2 specific directory.

llvm-svn: 328129
2018-03-21 18:11:05 +00:00
Andrea Di Biagio
f0b727c01d [llvm-mca] Clean up some code. NFC
Removed a couple of methods from DispatchUnit.

llvm-svn: 328094
2018-03-21 12:49:07 +00:00
Andrea Di Biagio
7c7bcf05c6 [llvm-mca] add keyword override to a couple of methods in BackendStatistics.
This should fix the buildbots after r328011.

llvm-svn: 328029
2018-03-20 20:18:36 +00:00
Andrea Di Biagio
e4e0a138c6 [llvm-mca] Remove const from a bunch of ArrayRef. NFC
llvm-svn: 328018
2018-03-20 19:06:34 +00:00
Andrea Di Biagio
06f01a6c2d [llvm-mca] Move the logic that computes the scheduler's queue usage to the BackendStatistics view.
This patch introduces two new callbacks in the event listener interface to
handle the "buffered resource reserved" event and the "buffered resource
released" event. Every time a buffered resource is used, an event is generated.

Before this patch, the Scheduler (with the help of the ResourceManager) was
responsible for tracking the scheduler's queue usage. However, that design
forced the Scheduler to 'publish' scheduler's queue pressure information through
the Backend interface.

The goal of this patch is to break the dependency between the BackendStatistics
view, and the Backend. Now the Scheduler knows how to notify "buffer
reserved/released" events.  The scheduler's queue usage analysis has been moved
to the BackendStatistics.

Differential Revision: https://reviews.llvm.org/D44686

llvm-svn: 328011
2018-03-20 18:20:39 +00:00
Andrea Di Biagio
3cce5c6f4b [llvm-mca] Use llvm::make_unique in a few places. NFC
Also, clang-format a couple of DEBUG functions.

llvm-svn: 327978
2018-03-20 12:58:34 +00:00
Andrea Di Biagio
cf05a35161 [llvm-mca] Move the routine that computes processor resource masks to its own file.
Function computeProcResourceMasks is used by the ResourceManager (owned by the
Scheduler) to compute resource masks for processor resources.  Before this
refactoring, there was an implicit dependency between the Scheduler and the
InstrBuilder. That is because InstrBuilder has to know about resource masks when
computing the set of processor resources consumed by a new instruction.

With this patch, the functionality that computes resource masks has been
extracted from the ResourceManager, and moved to a separate file (Support.h). 
This helps removing the dependency between the Scheduler and the InstrBuilder.

No functional change intended.

llvm-svn: 327973
2018-03-20 12:25:54 +00:00
Andrea Di Biagio
66c09621c6 [llvm-mca] Remove unused method from ResourceManager. NFC
llvm-svn: 327888
2018-03-19 19:14:06 +00:00
Andrea Di Biagio
06ba64d31f [llvm-mca] Simplify code. NFC
llvm-svn: 327886
2018-03-19 19:09:38 +00:00
Andrea Di Biagio
ed37aa59f3 [llvm-mca] Add pipeline stall events.
This patch introduces a new class named HWStallEvent (see HWEventListener.h),
and updates the event listener interface. A HWStallEvent represents a pipeline
stall caused by the lack of hardware resources. Similarly to HWInstructionEvent,
the event type is an unsigned, and the exact meaning depends on the subtarget.
At the moment, HWStallEvent supports a few generic dispatch events.

The main goals of this patch is to remove the logic that counts dispatch stalls
from the DispatchUnit to the BackendStatistics view.

Previously, DispatchUnit was responsible for counting and classifying dispatch
stall events. With this patch, we delegate the task of counting and classifying
stall events to the listeners (i.e. in our case, it is view
"BackendStatistics"). So, the DispatchUnit doesn't have to do extra
(unnecessary) bookkeeping.

This patch also helps futher simplifying the Backend interface. Now class
BackendStatistics no longer has to query the Backend interface to obtain the
number of dispatch stalls. As a consequence, we can get rid of all the
'getNumXXX()' methods from class Backend.
The long term goal is to remove all the remaining dependencies between the
Backend and the BackendStatistics interface.

Differential Revision: https://reviews.llvm.org/D44621

llvm-svn: 327837
2018-03-19 13:23:07 +00:00
Andrea Di Biagio
48886c59e8 [llvm-mca] Allow the definition of multiple register files.
This is a refactoring in preparation for other two changes that will allow
scheduling models to define multiple register files. This is the first step
towards fixing PR36662.

class RegisterFile (in Dispatch.h) now can emulate multiple register files.
Internally, it tracks the number of available physical registers in each
register file (described by class RegisterFileInfo).

Each register file is associated to a list of MCRegisterClass indices. Knowing
the register class indices allows to map physical registers to register files.

The long term goal is to allow processor models to optionally specify how many
register files are implemented via tablegen.

Differential Revision: https://reviews.llvm.org/D44488

llvm-svn: 327798
2018-03-18 15:33:27 +00:00
Andrea Di Biagio
20562bf853 [llvm-mca] Remove method getSchedModel() from the Backend.
llvm-svn: 327756
2018-03-16 22:21:52 +00:00
Andrea Di Biagio
d9e4d8c0eb [llvm-mca] Remove unused methods from Backend. NFC
llvm-svn: 327749
2018-03-16 22:02:47 +00:00
Andrea Di Biagio
905db8a3d6 [llvm-mca] Simplify code. NFC.
Now both method DispatchUnit::checkRAT() and DispatchUnit::canDispatch take as
input an Instruction refrence instead of an instruction descriptor.
This was requested by Simon in D44488 to simplify the diff.

llvm-svn: 327640
2018-03-15 16:13:12 +00:00
Andrea Di Biagio
77ab4ed0a3 [llvm-mca] Remove unused variable from InstrBuilder.cpp. NFC
This was causing a buildbot failure.

llvm-svn: 327517
2018-03-14 15:19:47 +00:00
Andrea Di Biagio
29d48bb255 [llvm-mca] Move the logic that updates the register files from InstrBuilder to DispatchUnit. NFCI
Before this patch, the register file was always updated at instruction creation
time. That means, new read-after-write dependencies, and new temporary registers
were allocated at instruction creation time.

This patch refactors the code in InstrBuilder, and move all the logic that
updates the register file into the dispatch unit. We only want to update the
register file when instructions are effectively dispatched (not before).

This refactoring also helps removing a bad dependency between the InstrBuilder
and the DispatchUnit.

No functional change intended.

llvm-svn: 327514
2018-03-14 14:57:23 +00:00
Andrea Di Biagio
5efc27c249 [llvm-mca] Remove the logic that computes the reciprocal throughput, and make the SummaryView independent from the Backend. NFCI
Since r327420, the tool can query the MCSchedModel interface to obtain the
reciprocal throughput information.
As a consequence, method `ResourceManager::getRThroughput`, and
method `Backend::getRThroughput` are no longer needed.

This patch simplifies the code by removing the custom RThroughput computation.
This patch also refactors class SummaryView by removing the dependency with
the Backend object.

No functional change intended.

llvm-svn: 327425
2018-03-13 17:24:32 +00:00
Andrea Di Biagio
a627e4f7be [llvm-mca] Simplify code that computes the latency of an instruction in
InstrBuilder. NFCI

This was possible because of r327406, which added function`computeInstrLatency`
to MCSchedModel.

llvm-svn: 327415
2018-03-13 15:59:59 +00:00
Andrea Di Biagio
6917de9a43 [llvm-mca] Use a const ArrayRef in a few places. NFC
llvm-svn: 327396
2018-03-13 13:58:02 +00:00
Clement Courbet
0c8c714bb4 [llvm-mca] Fix unused variable warning in opt mode.
llvm-svn: 327394
2018-03-13 13:44:18 +00:00
Clement Courbet
767a644ff6 [llvm-mca] Refactor event listeners to make the backend agnostic to event types.
Summary: This is a first step towards making the pipeline configurable.

Subscribers: llvm-commits, andreadb

Differential Revision: https://reviews.llvm.org/D44309

llvm-svn: 327389
2018-03-13 13:11:01 +00:00
Andrea Di Biagio
63ab384f89 [llvm-mca] Fix use-of-uninitialized-value error reported by the MemorySanitizer.
This should make the buildbots green again.

llvm-svn: 327223
2018-03-10 20:52:59 +00:00
Andrea Di Biagio
17857e9071 [llvm-mca] BackendStatistics: early exit from method printSchedulerUsage if the
no scheduler resources were consumed.

llvm-svn: 327215
2018-03-10 17:40:25 +00:00
Andrea Di Biagio
13307dcaad [llvm-mca] Views are now independent from resource masks. NFCI
This change removes method Backend::getProcResourceMasks() and simplifies some
logic in the Views. This effectively removes yet another dependency between the
views and the Backend.
No functional change intended.

llvm-svn: 327214
2018-03-10 16:55:07 +00:00
Andrea Di Biagio
0a931ef145 [llvm-mca] Move the logic that prints the summary into its own view. NFCI
llvm-svn: 327128
2018-03-09 13:52:03 +00:00
Andrea Di Biagio
9d4e3cac5b [llvm-mca] Run clang-format on the source code. NFC
llvm-svn: 327125
2018-03-09 12:50:42 +00:00
Andrea Di Biagio
9519f9efed [llvm-mca] Fix handling of zero-latency instructions.
This patch fixes a problem found when testing zero latency instructions on
target AArch64 -mcpu=exynos-m3 / -mcpu=exynos-m1.

On Exynos-m3/m1, direct branches are zero-latency instructions that don't consume
any processor resources.  The DispatchUnit marks zero-latency instructions as
"executed", so that no scheduling is required.  The event of instruction
executed is then notified to all the listeners, and the reorder buffer (managed
by the RetireControlUnit) is updated. In particular, the entry associated to the
zero-latency instruction in the reorder buffer is marked as executed.

Before this patch, the DispatchUnit forgot to assign a retire control unit token
(RCUToken) to the zero-latency instruction. As a consequence, the RCUToken was
used uninitialized. This was causing a crash in the RetireControlUnit logic.

Fixes PR36650.

llvm-svn: 327056
2018-03-08 20:21:55 +00:00
Andrea Di Biagio
90adf354a8 [llvm-mca] add override keyword to method ResourcePressureView::printView().
NFC.

llvm-svn: 327027
2018-03-08 17:02:28 +00:00
Andrea Di Biagio
b9a5c5c635 [llvm-mca] HWEventListener is a class, not struct.
This should appease the buildbots.

llvm-svn: 327025
2018-03-08 16:34:19 +00:00
Andrea Di Biagio
84af6ac04f [llvm-mca] Unify the API for the various views. NFCI
This allows the customization of the performance report.

Users can specify their own custom sequence of views.
Each view contributes a portion of the performance report generated by the
BackendPrinter.

Internally, class BackendPrinter keeps a sequence of views; views are printed
out in sequence when method 'printReport()' is called. 

This patch addresses one of the two review comments from Clement in D43951.

llvm-svn: 327018
2018-03-08 16:08:43 +00:00
Andrea Di Biagio
e9587cc537 [llvm-mca] Emit the 'Instruction Info' table before the resource pressure view.
In future, both the summary information and the 'instruction info' table should
be moved into a separate "Summary" view.

llvm-svn: 327010
2018-03-08 15:34:38 +00:00
Andrea Di Biagio
45f0e5261e [llvm-mca] LLVM Machine Code Analyzer.
llvm-mca is an LLVM based performance analysis tool that can be used to
statically measure the performance of code, and to help triage potential
problems with target scheduling models.

llvm-mca uses information which is already available in LLVM (e.g. scheduling
models) to statically measure the performance of machine code in a specific cpu.
Performance is measured in terms of throughput as well as processor resource
consumption. The tool currently works for processors with an out-of-order
backend, for which there is a scheduling model available in LLVM.

The main goal of this tool is not just to predict the performance of the code
when run on the target, but also help with diagnosing potential performance
issues.

Given an assembly code sequence, llvm-mca estimates the IPC (instructions per
cycle), as well as hardware resources pressure. The analysis and reporting style
were mostly inspired by the IACA tool from Intel.

This patch is related to the RFC on llvm-dev visible at this link:
http://lists.llvm.org/pipermail/llvm-dev/2018-March/121490.html

Differential Revision: https://reviews.llvm.org/D43951

llvm-svn: 326998
2018-03-08 13:05:02 +00:00