24 Commits

Author SHA1 Message Date
Matt Davis
fce447566a [llvm-mca] Introduce the ExecuteStage (was originally the Scheduler class).
Summary: This patch transforms the Scheduler class into the ExecuteStage.  Most of the logic remains.  

Reviewers: andreadb, RKSimon, courbet

Reviewed By: andreadb

Subscribers: mgorny, javed.absar, tschuett, gbedwell, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334679 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 01:20:18 +00:00
Matt Davis
cf35b20cbe [llvm-mca] Add the RetireStage.
Summary:
This class maintains the same logic as the original RetireControlUnit.

This is just an intermediate patch to make the RCU a Stage.  Future patches will remove the dependency on the DispatchStage, and then more properly populate the pre/execute/post Stage interface.  

Reviewers: andreadb, RKSimon, courbet

Reviewed By: andreadb, courbet

Subscribers: javed.absar, mgorny, tschuett, gbedwell, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333292 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-25 18:00:25 +00:00
Matt Davis
c783a5d937 [llvm-mca] Make Dispatch a subclass of Stage.
Summary:
The logic of dispatch remains the same, but now DispatchUnit is a Stage (DispatchStage).

This change has the benefit of simplifying the backend runCycle() code.
The same logic applies, but it belongs to different components now.  This is just a start,
eventually we will need to remove the call to the DispatchStage in Scheduler.cpp, but
that will be a separate patch.  This change is mostly a renaming and moving of existing logic.

This change also encouraged me to remove the Subtarget (STI) member from the
Backend class.  That member was used to initialize the other members of Backend
and to eventually call DispatchUnit::dispatch().  Now that we have Stages, we
can eliminate this by instantiating the DispatchStage with everything it needs
at the time of construction (e.g., Subtarget).  That change allows us to call
DispatchStage::execute(IR) as we expect to call execute() for all other stages.

Once we add the Stage list (D46907) we can more cleanly call preExecute() on
all of the stages, DispatchStage, will probably wrap cycleEvent() in that
case.

Made some formatting and minor cleanups to README.txt.  Some of the text
was re-flowed to stay within 80 cols.


Reviewers: andreadb, courbet, RKSimon

Reviewed By: andreadb, courbet

Subscribers: mgorny, javed.absar, tschuett, gbedwell, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332652 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-17 19:22:29 +00:00
Matt Davis
c9a31109e7 [llvm-mca] Avoid exposing index values in the MCA interfaces.
Summary:
This patch eliminates many places where we originally needed to  pass index
values to represent an instruction.  The index is still used as a key, in various parts of 
MCA.  I'm  not comfortable eliminating the index just yet.    By burying the index in
the instruction, we can avoid exposing that value in many places.

Eventually, we should consider removing the Instructions list in the Backend 
all together,   it's only used to hold and reclaim the memory for the allocated 
Instruction instances.  Instead we could pass around a smart pointer.  But that's
a separate discussion/patch.

Reviewers: andreadb, courbet, RKSimon

Reviewed By: andreadb

Subscribers: javed.absar, tschuett, gbedwell, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331660 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-07 18:29:15 +00:00
Adrian Prantl
26b584c691 Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

  for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331272 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-01 15:54:18 +00:00
Matt Davis
891b01ba29 [MCA] [NFC] Remove unused Index formal from ResourceManager::issueInstruction
Summary: The instruction index was never referenced in the body.  Just a minor cleanup.

Reviewers: andreadb

Reviewed By: andreadb

Subscribers: javed.absar, gbedwell, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331001 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-26 22:30:40 +00:00
Andrea Di Biagio
b7acab1156 [llvm-mca] run clang-format on a bunch of files. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330811 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-25 10:27:30 +00:00
Andrea Di Biagio
0f80c5447f [llvm-mca] Refactor the Scheduler interface in preparation for PR36663.
Zero latency instructions are now scheduled the same way as other instructions.
Before this patch, there was a specialzed code path for those instructions.

All scheduler events are now generated from method `scheduleInstruction()` and
from method `cycleEvent()`. This will make easier to implement a "execution
stage", and let that stage publish all the scheduler events.

No functional change intended.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330723 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-24 14:53:16 +00:00
Andrea Di Biagio
a2ce47d27d [llvm-mca] Ensure that instructions with a schedule read-advance are always issued in the right order.
Normally, the Scheduler prioritizes older instructions over younger instructions
during the instruction issue stage. In one particular case where a dependent
instruction had a schedule read-advance associated to one of the input operands,
this rule was not correctly applied.

This patch fixes the issue and adds a test to verify that we don't regress that
particular case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330032 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-13 15:19:07 +00:00
Andrea Di Biagio
ca9b26eb14 [llvm-mca] Removed unused argument from cycleEvent. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329895 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-12 10:49:40 +00:00
Andrea Di Biagio
db8b1f306e [llvm-mca] Let the Scheduler notify dispatch stall events caused by the lack of scheduling resources.
This patch moves part of the logic that notifies dispatch stall events from the
DispatchUnit to the Scheduler.

The main goal of this patch is to remove (yet another) dependency between the
DispatchUnit and the Scheduler. Before this patch, the DispatchUnit had to know
about `Scheduler::Event` and how to classify stalls due to the lack of scheduling
resources. This patch removes that knowledge and simplifies the logic in
DispatchUnit::checkScheduler.

This is another change done in preparation for the work to fix PR36663.

No functional change intended.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329835 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-11 18:05:23 +00:00
Andrea Di Biagio
8ff27dbe39 [llvm-mca] Correctly set the ReadAdvance information for register use operands.
The tool was passing the wrong operand index to method
MCSubtargetInfo::getReadAdvanceCycles(). That method requires a "UseIdx", and
not the operand index. This was found when testing X86 code where instructions
had a memory folded operand.

This patch fixes the issue and adds test read-advance-1.s to ensure that
the ReadAfterLd (a ReadAdvance of 3cy) information is correctly used.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328790 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-29 14:26:56 +00:00
Andrea Di Biagio
add7b3e24e [llvm-mca] run clang-format on all files.
This also addresses Simon's review comment in D44839.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328428 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-24 16:05:36 +00:00
Andrea Di Biagio
c643add02d [llvm-mca] Make the resource cost a double.
This is done in preparation for the fix for PR36874.
The number of cycles consumed for each pipe is now a double quantity. This
allows reuse of the resource pressure view to print out instruction tables.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328335 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-23 17:36:07 +00:00
Andrea Di Biagio
0183d4fd60 [llvm-mca] Remove const from a bunch of ArrayRef. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328018 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-20 19:06:34 +00:00
Andrea Di Biagio
5c0bc7c635 [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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328011 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-20 18:20:39 +00:00
Andrea Di Biagio
bce5921b79 [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327973 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-20 12:25:54 +00:00
Andrea Di Biagio
8804752576 [llvm-mca] Remove unused method from ResourceManager. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327888 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-19 19:14:06 +00:00
Andrea Di Biagio
de37af54bd [llvm-mca] Simplify code. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327886 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-19 19:09:38 +00:00
Andrea Di Biagio
04be4f5879 [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327425 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-13 17:24:32 +00:00
Andrea Di Biagio
7411a59746 [llvm-mca] Use a const ArrayRef in a few places. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327396 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-13 13:58:02 +00:00
Clement Courbet
641c297f4d [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327389 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-13 13:11:01 +00:00
Andrea Di Biagio
80f8cd5c84 [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327214 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-10 16:55:07 +00:00
Andrea Di Biagio
29b29cc6a9 [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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326998 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-08 13:05:02 +00:00