-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Optimize std::vector<:ghost:> copy algorithms #2461
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
a37cddd
to
4376f0e
Compare
4376f0e
to
170e1ee
Compare
static random_device rd; | ||
static mt19937 gen{random_device{}()}; | ||
vector<bool> result(size); | ||
generate_n(result.begin(), size, []() { return bernoulli_distribution{0.5}(gen); }); |
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.
unnecessary ()
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 am not sure, I thought that this is only C++20 and I would want to be able to run the tests in earlier standard modes too
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 has been there since lambdas introduction: https://godbolt.org/z/7cnWEMa6G
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 we remove ()
here we should on line 17 in the previous file as well.
} | ||
|
||
template <class _VbIt, class _OutIt> | ||
_CONSTEXPR20 _OutIt _Copy_vbool(_VbIt _First, _VbIt _Last, _OutIt _Dest) { |
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 questioning having this in the header, created #2462
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 am wondering whether we should make them static methods inside of vector itself
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 think method vs free function and in fully header / mostly in .cpp are orthogonal questions.
I have no opinion on method vs free function.
41ddca0
to
5b6cd2b
Compare
Can someone tell me whats wrong with the standard library header units? |
Urgh looks like it is concerned about unreachable code because we always return for vbool |
A benchmark to consider to add when this is merged: #804 (comment) |
I didn't know 👻 was a valid type name in C++... |
It's the spooky |
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.
Partial review
README.md
Outdated
[documentation](https://github.com/google/benchmark/blob/main/docs/user_guide.md#running-a-subset-of-benchmarks)) | ||
|
||
Right now the tests depend on an externally installed benchmark library. This can be done via `vcpkg install benchmark`. | ||
However, it has the drawback that it is not possible to benchmark code that links into the libraries provided by the |
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 "has the drawback"? Does "it is not possible to benchmark code that links into the libraries" mean that benchmarks can only use core headers? If so, we need to provide more explanation. If not, we need to clarify what it's trying to say.
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 dropped that whole sentence because i actually never really tried
static random_device rd; | ||
static mt19937 gen{random_device{}()}; | ||
vector<bool> result(size); | ||
generate_n(result.begin(), size, []() { return bernoulli_distribution{0.5}(gen); }); |
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 we remove ()
here we should on line 17 in the previous file as well.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: Casey Carter <[email protected]>
Note I left the whole vector bool tests disabled for EDG because it internally relies on vector which essentially breaks all the tests |
There's a merge conflict with |
Assigning myself to help merge the benchmarks into the fancy benchmarking stuff added in #2780 |
@miscco any interest in reviving this PR as of right now? Or should I mark draft? |
There is definitely interest, but no time. I just started a new job and we are moving later this month. So I would not expect any work this month |
Alright! I heard about your new job, good luck with that!!! I'm really happy for you 😁, and also good luck with moving! I'll mark as draft for now; please ping me on the discord once you're ready to work on it again 😃 |
I wonder whether rotation (used in #3021) should be similarly optimized... |
We talked about this at the weekly maintainer meeting (first of the new year! 😸). While we remain interested in optimizing algorithms for |
This adds optimizations for std::vector<:ghost:> to make it a bit more useful.
I also added a new subproject for benchmarks. I tried to make it as clean as possible but my CMake skills are limited.
There is one big wrinkle regarding benchmarks in that I currently use an installed version of
benchmark
. I am not sure if it is possible to link against our produced libraries without any linker errors. As I am currently using header only code I postponed adding benchmark as a subproject for another time.I only added the x64-Release target for now and will wait until there is a decision on how to name things before adding other targets.
For posterity, I also did some experimentations around using lit for generating and running the benchmarks. But the result was really ugly and also a bit unwieldly as I was not able to make it print out the results of a passed test.
I am also not sure whether there is really value added in testing different standard modes. However, clang vs MSVC would definitely be worthwile