Use int64_t throughout to facilitate probing larger inputs.#517
Use int64_t throughout to facilitate probing larger inputs.#517NAThompson wants to merge 5 commits intogoogle:masterfrom NAThompson:master
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). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
|
I signed it! |
|
CLAs look good, thanks! |
dmah42
left a comment
There was a problem hiding this comment.
There is a cost to forcing int64_t on 32-bit platforms. As such, let's keep this just to where it's necessary. From your issue report that seems to be in defining ranges.
include/benchmark/benchmark.h
Outdated
| State(size_t max_iters, const std::vector<int>& ranges, int thread_i, | ||
| int n_threads, internal::ThreadTimer* timer, | ||
| State(size_t max_iters, const std::vector<int64_t>& ranges, int64_t thread_i, | ||
| int64_t n_threads, internal::ThreadTimer* timer, |
There was a problem hiding this comment.
i'm not sure we need more than 2^32 threads, do we?
There was a problem hiding this comment.
I got a bunch of compiler warnings while only changing the Range arguments. But yes it is ridiculous to have 64-bit threadcounts.
src/benchmark.cc
Outdated
| std::unique_ptr<internal::ThreadManager> manager; | ||
| std::vector<std::thread> pool(b.threads - 1); | ||
| const int repeats = | ||
| const int64_t repeats = |
There was a problem hiding this comment.
repetitions certainly shouldn't head north of 2^32.
src/benchmark_register.cc
Outdated
| void Benchmark::SetName(const char* name) { name_ = name; } | ||
|
|
||
| int Benchmark::ArgsCnt() const { | ||
| int64_t Benchmark::ArgsCnt() const { |
There was a problem hiding this comment.
also here: if someone is passing this many args around we're in trouble.
|
✅ Build benchmark 957 completed (commit 69b4d7718d by @NAThompson) |
|
Looks like the threads are passed to the So the type of the threads looks like it must be the same as the type as the argument to the (The other alternative-that my mental model of this code is unsophisticated and I've totally missed the point-is of course the most likely possibility.) |
|
Oh right: Enthusiastic reuse of code. Templating AddRange on integer sgtm, given it's a generic utility function. |
…tions to integers.
include/benchmark/benchmark.h
Outdated
| std::string error_message; | ||
|
|
||
| int64_t iterations; | ||
| int iterations; |
There was a problem hiding this comment.
I figured the iteration count wouldn't go past 4 billion. It reverts the previous change, which is admittedly annoying.
src/mutex.h
Outdated
| class Barrier { | ||
| public: | ||
| Barrier(int num_threads) : running_threads_(num_threads) {} | ||
| Barrier(int64_t num_threads) : running_threads_(num_threads) {} |
There was a problem hiding this comment.
We're never going to have more than 4 billion threads.
src/mutex.h
Outdated
| Mutex lock_; | ||
| Condition phase_condition_; | ||
| int running_threads_; | ||
| int64_t running_threads_; |
There was a problem hiding this comment.
All these changes for thread counts seem unneeded.
src/statistics.cc
Outdated
| // All repetitions should be run with the same number of iterations so we | ||
| // can take this information from the first benchmark. | ||
| int64_t const run_iterations = reports.front().iterations; | ||
| int const run_iterations = reports.front().iterations; |
There was a problem hiding this comment.
Why are you doing the reverse here, and changing an int64_t into an int?
include/benchmark/benchmark.h
Outdated
| std::string error_message; | ||
|
|
||
| int64_t iterations; | ||
| int iterations; |
There was a problem hiding this comment.
this was int64_t before and probably still should be.
src/benchmark.cc
Outdated
| report.report_label = results.report_label_; | ||
| // Report the total iterations across all threads. | ||
| report.iterations = static_cast<int64_t>(iters) * b.threads; | ||
| report.iterations = static_cast<int>(iters) * b.threads; |
src/json_reporter.cc
Outdated
| return ss.str(); | ||
| } | ||
|
|
||
| std::string FormatKV(std::string const& key, int value) { |
There was a problem hiding this comment.
if this is for outputting the args (which i don't think we do other than as part of the name) then it should be int64_t value, right?
There was a problem hiding this comment.
This fixed a build error. Now either type will work.
There was a problem hiding this comment.
J/K, that error went away once I made your other suggested changes.
src/statistics.cc
Outdated
| // All repetitions should be run with the same number of iterations so we | ||
| // can take this information from the first benchmark. | ||
| int64_t const run_iterations = reports.front().iterations; | ||
| int const run_iterations = reports.front().iterations; |
test/benchmark_test.cc
Outdated
|
|
||
| static void BM_CalculatePi(benchmark::State& state) { | ||
| static const int depth = 1024; | ||
| static const int64_t depth = 1024; |
There was a problem hiding this comment.
definitely doesn't need to be updated :)
|
❌ Build benchmark 958 failed (commit 2a02f88a1d by @NAThompson) |
|
❌ Build benchmark 959 failed (commit ab7f5f972b by @NAThompson) |
|
❌ Build benchmark 960 failed (commit 15ee0134b3 by @NAThompson) |
|
❌ Build benchmark 961 failed (commit ebba6ca394 by @NAThompson) |
|
I think this PR has been obsoleted by other changes. |
No description provided.