Halide icon indicating copy to clipboard operation
Halide copied to clipboard

Extend fork_async_producers to support functions scheduled with compute_with

Open vksnk opened this issue 4 years ago • 4 comments

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.

vksnk avatar Aug 19 '20 05:08 vksnk

Monday review ping.

vksnk avatar Aug 31 '20 16:08 vksnk

Is this just awaiting review?

steven-johnson avatar Sep 24 '20 20:09 steven-johnson

Where does this PR stand?

steven-johnson avatar Oct 22 '20 16:10 steven-johnson

Yes, waiting for review.

vksnk avatar Oct 22 '20 17:10 vksnk