Skip to content

Conversation

NAThompson
Copy link
Contributor

No description provided.

@googlebot
Copy link

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!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot. The email used to register you as an authorized contributor must be the email used for the Git commit.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@NAThompson
Copy link
Contributor Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

Copy link
Member

@dmah42 dmah42 left a 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.

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,
Copy link
Member

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?

Copy link
Contributor Author

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 =
Copy link
Member

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.

void Benchmark::SetName(const char* name) { name_ = name; }

int Benchmark::ArgsCnt() const {
int64_t Benchmark::ArgsCnt() const {
Copy link
Member

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.

@AppVeyorBot
Copy link

Build benchmark 957 completed (commit 69b4d7718d by @NAThompson)

@NAThompson
Copy link
Contributor Author

Looks like the threads are passed to the AddRange function:

benchmark/src/benchmark_register.cc:432:12: error: cannot initialize a parameter of type 'std::vector<int64_t> *'
      (aka 'vector<long long> *') with an rvalue of type 'std::vector<int> *'
  AddRange(&thread_counts_, min_threads, max_threads, 2);
           ^~~~~~~~~~~~~~~
benchmark/src/benchmark_register.cc:247:48: note: passing argument to parameter 'dst' here
void Benchmark::AddRange(std::vector<int64_t>* dst, int64_t lo, int64_t hi, int64_t mult)

So the type of the threads looks like it must be the same as the type as the argument to the AddRange, or the AddRange function must be templated on an integer. Do you have a preference?

(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.)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 86.985% when pulling 8d180bb on NAThompson:master into 9f5694c on google:master.

@dmah42
Copy link
Member

dmah42 commented Jan 17, 2018

Oh right: Enthusiastic reuse of code.

Templating AddRange on integer sgtm, given it's a generic utility function.

std::string error_message;

int64_t iterations;
int iterations;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this change?

Copy link
Contributor Author

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) {}
Copy link
Contributor

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_;
Copy link
Contributor

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.

// 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;
Copy link
Contributor

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?

Copy link
Member

@dmah42 dmah42 left a 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.

std::string error_message;

int64_t iterations;
int iterations;
Copy link
Member

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;
Copy link
Member

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

return ss.str();
}

std::string FormatKV(std::string const& key, int value) {
Copy link
Member

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?

Copy link
Contributor Author

@NAThompson NAThompson Jan 17, 2018

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.

Copy link
Contributor Author

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.

// 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int64_t


static void BM_CalculatePi(benchmark::State& state) {
static const int depth = 1024;
static const int64_t depth = 1024;
Copy link
Member

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 :)

@AppVeyorBot
Copy link

Build benchmark 958 failed (commit 2a02f88a1d by @NAThompson)

@AppVeyorBot
Copy link

Build benchmark 959 failed (commit ab7f5f972b by @NAThompson)

@AppVeyorBot
Copy link

Build benchmark 960 failed (commit 15ee0134b3 by @NAThompson)

@dmah42
Copy link
Member

dmah42 commented Jan 17, 2018

works for me once tests pass and @pleroy and @EricWF have weighed in.

i think there's a broader approach here to templatize range args but i may try that after this lands to see if it works out.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.926% when pulling d5f07bf on NAThompson:master into 9f5694c on google:master.

@AppVeyorBot
Copy link

Build benchmark 961 failed (commit ebba6ca394 by @NAThompson)

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.926% when pulling 9dcdd39 on NAThompson:master into 9f5694c on google:master.

@dmah42
Copy link
Member

dmah42 commented May 29, 2018

I think this PR has been obsoleted by other changes.

@dmah42 dmah42 closed this May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants