Repository navigation
Description
#5501 prepares iree_hal_device_submit_and_wait and plumbs it down into iree_hal_task_queue_submit_and_wait:

There's two major things required to finish this work as intended: we need a wait_handle to pass to iree_task_executor_donate_caller derived from the submission signal semaphores and _donate_caller needs to actually be implemented.
The wait_handle can probably be obtained by acquiring a timepoint from the last signal semaphore of the last batch - though this may not be guaranteed by the API (maybe?) it's probably good enough to start. The advantage we have here is that all of this is strictly an optimization and if it returns a bit early that's fine.
Donation is a bit more involved but may require only minor trickery to setup a donated iree_task_worker_t with no backing thread that is used to process tasks. When the submit_and_wait issues its flush and calls iree_task_executor_coordinate this worker can be provided as current_worker to receive any immediately runnable tasks and then a pump loop similar to iree_task_worker_pump_until_exit can be used to drain the queues. This may take the form of a iree_task_worker_pump_until_ready(..., wait_handle, timeout).
The larger design question here is how much to share between the donated workers code path and the normal workers code path: if a simple loop try_steal_tasking work is enough then that may keep things much simpler at the cost of potential spurious thread wakeups. For example, if we flush and post work to another thread, request a wake of that thread, and then immediately steal the work from it the thread will have nothing todo once woken. This is likely still a win as overall latency will go way down and in anything but stupid simple programs (like ++i from HLO) the woken thread may already have more work waiting for it by the time it's ready also helping lower latency. The largest benefit would be avoiding the iree_task_post_batch_wake_workers that can take several us.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
benvanik commentedon Jun 22, 2022
Don't think we want this, given that it bypasses our controls and conflicts with multi-tenancy.