-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Use int64_t throughout to facilitate probing larger inputs. #517
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). 📝 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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure we need more than 2^32 threads, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you doing the reverse here, and changing an int64_t
into an int?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with where this is going. I believe @pleroy has expressed concern about putting 64-bit stuff into 32-bit runs, so i'd like their thoughts. I think in this case it's justified.
include/benchmark/benchmark.h
Outdated
std::string error_message; | ||
|
||
int64_t iterations; | ||
int iterations; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.. keep as int64_t
src/json_reporter.cc
Outdated
return ss.str(); | ||
} | ||
|
||
std::string FormatKV(std::string const& key, int value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixed a build error. Now either type will work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int64_t
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.