halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.91k stars 1.07k forks source link

Backport reverse_view to clean up some code #8486

Closed alexreinking closed 2 days ago

alexreinking commented 3 days ago

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 commented 3 days ago

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

alexreinking commented 3 days ago

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

abadams commented 3 days ago

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

alexreinking commented 3 days ago

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 commented 3 days ago

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

alexreinking commented 2 days ago

Vulkan failures are unrelated