-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add support for other multi-threading APIs #1667
base: main
Are you sure you want to change the base?
Conversation
Fork update
Support the benchmarking of code, which relies on other multi-threading APIs, e.g. OpenMP.
This is a follow-up to PR #1027 |
I guess i will need to review this. It's unfortunate that so much time has passed |
a usual State object instead of copying it. This fixes a bug, which otherwise happens, if one thread has already finished the benchmark loop and merged its results to the parent state, while another one hasn't started yet.
Support the benchmarking of code, which relies on other multi-threading APIs, e.g. OpenMP.
a usual State object instead of copying it. This fixes a bug, which otherwise happens, if one thread has already finished the benchmark loop and merged its results to the parent state, while another one hasn't started yet.
… into threadingapi_2
Any chance to get a review on this soon? Do I have to do something before you start? The issues I still have in the CI runners don't seem to be related to my additions. |
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 guess i will need to review this. It's unfortunate that so much time has passed since the previous attempt, i basically do not recall what specific issues i had there.
Any chance to get a review on this soon?
Wouldn't that be nice :(
Do I have to do something before you start?
No.
// Don't create threads. Let the user evaluate state.threads and/or use | ||
// ThreadState. | ||
Benchmark* ManualThreading() { |
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 presumably should assert that thread_counts_
is empty.
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.
It is actually fine to have a non-empty thread_counts_
. In that case the benchmark is executed with each thread count and the user is responsible for creating the appropriate number of threads. The first two examples in the user guide use this combination. Later src/benchmark_runner.cc:140 checks, if the thread count and the number of ThreadState
created match.
@@ -1274,6 +1296,13 @@ class BENCHMARK_EXPORT Benchmark { | |||
// Equivalent to ThreadRange(NumCPUs(), NumCPUs()) | |||
Benchmark* ThreadPerCpu(); |
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.
These all should probably assert !manual_threading_
.
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.
As said above, it is fine to combine these functions with manual threading.
@@ -66,6 +69,9 @@ class BenchmarkInstance { | |||
double min_warmup_time_; | |||
IterationCount iterations_; | |||
int threads_; // Number of concurrent threads to us | |||
bool manual_threading_; | |||
bool explicit_threading_; // true: Number of threads come from a Threads() | |||
// call |
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 haven't fully looked at things, but preliminary, i don't really like the names chosen.
and "Improve thread sanitzer statements"
Support the benchmarking of code, which relies on other multi-threading APIs, e.g. OpenMP.
… into threadingapi_2
Support the benchmarking of code, which relies on other multi-threading APIs, e.g. OpenMP.