-
Notifications
You must be signed in to change notification settings - Fork 13.9k
[libc++] Optimize ranges::{for_each, for_each_n} for segmented iterators #132896
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
Open
winner245
wants to merge
12
commits into
llvm:main
Choose a base branch
from
winner245:for-each-segment
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a5148ec
Optimize ranges::{for_each, for_each_n} for segmented iterators
winner245 90c826b
Address ldionne's review comments
winner245 fae4de0
Fix test and ADL call
winner245 37d68a3
Make for_each segmented iterator optimization valid for C++03
winner245 2a83548
Allow transitive include of <optional> in affected headers
winner245 5cc4af8
Remove unnecessary _AlgoPolicy template parameter
winner245 b74e188
Apply optimization for join_view segmented iterators
winner245 1f7ad34
Consistently extend segmented iterator optimization to ranges::for_each
winner245 ca54b95
Fix review comments
winner245 100521b
Fix invoke call by using std::__invoke
winner245 05161a1
Refactor to simplify logic of for_each_n_segment.h
winner245 18bf207
Address ldionne's comments
winner245 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
int main(int argc, char** argv) { | ||
auto std_for_each_n = [](auto first, auto n, auto f) { return std::for_each_n(first, n, f); }; | ||
|
||
// std::for_each_n | ||
// {std,ranges}::for_each_n | ||
{ | ||
auto bm = []<class Container>(std::string name, auto for_each_n) { | ||
using ElemType = typename Container::value_type; | ||
|
@@ -41,19 +41,17 @@ int main(int argc, char** argv) { | |
->Arg(8) | ||
->Arg(32) | ||
->Arg(50) // non power-of-two | ||
->Arg(1024) | ||
->Arg(4096) | ||
->Arg(8192) | ||
->Arg(1 << 14) | ||
->Arg(1 << 16) | ||
->Arg(1 << 18); | ||
->Arg(8192); | ||
}; | ||
bm.operator()<std::vector<int>>("std::for_each_n(vector<int>)", std_for_each_n); | ||
bm.operator()<std::deque<int>>("std::for_each_n(deque<int>)", std_for_each_n); | ||
bm.operator()<std::list<int>>("std::for_each_n(list<int>)", std_for_each_n); | ||
bm.operator()<std::vector<int>>("rng::for_each_n(vector<int>)", std::ranges::for_each_n); | ||
Comment on lines
48
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use the same numbers as for the |
||
bm.operator()<std::deque<int>>("rng::for_each_n(deque<int>)", std::ranges::for_each_n); | ||
bm.operator()<std::list<int>>("rng::for_each_n(list<int>)", std::ranges::for_each_n); | ||
} | ||
|
||
// std::for_each_n for join_view | ||
// {std,ranges}::for_each_n for join_view | ||
{ | ||
auto bm = []<class Container>(std::string name, auto for_each_n) { | ||
using C1 = typename Container::value_type; | ||
|
@@ -81,14 +79,11 @@ int main(int argc, char** argv) { | |
->Arg(8) | ||
->Arg(32) | ||
->Arg(50) // non power-of-two | ||
->Arg(1024) | ||
->Arg(4096) | ||
->Arg(8192) | ||
->Arg(1 << 14) | ||
->Arg(1 << 16) | ||
->Arg(1 << 18); | ||
->Arg(8192); | ||
}; | ||
bm.operator()<std::vector<std::vector<int>>>("std::for_each_n(join_view(vector<vector<int>>))", std_for_each_n); | ||
bm.operator()<std::vector<std::vector<int>>>( | ||
"rng::for_each_n(join_view(vector<vector<int>>)", std::ranges::for_each_n); | ||
} | ||
|
||
benchmark::Initialize(&argc, argv); | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.