summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca
Commit message (Collapse)AuthorAgeFilesLines
* [llvm-mca] Hide unrelated flags from the -help output.Andrea Di Biagio2018-05-171-23/+35
| | | | llvm-svn: 332615
* [llvm-mca] add flag -all-views and flag -all-stats.Andrea Di Biagio2018-05-171-0/+38
| | | | | | | Flag -all-views enables all the views. Flag -all-stats enables all the views that print hardware statistics. llvm-svn: 332602
* [llvm-mca] Move the RegisterFile class into its own translation unit. NFCMatt Davis2018-05-165-371/+428
| | | | | | | | | | | | | | Summary: This change will help us turn the DispatchUnit into its own stage. Reviewers: andreadb, RKSimon, courbet Reviewed By: andreadb, courbet Subscribers: mgorny, tschuett, gbedwell, llvm-commits Differential Revision: https://reviews.llvm.org/D46916 llvm-svn: 332493
* [llvm-mca] Move definitions in FetchStage.cpp inside namespace mca. NFCAndrea Di Biagio2018-05-162-3/+3
| | | | | | Also, get rid of a redundant include in FetchStage.h and FetchStage.cpp. llvm-svn: 332468
* [llvm-mca] Fix perf regression after r332390.Andrea Di Biagio2018-05-162-7/+9
| | | | | | | | | | | | | | | | | | | | | | | Revision 332390 introduced a FetchStage class in llvm-mca. By design, FetchStage owns all the instructions in-flight in the OoO Backend. Before this change, new instructions were added to a DenseMap indexed by instruction id. The problem with using a DenseMap is that elements are not ordered by key. This was causing a massive slow down in method FetchStage::postExecute(), which searches for instructions retired that can be deleted. This patch replaces the DenseMap with a std::map ordered by instruction index. At the end of every cycle, we search for the first instruction which is not marked as "retired", and we remove all the previous instructions before it. This works well because instructions are retired in-order. Before this patch, a debug build of llvm-mca (on my Ryzen linux machine) took ~8.0 seconds to simulate 3000 iterations of a x86 dot-product (a `vmulps, vpermilps, vaddps, vpermilps, vaddps` sequence). With this patch, it now takes ~0.8s to run all the 3000 iterations. llvm-svn: 332461
* [llvm-mca] Remove redundant includes in Stage.h.Andrea Di Biagio2018-05-164-9/+8
| | | | | | | | This patch also makes Stage::isReady() a const method. No functional change. llvm-svn: 332443
* [llvm-mca] Introduce a pipeline Stage class and FetchStage.Matt Davis2018-05-1510-39/+216
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is just an idea, really two ideas. I expect some push-back, but I realize that posting a diff is the most comprehensive way to express these concepts. This patch introduces a Stage class which represents the various stages of an instruction pipeline. As a start, I have created a simple FetchStage that is based on existing logic for how MCA produces instructions, but now encapsulated in a Stage. The idea should become more concrete once we introduce additional stages. The idea being, that when a stage completes, the next stage in the pipeline will be executed. Stages are chained together as a singly linked list to closely model a real pipeline. For now there is only one stage, so the stage-to-stage flow of instructions isn't immediately obvious. Eventually, Stage will also handle event notifications, but that functionality is not complete, and not destined for this patch. Ideally, an interested party can register for notifications from a particular stage. Callbacks will be issued to these listeners at various points in the execution of the stage. For now, eventing functionality remains similar to what it has been in mca::Backend. We will be building-up the Stage class as we move on, such as adding debug output. This patch also removes the unique_ptr<Instruction> return value from InstrBuilder::createInstruction. An Instruction pointer is still produced, but now it's up to the caller to decide how that item should be managed post-allocation (e.g., smart pointer). This allows the Fetch stage to create instructions and manage the lifetime of those instructions as it wishes, and not have to be bound to any specific managed pointer type. Other callers of createInstruction might have different requirements, and thus can manage the pointer to fit their needs. Another idea would be to push the ownership to the RCU. Currently, the FetchStage will wrap the Instruction pointer in a shared_ptr. This allows us to remove the Instruction container in Backend, which was probably going to disappear, or move, at some point anyways. Note that I did run these changes through valgrind, to make sure we are not leaking memory. While the shared_ptr comes with some additional overhead it relieves us from having to manage a list of generated instructions, and/or make lookup calls to remove the instructions. I realize that both the Stage class and the Instruction pointer management (mentioned directly above) are separate but related ideas, and probably should land as separate patches; I am happy to do that if either idea is decent. The main reason these two ideas are together is that Stage::execute() can mutate an InstRef. For the fetch stage, the InstRef is populated as the primary action of that stage (execute()). I didn't want to change the Stage interface to support the idea of generating an instruction. Ideally, instructions are to be pushed through the pipeline. I didn't want to draw too much of a specialization just for the fetch stage. Excuse the word-salad. Reviewers: andreadb, courbet, RKSimon Reviewed By: andreadb Subscribers: llvm-commits, mgorny, javed.absar, tschuett, gbedwell Differential Revision: https://reviews.llvm.org/D46741 llvm-svn: 332390
* [llvm-mca] use a formatted_raw_ostream to insert padding and get rid of ↵Andrea Di Biagio2018-05-153-92/+76
| | | | | | tabs. NFC llvm-svn: 332381
* [llvm-mca] Strip leading tabs and spaces from instruction strings before ↵Andrea Di Biagio2018-05-153-11/+54
| | | | | | printing. NFC llvm-svn: 332361
* [llvm-mca] Remove unused include header files. NFCAndrea Di Biagio2018-05-151-4/+3
| | | | | | Also, run clang-format on RetireControlUnit.cpp. llvm-svn: 332337
* [llvm-mca] Add file header to RetireControlUnit.cpp.Andrea Di Biagio2018-05-151-0/+15
| | | | | | | Strictly speaking, this is not necessary for .cpp files. However, other .cpp files from this same tool have it. This also matches what we do in other tools. llvm-svn: 332334
* [llvm-mca] Improved support for dependency-breaking instructions.Andrea Di Biagio2018-05-144-35/+54
| | | | | | | | | The tool assumes that a zero-latency instruction that doesn't consume hardware resources is an optimizable dependency-breaking instruction. That means, it doesn't have to wait on register input operands, and it doesn't consume any physical register. The PRF knows how to optimize it at register renaming stage. llvm-svn: 332249
* Rename DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-145-37/+41
| | | | | | | | | | | | | | | | The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM - Manual change to APInt - Manually chage DOCS as regex doesn't match it. In the transition period the DEBUG() macro is still present and aliased to the LLVM_DEBUG() one. Differential Revision: https://reviews.llvm.org/D43624 llvm-svn: 332240
* Move standard library inclusions to after internal inclusions.David Blaikie2018-05-111-3/+3
| | | | llvm-svn: 332124
* llvm-mca: Add missing includesDavid Blaikie2018-05-092-1/+5
| | | | | | | Move the header include in the primary source file to the top to validate that it doesn't depend on any other inclusions. llvm-svn: 331897
* [llvm-mca] Avoid exposing index values in the MCA interfaces.Matt Davis2018-05-0716-173/+204
| | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 331660
* [llvm-mca] removes flag -instruction-tables from the "View Options" category.Andrea Di Biagio2018-05-051-25/+15
| | | | | | | | This patch also improves the description of a couple of flags in the view options. With this change, the -help now specifies which views are enabled by default. llvm-svn: 331594
* [llvm-mca] minor tweak to the resource pressure printing functionality. NFC.Andrea Di Biagio2018-05-051-1/+1
| | | | llvm-svn: 331590
* [llvm-mca] Add descriptive names for the TimelineView report characters. NFC.Matt Davis2018-05-042-8/+18
| | | | | | | | | | | | | | | | Summary: This change makes the TimelineView source simpler to read and easier to modify in the future. This patch introduces a class of static chars used as the display values in the TimelineView report, this change just eliminates a few magic characters. Reviewers: andreadb, courbet, RKSimon Reviewed By: andreadb Subscribers: tschuett, gbedwell, llvm-commits Differential Revision: https://reviews.llvm.org/D46409 llvm-svn: 331540
* [llvm-mca] use colors for warnings and notes generated by InstrBuilder.Andrea Di Biagio2018-05-042-10/+10
| | | | llvm-svn: 331517
* [llvm-mca] remove unused argument from method InstrBuilder::createInstrDescImpl.Andrea Di Biagio2018-05-044-11/+13
| | | | | | | | | We don't need to pass the instruction index to the method that constructs new instruction descriptors. No functional change intended. llvm-svn: 331516
* [llvm-mca] Lift the logic of the RetireControlUnit from the Dispatch ↵Matt Davis2018-05-015-132/+175
| | | | | | | | | | translation unit into its own translation unit. NFC The logic remains the same. Eventually, I see the RCU acting as its own separate stage in the instruction pipeline. Differential Revision: https://reviews.llvm.org/D46331 llvm-svn: 331316
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-0111-20/+20
| | | | | | | | | | | | | | | | 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 llvm-svn: 331272
* [llvm-mca] Correctly handle zero-latency stores that consume pipeline resources.Andrea Di Biagio2018-04-302-2/+4
| | | | | | | | | | | | | | | | This fixes PR37293. We can have scheduling classes with no write latency entries, that still consume processor resources. We don't want to treat those instructions as zero-latency instructions; they still have to be issued to the underlying pipelines, so they still consume resource cycles. This is likely to be a regression which I have accidentally introduced at revision 330807. Now, if an instruction has a non-empty set of write processor resources, we conservatively treat it as a normal (i.e. non zero-latency) instruction. llvm-svn: 331193
* [llvm-mca] Support for in-order CPU for -instruction-tables testing.Andrea Di Biagio2018-04-301-1/+1
| | | | | | | | | Added Intel Atom tests to verify that the tool correctly generates instruction tables even if the CPU is in-order. Fixes PR37282. llvm-svn: 331169
* [MCA] [NFC] Remove unused Index formal from ResourceManager::issueInstructionMatt Davis2018-04-262-3/+3
| | | | | | | | | | | | | | 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 llvm-svn: 331001
* [llvm-mca] Make ViewOptions static. NFCIFilipe Cabecinhas2018-04-251-1/+1
| | | | llvm-svn: 330829
* [llvm-mca] Add a new option category for views.Andrea Di Biagio2018-04-251-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | With this patch, options to add/tweak views are all grouped together in the -help output. The new "View Options" category looks like this: ``` View Options: -dispatch-stats - Print dispatch statistics -instruction-info - Print the instruction info view -instruction-tables - Print instruction tables -register-file-stats - Print register file statistics -resource-pressure - Print the resource pressure view -retire-stats - Print retire control unit statistics -scheduler-stats - Print scheduler statistics -timeline - Print the timeline view -timeline-max-cycles=<uint> - Maximum number of cycles in the timeline view. Defaults to 80 cycles -timeline-max-iterations=<uint> - Maximum number of iterations to print in timeline view ``` llvm-svn: 330816
* [llvm-mca] run clang-format on a bunch of files. NFCAndrea Di Biagio2018-04-254-14/+13
| | | | llvm-svn: 330811
* [llvm-mca] Default to the native host cpu if flag -mcpu is not specified.Andrea Di Biagio2018-04-251-2/+7
| | | | llvm-svn: 330809
* [llvm-mca] Remove method Instruction::isZeroLatency(). NFCIAndrea Di Biagio2018-04-255-13/+11
| | | | llvm-svn: 330807
* [llvm-mca] Remove unused flag -verbose. NFCAndrea Di Biagio2018-04-241-4/+0
| | | | | | I forgot to remove it at r329794. llvm-svn: 330757
* [llvm-mca] Default the output asm dialect used by the instruction printer to ↵Andrea Di Biagio2018-04-241-12/+16
| | | | | | | | | | | | | | | | the input asm dialect. The instruction printer used by llvm-mca to generate the performance report now defaults the output assembly format to the format used for the input assembly file. On x86, the asm format can be either AT&T or Intel, depending on the presence/absence of directive `.intel_syntax`. Users can still specify a different assembly dialect with the command line flag -output-asm-variant=<uint>. llvm-svn: 330733
* [llvm-mca] Refactor the Scheduler interface in preparation for PR36663.Andrea Di Biagio2018-04-242-79/+107
| | | | | | | | | | | | | 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. llvm-svn: 330723
* [llvm-mca] Use WithColor for printing errorsJonas Devlieghere2018-04-181-12/+15
| | | | | | | | Use convenience helpers in WithColor to print errors and notes. Differential revision: https://reviews.llvm.org/D45666 llvm-svn: 330267
* Define InitLLVM to do common initialization all at once.Rui Ueyama2018-04-131-5/+2
| | | | | | | | | | | We have a few functions that virtually all command wants to run on process startup/shutdown. This patch adds InitLLVM class to do that all at once, so that we don't need to copy-n-paste boilerplate code to each llvm command's main() function. Differential Revision: https://reviews.llvm.org/D45602 llvm-svn: 330046
* [llvm-mca] Ensure that instructions with a schedule read-advance are always ↵Andrea Di Biagio2018-04-132-57/+47
| | | | | | | | | | | | | | 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. llvm-svn: 330032
* [llvm-mca] Removed unused argument from cycleEvent. NFCAndrea Di Biagio2018-04-1210-17/+17
| | | | llvm-svn: 329895
* [llvm-mca] Let the Scheduler notify dispatch stall events caused by the lack ↵Andrea Di Biagio2018-04-114-70/+25
| | | | | | | | | | | | | | | | | | | 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. llvm-svn: 329835
* Revert "[llvm-mca][CMake] Remove unused libraries from set LLVM_LINK_COMPONENTS"Andrea Di Biagio2018-04-111-0/+6
| | | | | | It caused a buildbot failure (clang-ppc64le-linux-multistage - build #6424) llvm-svn: 329812
* [llvm-mca][CMake] Remove unused libraries from set LLVM_LINK_COMPONENTS.Andrea Di Biagio2018-04-111-6/+0
| | | | llvm-svn: 329807
* [llvm-mca] Minor code cleanup. NFCAndrea Di Biagio2018-04-115-26/+19
| | | | llvm-svn: 329796
* [llvm-mca] Renamed BackendStatistics to RetireControlUnitStatistics.Andrea Di Biagio2018-04-114-26/+26
| | | | | | Also, removed flag -verbose in favor of flag -retire-stats. llvm-svn: 329794
* [llvm-mca] Move the logic that prints scheduler statistics from ↵Andrea Di Biagio2018-04-116-124/+203
| | | | | | | | BackendStatistics to its own view. Added flag -scheduler-stats to print scheduler related statistics. llvm-svn: 329792
* [llvm-mca] Simplify code. NFCAndrea Di Biagio2018-04-101-30/+18
| | | | llvm-svn: 329711
* [llvm-mca] Move the logic that prints dispatch unit statistics from ↵Andrea Di Biagio2018-04-106-81/+170
| | | | | | | | | | | BackendStatistics to its own view. This patch moves the logic that collects and analyzes dispatch events to the DispatchStatistics view. Added flag -dispatch-stats to print statistics related to the dispatch logic. llvm-svn: 329708
* [llvm-mca] Increase the default number of iterations to 100.Andrea Di Biagio2018-04-102-2/+2
| | | | llvm-svn: 329694
* Reapply "[llvm-mca] Do not separate iterations with a newline in the ↵Andrea Di Biagio2018-04-102-23/+17
| | | | | | | | timeline view." This reapplies r329403 with a fix for the floating point rounding issue. llvm-svn: 329680
* [llvm-mca] Fix MCACommentConsumerFangrui Song2018-04-091-1/+1
| | | | llvm-svn: 329592
* [llvm-mca] Add the ability to mark regions of code for analysis (PR36875)Andrea Di Biagio2018-04-095-46/+306
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch teaches llvm-mca how to parse code comments in search for special "markers" used to select regions of code. Example: # LLVM-MCA-BEGIN My Code Region .... # LLVM-MCA-END The MCAsmLexer now delegates to an object of class MCACommentParser (i.e. an AsmCommentConsumer) the parsing of code comments to search for begin/end code region markers. A comment starting with substring "LLVM-MCA-BEGIN" marks the beginning of a new region of code. A comment starting with substring "LLVM-MCA-END" marks the end of the last region. This implementation doesn't allow regions to overlap. Each region can have a optional description; internally, each region is identified by a range of source code locations (SMLoc). MCInst objects are added to a region R only if the source location for the MCInst is in the range of locations specified by R. By default, the tool allocates an implicit "Default" code region which contains every source location. See new tests llvm-mca-marker-*.s for a few examples. A new Backend object is created for every region. So, the analysis is conducted on every parsed code region. The final report is the union of the reports generated for every code region. Note that empty regions are skipped. Special "[#] Code Region - ..." strings are used in the report to mark the portion which is specific to a code region only. For example, see llvm-mca-markers-5.s. Differential Revision: https://reviews.llvm.org/D45433 llvm-svn: 329590
OpenPOWER on IntegriCloud