Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Friends | List of all members
uni20::async::TbbScheduler Class Reference

#include <tbb_scheduler.hpp>

Inheritance diagram for uni20::async::TbbScheduler:
[legend]
Collaboration diagram for uni20::async::TbbScheduler:
[legend]

Public Member Functions

void help_while_waiting (const WaitPredicate &is_ready) override
 Allow a scheduler to advance queued work while a thread is blocking.
 
void pause () override
 Pause the scheduler. Don't execute scheduled tasks, but instead add them to a queue.
 
void resume () override
 Unpause the scheduler, and execute any tasks that have been queued.
 
void run_all ()
 Block until all tasks scheduled on this scheduler are complete.
 
void schedule (AsyncTask &&t) override
 Schedule a coroutine for initial execution.
 
 TbbScheduler (int max_concurrency=oneapi::tbb::task_arena::automatic, TbbSchedulerBatchOptions batch_options={})
 Construct a TBB scheduler with a given arena concurrency.
 
 TbbScheduler (oneapi::tbb::task_arena::constraints constraints, TbbSchedulerBatchOptions batch_options={})
 Construct a TBB scheduler constrained to a specific NUMA node.
 
void wait_for (const WaitPredicate &is_ready) override
 Accept an already-satisfied predicate; pending TBB waits require a WaitRequest notification.
 
void wait_for (WaitRequest const &request) override
 Wait for targeted readiness while allowing the arena to execute other work.
 
 ~TbbScheduler () noexcept override
 
- Public Member Functions inherited from uni20::async::IAsyncScheduler
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.
 
 ~IAsyncScheduler () override=default
 Virtual destructor.
 
- Public Member Functions inherited from uni20::async::IScheduler
virtual ~IScheduler ()=default
 Virtual destructor.
 

Protected Member Functions

virtual void dispatch_handle (TaskHandle handle)
 Route one runnable task activation to its execution arena.
 
template<typename Prepare >
void dispatch_handle_in_arena (oneapi::tbb::task_arena &arena, TaskHandle handle, detail::TbbTaskAdmissionContext context, Prepare &&prepare)
 Submit one activation to an arena through the shared task group.
 
void enqueue_task (BasicTask &&t)
 Enqueue one task through the scheduler's domain-routing hook.
 
void wait_for_submitted_tasks ()
 Wait for every activation registered with the shared task group.
 

Friends

class TbbNumaScheduler
 

Additional Inherited Members

- Public Types inherited from uni20::async::IAsyncScheduler
using WaitPredicate = std::function< bool()>
 
using WaitWakeup = std::function< void()>
 
using WaitWakeupRegistration = std::function< void(WaitWakeup)>
 

Constructor & Destructor Documentation

◆ TbbScheduler() [1/2]

uni20::async::TbbScheduler::TbbScheduler ( int  max_concurrency = oneapi::tbb::task_arena::automatic,
TbbSchedulerBatchOptions  batch_options = {} 
)
inlineexplicit

Construct a TBB scheduler with a given arena concurrency.

Parameters
max_concurrencyMaximum arena participation, including application threads. Use task_arena::automatic for the oneTBB default.
batch_optionsLightweight-batch concurrency policy.
Note
Explicit concurrency one shares its sole slot between application and worker threads; reserving that slot would let oneTBB add a second participant for enqueued work.

◆ TbbScheduler() [2/2]

uni20::async::TbbScheduler::TbbScheduler ( oneapi::tbb::task_arena::constraints  constraints,
TbbSchedulerBatchOptions  batch_options = {} 
)
inlineexplicit

Construct a TBB scheduler constrained to a specific NUMA node.

Parameters
constraintsBinding constraints applied to the underlying arena.
batch_optionsLightweight-batch concurrency policy.

◆ ~TbbScheduler()

uni20::async::TbbScheduler::~TbbScheduler ( )
inlineoverridenoexcept

Member Function Documentation

◆ dispatch_handle()

virtual void uni20::async::TbbScheduler::dispatch_handle ( TaskHandle  handle)
inlineprotectedvirtual

Route one runnable task activation to its execution arena.

◆ dispatch_handle_in_arena()

template<typename Prepare >
void uni20::async::TbbScheduler::dispatch_handle_in_arena ( oneapi::tbb::task_arena &  arena,
TaskHandle  handle,
detail::TbbTaskAdmissionContext  context,
Prepare &&  prepare 
)
inlineprotected

Submit one activation to an arena through the shared task group.

Template Parameters
Preparecallable that establishes or verifies the arena execution context.
Parameters
arenaArena that will execute the activation.
handlePromise-neutral task identity.
contextDiagnostic context for admission failure.
prepareCallable invoked immediately before coroutine resumption.

◆ enqueue_task()

void uni20::async::TbbScheduler::enqueue_task ( BasicTask &&  t)
inlineprotected

Enqueue one task through the scheduler's domain-routing hook.

◆ help_while_waiting()

void uni20::async::TbbScheduler::help_while_waiting ( const WaitPredicate &  is_ready)
inlineoverridevirtual

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 from uni20::async::IAsyncScheduler.

◆ pause()

void uni20::async::TbbScheduler::pause ( )
inlineoverridevirtual

Pause the scheduler. Don't execute scheduled tasks, but instead add them to a queue.

Implements uni20::async::IAsyncScheduler.

◆ resume()

void uni20::async::TbbScheduler::resume ( )
inlineoverridevirtual

Unpause the scheduler, and execute any tasks that have been queued.

Implements uni20::async::IAsyncScheduler.

◆ run_all()

void uni20::async::TbbScheduler::run_all ( )
inline

Block until all tasks scheduled on this scheduler are complete.

Note
This guarantees quiescence with respect to tasks that were scheduled on this TbbScheduler. Tasks blocked on external events (I/O, MPI, etc.) may still be logically alive and will resume later if rescheduled.

◆ schedule()

void uni20::async::TbbScheduler::schedule ( AsyncTask &&  t)
inlineoverridevirtual

Schedule a coroutine for initial execution.

Implements uni20::async::IAsyncScheduler.

◆ wait_for() [1/2]

void uni20::async::TbbScheduler::wait_for ( const WaitPredicate &  is_ready)
inlineoverridevirtual

Accept an already-satisfied predicate; pending TBB waits require a WaitRequest notification.

Reimplemented from uni20::async::IAsyncScheduler.

◆ wait_for() [2/2]

void uni20::async::TbbScheduler::wait_for ( WaitRequest const &  request)
inlineoverridevirtual

Wait for targeted readiness while allowing the arena to execute other work.

Parameters
requestReadiness predicate and race-safe wakeup registration.
Exceptions
async_state_errorif a pending request has no notification registration.

Reimplemented from uni20::async::IAsyncScheduler.

◆ wait_for_submitted_tasks()

void uni20::async::TbbScheduler::wait_for_submitted_tasks ( )
inlineprotected

Wait for every activation registered with the shared task group.

Friends And Related Symbol Documentation

◆ TbbNumaScheduler

friend class TbbNumaScheduler
friend

The documentation for this class was generated from the following file: