|
Uni20
Asynchronous tensor and runtime library.
|
Scheduler interface for initial AsyncTask submission and host-side progress.
More...
#include <scheduler.hpp>
Classes | |
| struct | WaitRequest |
| Readiness predicate and optional targeted wakeup registration for a blocking wait. More... | |
Public Types | |
| using | WaitPredicate = std::function< bool()> |
| using | WaitWakeup = std::function< void()> |
| using | WaitWakeupRegistration = std::function< void(WaitWakeup)> |
Public Member Functions | |
| template<class Function > requires std::invocable<Function&, std::size_t> | |
| void | execute_batch (std::size_t size, Function &&function) |
| Execute a synchronous batch of independent lightweight work items. | |
| virtual void | help_while_waiting (const WaitPredicate &is_ready) |
| Allow a scheduler to advance queued work while a thread is blocking. | |
| virtual void | pause ()=0 |
| Pause the scheduler. | |
| virtual void | resume ()=0 |
| Resume the scheduler. | |
| virtual void | schedule (AsyncTask &&task)=0 |
| Schedule a coroutine for its initial execution. | |
| virtual void | wait_for (const WaitPredicate &is_ready) |
Block the calling thread until is_ready returns true. | |
| virtual void | wait_for (WaitRequest const &request) |
| Block until a structured wait request becomes ready. | |
| ~IAsyncScheduler () override=default | |
| Virtual destructor. | |
Public Member Functions inherited from uni20::async::IScheduler | |
| virtual | ~IScheduler ()=default |
| Virtual destructor. | |
Scheduler interface for initial AsyncTask submission and host-side progress.
| using uni20::async::IAsyncScheduler::WaitPredicate = std::function<bool()> |
| using uni20::async::IAsyncScheduler::WaitWakeup = std::function<void()> |
| using uni20::async::IAsyncScheduler::WaitWakeupRegistration = std::function<void(WaitWakeup)> |
|
overridedefault |
Virtual destructor.
|
inline |
Execute a synchronous batch of independent lightweight work items.
On successful return, the callable has been invoked exactly once for every index in [0, size). Implementations may invoke items concurrently. If an item throws, unfinished items may be cancelled; the exception is rethrown after participating work has joined. The callable is borrowed only for this call.
Batch items are ordinary functions, not coroutine tasks. They may use scheduler APIs, including nested get_wait(), but the batch itself creates no epoch or dependency relationship.
| Function | Callable accepting one std::size_t index. |
| size | Number of work items. |
| function | Work-item callable. |
|
inlinevirtual |
Allow a scheduler to advance queued work while a thread is blocking.
Blocking waits (e.g., Async<T>::get_wait()) call this hook to cooperatively drive progress on the owning scheduler until is_ready() reports completion. The default implementation simply yields the calling thread until the predicate succeeds, which is suitable for schedulers that rely on dedicated worker threads.
Reimplemented in uni20::async::DebugScheduler, and uni20::async::TbbScheduler.
|
pure virtual |
Pause the scheduler.
Tasks can still be scheduled, but they will not start running until resume() is called
Implemented in uni20::async::DebugScheduler, uni20::async::TbbNumaScheduler, and uni20::async::TbbScheduler.
|
pure virtual |
Resume the scheduler.
Tasks scheduled while paused can start running, as can newly scheduled tasks.
Implemented in uni20::async::DebugScheduler, uni20::async::TbbNumaScheduler, and uni20::async::TbbScheduler.
|
pure virtual |
Schedule a coroutine for its initial execution.
| task | Task to bind to this scheduler and submit. |
Implemented in uni20::async::TbbCudaScheduler, uni20::async::TbbScheduler, uni20::async::DebugCudaScheduler, uni20::async::DebugScheduler, and uni20::async::TbbNumaScheduler.
|
inlinevirtual |
Block the calling thread until is_ready returns true.
Implementations may override this to provide scheduler-specific waiting semantics (e.g., parking on a condition variable). The default implementation repeatedly invokes help_while_waiting until the predicate succeeds.
Reimplemented in uni20::async::TbbScheduler.
|
inlinevirtual |
Block until a structured wait request becomes ready.
| request | Readiness predicate and optional targeted notification registration. |
The default implementation preserves compatibility with schedulers that advance work by polling the readiness predicate. Schedulers with a suspend/resume mechanism can override this overload and register the supplied wakeup callback.
Reimplemented in uni20::async::TbbScheduler.