Halide
Halide copied to clipboard
Extend fork_async_producers to support functions scheduled with compute_with
As described in #5179 compute_with() and async() have issues when used together and this PR extends ForkAsyncProducers to support fused function groups to address these issues.
The important limitation is that all functions from the same group have to be marked as async and will share fork block/task/thread. I think this is the only reasonable combination, because functions scheduled with compute_with share the loop(s) and launching them in different task would break this assumption.
(interesting side-effect of this is that now it's possible to schedule two completely independent functions to be executed in the same fork block with something like:
producer1.async();
producer2.compute_with(producer1, Var::outermost()).async();
).
I've added a number of tests which cover some of the possible combinations, but for something like async which depends on things like timing and such, it's quite difficult to be 100% convinced about correctness. For the existing functionality, I've tried to minimize changes to make sure that stuff that worked before still works. Also, I've eyeballed generated IR to make sure that forks and semaphores are generated in proper places and it looked alright.
Monday review ping.
Is this just awaiting review?
Where does this PR stand?
Yes, waiting for review.