Skip to content
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

Backport reverse_view to clean up some code #8486

Merged
merged 3 commits into from
Nov 23, 2024
Merged

Backport reverse_view to clean up some code #8486

merged 3 commits into from
Nov 23, 2024

Conversation

alexreinking
Copy link
Member

I found it very useful to backport reverse_view from C++20 for the sake of writing readable backwards loops. Here, I add reverse_view to Util.h. This allows us to simplify code in a lot of places.

@steven-johnson
Copy link
Contributor

Side note: we should (again) examine if we can move to C++20 for Halide 20. (Google has been at C++20 for a while now. Are there still blockers at Adobe?)

Copy link
Contributor

@steven-johnson steven-johnson left a comment

Choose a reason for hiding this comment

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

LGTM pending green

src/BoundsInference.cpp Outdated Show resolved Hide resolved
if (it->is_fuse()) {
if (parallel.count(it->inner) || parallel.count(it->outer)) {
parallel.insert(it->old_var);
for (const auto &split : sched.splits()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This one is meant to be forward.

@alexreinking
Copy link
Member Author

@abadams -- thanks for catching that! I went over all the other loops and they all have reverse_view, as they should.

@abadams
Copy link
Member

abadams commented Nov 22, 2024

Nice cleanup. How complete is it? Did you already grep for all the rbegins/rends, or are there potentially more opportunities?

@alexreinking
Copy link
Member Author

Nice cleanup. How complete is it? Did you already grep for all the rbegins/rends, or are there potentially more opportunities?

I grepped for size_t and int counter loop variables that had a - 1 or a >= 0 somewhere in there, too. I didn't try to convert loops that had peeled a first iteration.

I should look for rbegin/rend.

@abadams
Copy link
Member

abadams commented Nov 22, 2024

I made it through the new commit and didn't spot any issues.

@alexreinking alexreinking added the code_cleanup No functional changes. Reformatting, reorganizing, or refactoring existing code. label Nov 22, 2024
@alexreinking
Copy link
Member Author

Vulkan failures are unrelated

@alexreinking alexreinking merged commit 922e469 into main Nov 23, 2024
16 of 19 checks passed
@alexreinking alexreinking deleted the reverse-view branch November 23, 2024 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code_cleanup No functional changes. Reformatting, reorganizing, or refactoring existing code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants