aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-01-14Revert "Reland: "[Exegesis] Add the ability to dry-run the measurement phase ↵Min Hsu1-25/+8
(#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-8/+25
(#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-25/+8
(#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-8/+25
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-12-24[llvm-exegesis] Fix typo in f2334c5919ec077e6a8deeaf43a5b5188baf0251Aiden Grossman1-1/+1
This should have been in the original commit, but I somehow forgot to run git add && git commit --amend --no-edit between making the change in my editor, saving the file, and pushing the commit.
2024-12-24[llvm-exegesis] Make benchmark pinning actually workAiden Grossman1-1/+2
When originally writing this feature up, I apparently completely forgot to actually make the test exercise it and left an extra exit in the function implementing the functionality without the appropriate preprocessor macros around it, causing things to never work. This patch should fix that.
2024-09-23Reland "[llvm-exegesis] Add support for pinning benchmarking process to a ↵Aiden Grossman1-12/+64
CPU (#85168)" (#109688) This reverts commit 2cd20c255684257b86940bdda6861897f0bf3c00. This relands commit 9886788a8a500a1b429a6db64397c849b112251c. This was causing more buildbot failures due to getcpu not being available with glibc <=2.29. This patch fixes that by directly making the syscall, assuming the syscall number macro is available.
2024-09-23Revert "[llvm-exegesis] Add support for pinning benchmarking process to a ↵Aiden Grossman1-59/+12
CPU (#85168)" This reverts commit 6fc2451167ec991361dd0568de9a9fa2926f8da8. This broke some more buildbots.
2024-09-23[llvm-exegesis] Fix -Wunused-variable in BenchmarkRunner.cpp (NFC)Jie Fu1-1/+1
/llvm-project/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp:415:18: error: unused variable 'CurrentCPU' [-Werror,-Wunused-variable] unsigned int CurrentCPU; ^ 1 error generated.
2024-09-23Reland "[llvm-exegesis] Add support for pinning benchmarking process to a ↵Aiden Grossman1-12/+59
CPU (#85168)" This reverts commit 5e3d48a68096a0017a0fa4bb89f2d48767c8a7e4. This relands commit 9886788a8a500a1b429a6db64397c849b112251c. This was originally causing build failures on more esoteric platforms that have different definitions of getcpu. This is only intended to be supported on x86-64 currently, so just use preprocessor definitions to special case the function.
2024-09-19Revert "[llvm-exegesis] Add support for pinning benchmarking process to a ↵Aiden Grossman1-52/+12
CPU (#85168)" This reverts commit 9886788a8a500a1b429a6db64397c849b112251c. This was breaking builds on ppc64 and AIX. Pulling so I have time to investigate.
2024-09-19[llvm-exegesis] Add support for pinning benchmarking process to a CPU (#85168)Aiden Grossman1-12/+52
This patch adds in support for pinning a benchmarking process to a specific CPU (in the subprocess benchmarking mode on Linux). This is intended to be used in environments where a certain set of CPUs is isolated from the scheduler using something like cgroups and thus should present less potential for noise than normal. This also opens up the door for doing multithreaded benchmarking as we can now pin benchmarking processes to specific CPUs that we know won't interfere with each other.
2024-08-30[NFC] Add explicit #include llvm-config.h where its macros are used. (#106621)Daniil Fukalov1-5/+5
Without these explicit includes, removing other headers, who implicitly include llvm-config.h, may have non-trivial side effects.
2024-08-27[llvm-exegesis] Switch from intptr_t to uintptr_t in most cases (#102860)Aiden Grossman1-7/+8
This patch switches most of the uses of intptr_t to uintptr_t within llvm-exegesis for the subprocess memory support. In the vast majority of cases we do not want a signed component of the address, hence making intptr_t undesirable. intptr_t is left for error handling, for example when making syscalls and we need to see if the syscall returned -1.
2024-07-27[llvm-exegesis] Use correct rseq struct size (#100804)Aiden Grossman1-1/+12
Glibc v2.40 changes the definition of __rseq_size to the usable area of the struct rather than the actual size of the struct to accommodate users trying to figure out what features can be used. This change breaks llvm-exegesis trying to disable rseq as the size registered in the kernel is no longer equal to __rseq_size. This patch adds a check to see if __rseq_size is less than 32 bytes and uses 32 as a value if it is given alignment requirements. Fixes #100791.
2024-04-26[llvm-exegesis] Close file descriptors after use (#86584)Aiden Grossman1-0/+2
There are several insstances in the subprocess executor in llvm-exegesis where we fail to close file descriptors after using them. This leaves them open, which can cause issues later on if a third-party binary is using the exegesis libraries and executing many blocks before exiting. Leaving the descriptors open until process exit is also bad practice. This patch fixes that by explicitly calling close() when we are done with a specific file descriptor. This patch fixes #86583.
2024-03-22Reland "[llvm-exegesis] Add thread IDs to subprocess memory names (#84451)"Aiden Grossman1-4/+5
This reverts commit 1fe9c417a0bf143f9bb9f9e1fbf7b20f44196883. This relands commit 6bbe8a296ee91754d423c59c35727eaa624f7140. This was causing build failures on one of the ARMv8 builders. Still not completely sure why, but relanding it to see if the failure pops up again. If it does, the plan is to fix forward by disabling tests on ARM temporarily as llvm-exegesis does not currently use SubprocessMemory on ARM.
2024-03-22Reland "[llvm-exegesis] Refactor parent code to separate function (#86232)"Aiden Grossman1-57/+67
This reverts commit c3a41aac5f32475b9a0499e6e888e713763566dc. This relands commit bd493756fa51e538575fc320aae50d75394f0567. Apparently I forgot to update a couple values, so this change failed on every builder that builds those sections (should be every Linux platform) rather than something architecture specific like originally thought. I swore I updated the values and ran check-llvm before merging. Wondering If I forgot to push those changes...
2024-03-22Revert "[llvm-exegesis] Refactor parent code to separate function (#86232)"Aiden Grossman1-63/+53
This reverts commit bd493756fa51e538575fc320aae50d75394f0567. Causes build failures on non-X86 platforms. https://lab.llvm.org/buildbot/#/changes/128363
2024-03-22[llvm-exegesis] Refactor parent code to separate function (#86232)Aiden Grossman1-53/+63
This patch refactors the parent code to a separate function in the subprocess executor to make the code more clear and easy to follow.
2024-03-21[llvm-exegesis] Kill process that recieve a signal (#86069)Aiden Grossman1-2/+16
Before this patch, llvm-exegesis would leave processes lingering that experienced signals like segmentation faults. They would up in a signal-delivery-stop state under the ptrace and never exit. This does not cause problems (or at least many) in llvm-exegesis as they are cleaned up after the main process exits, which usually happens quickly. However, in downstream use, when many blocks are being executed (many of which run into signals) within a single process, these processes stay around and can easily exhaust the process limit on some systems. This patch cleans them up by sending SIGKILL after information about the signal that was sent has been gathered.
2024-03-13Revert "Reland "[llvm-exegesis] Add thread IDs to subprocess memory names ↵Aiden Grossman1-5/+4
(#84451)"" This reverts commit 8003f553a01a9a2a7eb09fe07e88f1ba9ee7d3a7. This (and/or a related commit) was causing build failures on one of the buildbots that needs more investigation. More information is available at https://lab.llvm.org/buildbot/#/builders/178/builds/7015.
2024-03-13Revert "[llvm-exegesis] Use LLVM Support to get thread ID"Aiden Grossman1-1/+1
This reverts commit 1c3b15e9f5bc671e40bcf5d3475f5425466754ce. This (and/or) a related patch was causing build failures on one of the buildbots. More information is available at https://lab.llvm.org/buildbot/#/builders/178/builds/7015.
2024-03-12[llvm-exegesis] Use LLVM Support to get thread IDAiden Grossman1-1/+1
This patch switches from manually using the Linux syscall to get the current thread ID to using the relevant LLVM Support libraries that abstract over the low level system details.
2024-03-12Reland "[llvm-exegesis] Add thread IDs to subprocess memory names (#84451)"Aiden Grossman1-4/+5
This reverts commit aefad27096bba513f06162fac2763089578f3de4. This relands commit 6bbe8a296ee91754d423c59c35727eaa624f7140. This patch was casuing build failures on non-Linux platforms due to the default implementations for the functions not being updated. This ended up causing out-of-line definition errors. Fixed for the relanding.
2024-03-12Revert "[llvm-exegesis] Add thread IDs to subprocess memory names (#84451)"Florian Hahn1-5/+4
This reverts commit 6bbe8a296ee91754d423c59c35727eaa624f7140. This breaks building LLVM on macOS, failing with llvm/tools/llvm-exegesis/lib/SubprocessMemory.cpp:146:33: error: out-of-line definition of 'setupAuxiliaryMemoryInSubprocess' does not match any declaration in 'llvm::exegesis::SubprocessMemory' Expected<int> SubprocessMemory::setupAuxiliaryMemoryInSubprocess(
2024-03-12[llvm-exegesis] Add thread IDs to subprocess memory names (#84451)Aiden Grossman1-4/+5
This patch adds the thread ID to the subprocess memory shared memory names. This avoids conflicts for downstream consumers that might want to consume llvm-exegesis across multiple threads, which would otherwise run into conflicts due to the same PID running multiple instances.
2024-02-17[NFC][llvm-exegesis] Clean up BenchmarkRunner commentsAiden Grossman1-9/+10
There were a couple things in the comments of BenchmarkRunner.cpp (and maybe other files, I can't really remember) that were bugging me. This patch fixes a couple of minor issues specifically in BenchmarkRunner like typos and makes a couple instances more clear.
2024-02-01[llvm-exegesis] Replace --num-repetitions with --min-instructions (#77153)Aiden Grossman1-8/+8
This patch replaces --num-repetitions with --min-instructions to make it more clear that the value refers to the minimum number of instructions in the final assembled snippet rather than the number of repetitions of the snippet. This patch also refactors some llvm-exegesis internal variable names to reflect the name change. Fixes #76890.
2024-01-29[llvm-exegesis] Remove llvm prefix where unnecessary (#79802)Aiden Grossman1-10/+9
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-17/+69
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-19[tools] Use SmallString::operator std::string (NFC)Kazu Hirata1-1/+1
2024-01-16[llvm-exegesis] Fix snippet value scaling (#77226)Aiden Grossman1-3/+4
Currently, BenchmarkRunner scales the per snippet counters by multiplying the raw counter values by the number of instructions (casted to a double) divided by the minimum number of instructions. This is incorrect for the loop repetition mode for snippets that don't fit a whole number of times into the minimum instruction count. For example, with 3 instructions in the snippet and the minimum number of instructions set to 4, the loop repetitor will execute a total of six instructions, but BenchmarkRunner will scale the raw count by 3/4 instead of 3/6=1/2. This will also be incorrect for the duplicate snippet repetitor after #77224. This patch fixes this behavior by dividing the raw count by the ceiling of the number of repetitions divided by the instruction count.
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-05[llvm-exegesis] Remove unused Counter::read method (#76651)Aiden Grossman1-1/+5
This method was simply a wrapper around readOrError. All users within the llvm-exegesis code base should have been processing an actual error rather than using the wrapper. This patch removes the wrapper and rewrites the users (just 1) to use the readOrError method.
2024-01-03[NFC][llvm-exegesis] Remove redundant register initial values argumentAiden Grossman1-1/+0
This patch removes the redundant RegisterInitialValues parameter from assembleToStream and friends as it is included within the BenchmarkKey struct that is also passed to all the functions that need this information.
2023-12-26[NFC][llvm-exegesis] Refactor InstrBenchmark to BenchmarkResult (#76388)Aiden Grossman1-23/+25
This patch refactors InstrBenchmark to BenchmarkResult. Most of the renaming away from things prefixed with Instr was performed in a previous commit, but this specific instance was missed.
2023-12-15[llvm-exegesis] Validate that address annotations are aligned (#75554)Aiden Grossman1-0/+6
This patch adds in validation at two different levels that address annotations are page aligned. This is necessary as otherwise the mmap calls will fail as MAP_FIXED/MAP_FIXED_NOREPLACE require page aligned addresses. This happens silently in the subprocess. This patch adds validation at snippet parsing time to give feedback to the user and also adds asserts at code generation/address usage time to ensure that other users of the Exegesis APIs conform to the same requirements.
2023-12-14[llvm-exegesis] Refactor MMAP platform-specific preprocessor directives (#75422)Aiden Grossman1-7/+1
This patch refactors the MMAP platform-specific preprocessor directives in llvm-exegesis to a single file instead of having duplicate code split across multiple files. These originally got introduced to get buildbots green again due to platform specific failures.
2023-12-13[SystemZ][z/OS] Add missing strnlen function for z/OS to fix build failures ↵Abhina Sree1-0/+1
(#75339) This patch adds strnlen to the zOSSupport.h file to fix build failures in multiple files.
2023-12-11[llvm-exegesis] Use explicit error classes for different snippet crashes ↵Aiden Grossman1-11/+12
(#74210) This patch switches to using explicit snippet crashes that contain more information about the specific type of error (like the address for a segmentation fault) that occurred. All these new error classes inherit from SnippetExecutionFailure to allow for easily grabbing all of them in addition to filtering for specific types using the standard LLVM error primitives.
2023-12-08[llvm-exegesis]Allow clients to do their own snippet running error ha… ↵Clement Courbet1-10/+6
(#74711) …ndling. Returns an error *and* a benchmark rather than an error *or* a benchmark. This allows users to have custom error handling while still being able to inspect the benchmark. Apart from this small API change, this is an NFC. This is an alternative to #74211.
2023-12-07[llvm-exegesis] Add MAP_FIXED_NOREPLACE definitonAiden Grossman1-0/+7
MAP_FIXED_NOREPLACE doesn't exist on older kernels, so we need to define it to be MAP_FIXED.
2023-12-07Reland "[llvm-exegesis] Add in snippet address annotation (#74218)"Aiden Grossman1-2/+10
This reverts commit 30d700117b772d94d8474ec56bd6f9cc423fc613. This relands commit 3ab41f912a6c219a93b87c257139822ea07c8863. When I was updating the patch to use llvm::to_integer, I only ran the lit tests and didn't run the unit tests, one of which started to fail. This patch fixes the broken unit test.
2023-12-06Revert "[llvm-exegesis] Add in snippet address annotation (#74218)"Aiden Grossman1-10/+2
This reverts commit 3ab41f912a6c219a93b87c257139822ea07c8863. Unit tests break after recent changes. Will investigate/reland.
2023-12-06[llvm-exegesis] Add in snippet address annotation (#74218)Aiden Grossman1-2/+10
2023-12-05[llvm-exegesis] Remove unnecessary includes (NFC)Kazu Hirata1-1/+0
Identified with clangd.
2023-12-05[llvm-exegesis] Stop including array (NFC)Kazu Hirata1-1/+0
Identified with clangd.
2023-12-04[llvm-exegesis] Disable core dumps in subprocess (#74144)Aiden Grossman1-0/+14
Core dumps are currently enabled within the llvm-exegesis subprocess executor. This can create a lot of core dumps when going through different snippets that might segfault when experimenting with memory annotations. These core dumps are not really needed as the information about the segfault is reported directly to the user.
2023-11-24[llvm-exegesis] Refactor ExecutableFunction to use a named constructor (#72837)Aiden Grossman1-12/+45
This patch refactors ExecutableFunction to use a named constructor pattern, namely adding the create function, so that errors occurring during the creation of an ExecutableFunction can be propogated back up rather than having to deal with them in report_fatal_error.