-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix CPU frequency estimation on riscv #1549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
https://github.com/google/benchmark/actions/runs/4217605263/jobs/7332317281#step:6:24 .. looks like a bit cleverer #defines are needed to avoid the lambda capture that's unnecessary. |
It has been resolved. It looks like only clang++ complains about this. By the way, I think clang is actually used for the workflow |
looks good.. just that one thing i'd like you to move back please, then check CI, then i can merge it :) |
I think |
sure. if they're unused let's do that. i'll wait :) |
thank you! |
--- Manual changes: --- 1) Updated version of google_benchmark to fix windows compile error. New range: https://chromium.googlesource.com/external/github.com/google/benchmark/+log/e8baf26..b177433 2) Remove unused sleep.[cc|h] from BUILD.gn. (Removed here: google/benchmark#1549) 3) Fix deprecation warnings (treated as errors) in allocation_perf.cc. benchmark::DoNotOptimize has deprecated overloads due to google/benchmark#1493. Bug: 1425054 --- Original message generated by autoroll: --- Rolling v8/third_party/google_benchmark/src: https://chromium.googlesource.com/external/github.com/google/benchmark/+log/e8baf26..efc89f0 link to benchmark directly for tests that aren't link_main_test (#1576) (dominic) https://chromium.googlesource.com/external/github.com/google/benchmark/+/efc89f0 Convert uses of `const char*` to `std::string` (#1567) (dominic) https://chromium.googlesource.com/external/github.com/google/benchmark/+/46d3c84 add '@' to correctly reference build file for libpfm (#1575) (dominic) https://chromium.googlesource.com/external/github.com/google/benchmark/+/68aa190 Address warnings on NVIDIA nvc++ (#1573) (Henrique Bucher) https://chromium.googlesource.com/external/github.com/google/benchmark/+/9f7dc38 simplify setting C++ standard (Dominic Hamon) https://chromium.googlesource.com/external/github.com/google/benchmark/+/1b507cb [FR] Provide public accessors to benchmark name and arguments #1551 (#1563) (Mike Apodaca) https://chromium.googlesource.com/external/github.com/google/benchmark/+/f32748c use std::string for skip messages (#1571) (dominic) https://chromium.googlesource.com/external/github.com/google/benchmark/+/060d762 [FR] state.SkipWithMessage #963 (#1564) (Mike Apodaca) https://chromium.googlesource.com/external/github.com/google/benchmark/+/adb0d3d ... Change-Id: I69218b84b88fb1da25e740d7fb623528d526b85b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4429376 Reviewed-by: Toon Verwaest <[email protected]> Commit-Queue: Matthias Liedtke <[email protected]> Cr-Commit-Position: refs/heads/main@{#87139}
I used to run llvm-test-suite on the riscv64 platform, but I found that the CPU frequency given by the benchmark framework was incorrect. Unfortunately, neither the
cpufreq
interface norBogoMIPS
is implemented on the linux-riscv64 platform, it just usesrdcycle
andnanosleep
to estimate CPU frequency.However, cycle counters are per-core on RISC-V, and what “sleep” means is also not standardized by the RISC-V specifications.
On my machine, calling
nanosleep
doesn't work because the cycle counter doesn't increase during sleeping. Furthermore, it does not prevent thread migration during timing.Please also refer to riscv/riscv-isa-manual#140 and the RISC-V Instruction Set Manual.
I use the pseudo-random number generator given by
<random>
instead of callingSleepForMilliseconds
as the load and temporarily pin the current thread to a core during timing. This patch works fine on my machine.It has been tested on the following platforms:
If it is OK, I can also drop bogoMIPS and just use the estimation to close #312.
Since
SleepForMilliseconds
is no longer used,sleep.h
andsleep.cc
can be removed from the framework.