aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-exegesis/lib/Target.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-17[llvm-exegesis] Ignore the instructions for which InstrDesc.getSchedClass() ↵Jim Lin1-0/+2
== 0 (#143840) This allows llvm-exegesis to skip instructions that lack scheduling information, avoiding invalid benchmarking. e.g. `InstB` in RISC-V.
2025-02-28[Exegesis][RISCV] Add initial RVV support (#128767)Min-Yih Hsu1-0/+13
This patch adds initial vector extension support to RISC-V's exegesis. The strategy here is to enumerate all RVV _pseudo_ opcodes as their MC opcode counterparts are kind of useless under this circumstance. We also enumerate all possible VTYPE operands in each CodeTemplate configuration. Various of MachineFunction Passes are used for post processing the snippets, like inserting VSETVLI instructions. See https://llvm.org/devmtg/2024-10/slides/techtalk/Hsu-RVV-Exegesis.pdf for more technical details.
2025-01-16[llvm-exegesis] Begin replacing unsigned with MCRegister. NFC (#123109)Craig Topper1-1/+1
Some of this was needed to fix implicit conversions from MCRegister to unsigned when calling getReg() on MCOperand for example. The majority was done by reviewing parts of the code that dealt with registers, converting them to MCRegister and then seeing what new implicit conversions were created and fixing those. There were a few places where I used MCPhysReg instead of MCRegiser for static arrays since its uint16_t instead of unsigned.
2025-01-14Revert "Reland: "[Exegesis] Add the ability to dry-run the measurement phase ↵Min Hsu1-2/+2
(#121991)" (#122775)" This reverts commit a39aaf35d3858a5542f532e399482c2bb0259dac and 63d3bd6d0caf8185aba49540fe2f67512fdf3a98. Due to test failures on MacOSX.
2025-01-13Reland: "[Exegesis] Add the ability to dry-run the measurement phase ↵Min-Yih Hsu1-2/+2
(#121991)" (#122775) This relands f8f8598fd886cddfd374fa43eb6d7d37d301b576 Follow up on #122371: The problem here is a little subtle: when we dry-run the measurement phase, we create a LLJIT instance without actually executing the snippets. The key is, LLJIT has its own TargetMachine which uses triple designated by LLVM_TARGET_ARCH (which is default to host). On a machine that does not support Exegesis, the LLJIT would fail to create its TargetMachine because llvm-exegesis don't even register the host's target! Putting this test into any of the target-specific folder won't help, because it's about the host. And personally I don't really want to use `exegesis-can-execute-<arch>` for generic tests like this -- it's too strict as we don't actually need to execute the snippet. My solution here is creating another test feature which is added only when LLVM_TARGET_ARCH is supported by llvm-exegesis. This feature is something in between `<arch>-registered-target` and `exegesis-can-execute-<arch>`.
2025-01-09Revert "[Exegesis] Add the ability to dry-run the measurement phase (… ↵Min-Yih Hsu1-2/+2
(#122371) …#121991)" This reverts commit f8f8598fd886cddfd374fa43eb6d7d37d301b576. This breaks ARMv7 and s390x buildbot with the following message: ``` llvm-exegesis error: No available targets are compatible with triple "armv8l-unknown-linux-gnueabihf" FileCheck error: '<stdin>' is empty. FileCheck command line: /home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/FileCheck /home/tcwg-buildbot/worker/clang-armv7-2stage/llvm/llvm/test/tools/llvm-exegesis/dry-run-measurement.test ```
2025-01-09[Exegesis] Add the ability to dry-run the measurement phase (#121991)Min-Yih Hsu1-2/+2
With the new benchmark phase, `dry-run-measurement`, llvm-exegesis can run everything except the actual snippet execution. It is useful when we want to test some parts of the code between the `assemble-measured-code` and `measure` phase without actually running on native platforms.
2024-01-29[llvm-exegesis] Remove llvm prefix where unnecessary (#79802)Aiden Grossman1-13/+12
This patch removes the llvm:: prefix within llvm-exegesis where it is not necessary. This is most occurrences of the prefix within exegesis as exegesis is within the llvm namespace. This patch makes things more consistent as the vast majority of the code did not use the llvm:: prefix for anything.
2024-01-19[llvm-exegesis] Add support for validation counters (#76653)Aiden Grossman1-10/+25
This patch adds support for validation counters. Validation counters can be used to measure events that occur during snippet execution like cache misses to ensure that certain assumed invariants about the benchmark actually hold. Validation counters are setup within a perf event group, so are turned on and off at exactly the same time as the "group leader" counter that measures the desired value.
2024-01-16[llvm-exegesis] Refactor Counter to CounterGroup (#77887)Aiden Grossman1-2/+2
This refactoring gets things ready for validation counters where the plan is to reuse the existing Counter infrastructure to contain event groups that consist of a single event that is being measured along with validation counters.
2024-01-10[llvm-exegesis] Add tablegen support for validation counters (#76652)Aiden Grossman1-2/+7
This patch adds support in the llvm-exegesis tablegen emitter for validation counters. Full support for validation counters in llvm-exegesis will be added in a future patch.
2023-12-07[llvm-exegesis] Add option to specify the number of measurement repetitions ↵Aiden Grossman1-3/+7
(#74276) Currently, the llvm-exegesis LatencyBenchmarkRunner repeats the benchmark several times (currently 30) and then aggregates the result to deal with noise in the measurement process. With this patch, the number of repetitions to perform is made configurable rather than left as a static number. This allows for significantly faster execution in situations where someone is performing a task like experimenting with memory annotations where the exact cycle counts might not be useful, and also allows for increased precision when desired.
2023-08-02[llvm-exegesis] Prevent llvm-exegesis from using unsupported opcodesPavel Kosov1-1/+4
When generating snippets for AArch64 with --opcode-index=-1, the code generator asserts on opcodes that are not supported according to CPU features. The same assertion can be triggered even when generating a serial snippet for a supported opcode if SERIAL_VIA_NON_MEMORY_INSTR execution mode is used and an unsupported instruction is chosen as the "other instruction". Unlike the first case, this one may result in flaky failures because the other instruction is randomly chosen from the instructions suitable for serializing execution. This patch adjusts TableGen emitter for *GenInstrInfo.inc to make possible to query for opcode availability instead of just asserting on unsupported ones. ~~ Huawei RRI, OS Lab Reviewed By: courbet Differential Revision: https://reviews.llvm.org/D146303
2023-06-26[llvm-exegesis] Add ability to assign perf counters to specific PIDAiden Grossman1-2/+3
This patch gives the ability to assign performance counters within llvm-exegesis to a specific process by passing its PID. This is needed later on for implementing a subprocess executor. Defaults to zero, the current process, for the InProcessFunctionExecutorImpl. Reviewed By: courbet Differential Revision: https://reviews.llvm.org/D151020
2023-06-22Revert "[llvm-exegesis] Add ability to assign perf counters to specific PID"Aiden Grossman1-3/+2
Revert "[llvm-exegesis] Introduce Subprocess Executor Mode" This reverts commit 5e9173c43a9b97c8614e36d6f754317f731e71e9. This reverts commit 4d618b52f6e05e41d35f56653cb36bf7d4dc794e. Reverting the PID commit as it is currently breaking MinGW builds and the way I'm checking for the presence of pid_t needs to be fixed and I need to do some testing. The subprocess executor mode patch is a dependent patch so also needs to be reverted and also needs some work as it is currently failing tests where libpfm is installed and the kernel version is less than 5.6.
2023-06-21[llvm-exegesis] Add ability to assign perf counters to specific PIDAiden Grossman1-2/+3
This patch gives the ability to assign performance counters within llvm-exegesis to a specific process by passing its PID. This is needed later on for implementing a subprocess executor. Defaults to zero, the current process, for the InProcessFunctionExecutorImpl. Reviewed By: courbet Differential Revision: https://reviews.llvm.org/D151020
2023-06-21[llvm-exegesis] Refactor FunctionExecutorImpl and create factoryAiden Grossman1-6/+10
In order to better support adding in new implementations of FunctionExecutor, this patch makes some small changes so that it is easier to add new ones in. FunctionExecutorImpl is renamed to InProcessFunctionExecutorImpl to better reflect how it will be placed relative to the soon-to-be introduced subprocess executor and a new function is created to create executors so selection can be done more easily. In addition, a new CLI flag, -execution-mode, which can be used to select between the different executors. Reviewed By: courbet Differential Revision: https://reviews.llvm.org/D151019
2023-04-06[llvm-exegesis] Make possible to execute snippets without perf countersPavel Kosov1-4/+14
Performance counters may be unavailable due to various reasons (such as access restriction via sysctl properties or the CPU model being unknown to libpfm). On the other hand, for debugging llvm-exegesis itself it is still useful to be able to run generated code snippets to ensure that the snippet does not crash at run time. The --use-dummy-perf-counters command line option makes llvm-exegesis behave just as usual except for using fake event counts instead of asking the kernel for actual values. ~~ Huawei RRI, OS Lab Reviewed By: courbet Differential Revision: https://reviews.llvm.org/D146301
2023-03-27[llvm-exegesis] Refactor InstructionBenchmark to BenchmarkAiden Grossman1-15/+15
When llvm-exegesis was first introduced, it only supported benchmarking individual instructions, hence the name for the data structure storing the data corresponding to a benchmark being called InstructionBenchmark made sense. However, now that benchmarking arbitrary snippets is supported, InstructionBenchmark doesn't correspond to a single instruction. This patch refactors InstructionBenchmark to be called Benchmark to clean up this little bit of technical debt. Reviewed By: courbet Differential Revision: https://reviews.llvm.org/D146884
2023-01-26Migrate away from C++20-deprecated POD type traitsDavid Blaikie1-1/+1
2023-01-05[exegesis] "Skip codegen" dry-run modeRoman Lebedev1-11/+11
While "skip measurements mode" is super useful for test coverage, i've come to discover it's trade-offs. It still calls back-end to actually codegen the target assembly, and that is what is taking 80%+ of the time regardless of whether or not we skip the measurements. On the other hand, just being able to see that exegesis can come up with a snippet to measure something, is already very useful, and takes maybe a second for a all-opcode sweep. Reviewed By: gchatelet Differential Revision: https://reviews.llvm.org/D140702
2022-12-21[NFC][llvm-exegesis] Ensure that target options show up in --helpRoman Lebedev1-0/+4
Fixes https://github.com/llvm/llvm-project/issues/59377
2022-12-07[llvm-exegesis] Dry run modeRoman Lebedev1-10/+22
Sometimes we only want to ensure that we can produce snippets (all the way through `SnippetRepetitor`!), but don't care for the execution. E.g. all of our tests are this way. I've built LLVM without PFM and removed my CPU from `X86PfmCounters.td`, and this produces the expected results in that configuration. Reviewed By: courbet Differential Revision: https://reviews.llvm.org/D139448
2021-01-16[llvm] Use *::empty (NFC)Kazu Hirata1-2/+1
2021-01-05[llvm] Use llvm::lower_bound and llvm::upper_bound (NFC)Kazu Hirata1-2/+1
2020-11-04Re-land "[llvm-exegesis] Save target state before running the benchmark."Clement Courbet1-0/+2
The X86 exegesis target is never executed run on non-X86 hosts, disable X86 instrinsic code on non-X86 targets. This reverts commit 8cfc872129a99782ab07a19171bf8eace85589ae.
2020-11-04Revert "Re-land "[llvm-exegesis] Save target state before running the ↵Clement Courbet1-2/+0
benchmark." Still issues on some architectures. This reverts commit fd13d7ce09af2bcad6976b8f5207874992bdd908.
2020-11-04Re-land "[llvm-exegesis] Save target state before running the benchmark.Clement Courbet1-0/+2
Use `__builtin_ia32_fxsave64` under __GNUC__, (_fxsave64) does not exist in old versions of gcc (pre-9.1). This reverts commit e128f9cafca4e72b089fcd1381af5a1ec656d987.
2020-11-02Revert "[llvm-exegesis] Save target state before running the benchmark."Clement Courbet1-2/+0
_fxsave64 is not available on some buildbots. This reverts commit 274de447fe9621082a523a7227157aeb84702a7d.
2020-11-02[llvm-exegesis] Save target state before running the benchmark.Clement Courbet1-0/+2
Some benchmarked instructions might set target state. Preserve this state. See PR26418. Differential Revision: https://reviews.llvm.org/D90592
2020-06-26 [llvm-exegesis] Let Counter returns up to 16 entriesVy Nguyen1-8/+11
LBR contains (up to) 16 entries for last x branches and the X86LBRCounter (from D77422) should be able to return all those. Currently, it just returns the latest entry, which could lead to mis-leading measurements. This patch aslo changes the LatencyBenchmarkRunner to accommodate multi-value readings. https://reviews.llvm.org/D81050
2020-06-02[llvm-exegesis] Fix D80610.Clement Courbet1-2/+1
Summary: Using a .data() member on a StringRef was discarding the StringRef size, breaking llvm-exegesis on machines with counter sums (e.g. Zen2). Reviewers: oontvoo Subscribers: mstojanovic, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D80982
2020-05-28[llvm-exegesis] Make a few counter methods virtual to allow targets to ↵Vy Nguyen1-0/+15
provide target-specific support. Misc: Also include errno in failure message. Differential Revision: https://reviews.llvm.org/D80610
2020-04-14[ADT/STLExtras.h] - Add llvm::is_sorted wrapper and update callers.Georgii Rymar1-2/+2
It can be used to avoid passing the begin and end of a range. This makes the code shorter and it is consistent with another wrappers we already have. Differential revision: https://reviews.llvm.org/D78016
2020-02-07Recommit: "[llvm-exegesis] Improve error reporting in Target.cpp"Miloš Stojanović1-5/+7
Summary: Commit 141915963b6ab36ee4e577d1b27673fa4d05b409 was reverted in abe01e17f648a97666d4fbed41f0861686a17972 because it broke builds testing without libpfm. A preparatory commit <commit_sha1> was added to enable this recommit. Original commit message: Followup to D74085. Replace the use of `report_fatal_error()` with returning the error to `llvm-exegesis.cpp` and handling it there. Differential Revision: https://reviews.llvm.org/D74113
2020-02-06Revert "[llvm-exegesis] Improve error reporting" and follow-up.Hans Wennborg1-7/+5
It broke e.g. all tests under tools/llvm-exegesis/X86/ when libpfm is not available, see comment on D74085. This reverts commit b3576f60ebc8f660afad8120a72473be47517573 and 141915963b6ab36ee4e577d1b27673fa4d05b409.
2020-02-06[llvm-exegesis] Improve error reporting in Target.cppMiloš Stojanović1-5/+7
Followup to D74085. Replace the use of `report_fatal_error()` with returning the error to `llvm-exegesis.cpp` and handling it there. Differential Revision: https://reviews.llvm.org/D74113
2020-01-23[llvm-exegesis] Allow the randomizer to fail nicely...Clement Courbet1-24/+0
Summary: ... instead of crashing. On typical exmaple is when there are no available registers. Reviewers: gchatelet Subscribers: tschuett, mstojanovic, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73196
2020-01-20[llvm-exegesis][NFC] Disassociate snippet generators from benchmark runnersMiloš Stojanović1-8/+10
The addition of `inverse_throughput` mode highlighted the disjointedness of snippet generators and benchmark runners because it used the `UopsSnippetGenerator` with the `LatencyBenchmarkRunner`. To keep the code consistent tie the snippet generators to parallelization/serialization rather than their benchmark runners. Renaming `LatencySnippetGenerator` -> `SerialSnippetGenerator`. Renaming `UopsSnippetGenerator` -> `ParallelSnippetGenerator`. Differential Revision: https://reviews.llvm.org/D72928
2019-12-31[llvm-exegesis] Check counters before runningMiloš Stojanović1-0/+11
Check if the appropriate counters for the specified mode are defined on the target. This is checked before any other work is done. Differential Revision: https://reviews.llvm.org/D71927
2019-10-09[llvm-exegesis][NFC] Remove extra `llvm::` qualifications.Clement Courbet1-17/+14
Summary: Second patch: in the lib. Reviewers: gchatelet Subscribers: nemanjai, tschuett, MaskRay, mgrang, jsji, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68692 llvm-svn: 374158
2019-10-08[llvm-exegesis] Add options to SnippetGenerator.Clement Courbet1-11/+11
Summary: This adds a `-max-configs-per-opcode` option to limit the number of configs per opcode. Reviewers: gchatelet Subscribers: tschuett, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68642 llvm-svn: 374054
2019-08-15[llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-4/+4
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
2019-04-06[llvm-exegesis][X86] Handle CMOVcc/SETcc OPERAND_COND_CODE OperandTypeRoman Lebedev1-0/+24
Summary: D60041 / D60138 refactoring changed how CMOV/SETcc opcodes are handled. concode is now an immediate, with it's own operand type. This at least allows to not crash on the opcode. However, this still won't generate all the snippets with all the condcode enumerators. D60066 does that. Reviewers: courbet, gchatelet Reviewed By: gchatelet Subscribers: tschuett, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60057 llvm-svn: 357841
2019-01-30[llvm-exegesis] Add throughput mode.Clement Courbet1-4/+6
Summary: This just uses the latency benchmark runner on the parallel uops snippet generator. Fixes PR37698. Reviewers: gchatelet Subscribers: tschuett, RKSimon, llvm-commits Differential Revision: https://reviews.llvm.org/D57000 llvm-svn: 352632
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-11-09[llvm-exegesis][NFC] Add a way to declare the default counter binding for ↵Clement Courbet1-2/+9
unbound CPUs for a target. Summary: This simplifies the code and moves everything to tablegen for consistency. This also prepares the ground for adding issue counters. Reviewers: gchatelet, john.brawn, jsji Subscribers: nemanjai, mgorny, javed.absar, kbarton, tschuett, llvm-commits Differential Revision: https://reviews.llvm.org/D54297 llvm-svn: 346489
2018-11-08Revert "[llvm-exegesis] Add a snippet generator to generate snippets to ↵Clement Courbet1-34/+20
compute ROB sizes." This reverts accidental commit rL346394. llvm-svn: 346398
2018-11-08[llvm-exegesis] Add a snippet generator to generate snippets to compute ROB ↵Clement Courbet1-20/+34
sizes. llvm-svn: 346394
2018-10-25[llvm-exegesis] Add missing initializer.Clement Courbet1-1/+1
This is a better fix than rL345245. llvm-svn: 345246