Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
uni20::async::CudaTaskPromise Class Referencefinal

Promise type for CUDA-constrained CudaTask coroutines. More...

#include <async_task_promise.hpp>

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

Public Member Functions

template<TaskAwaitable A>
auto await_transform (A &&a)
 Transforms rvalue awaitables into task-aware awaiters.
 
template<TaskFactoryAwaitable A>
auto await_transform (A &&a)
 
template<TaskAwaitable A>
auto await_transform (A &a)
 Transform an awaiter to transfer one task ownership claim.
 
template<TaskFactoryAwaitable A>
auto await_transform (A &a)
 Transform the awaiter to provide transfer of shared ownership of the TaskFactory.
 
template<CudaTaskAwaitable Awaiter>
Awaiter && await_transform (Awaiter &&awaiter) noexcept
 Pass through an explicitly opted-in CUDA task awaiter.
 
template<typename T >
auto await_transform (T &&)
 Fallback await_transform overload that rejects unsupported awaitables.
 
template<typename Task >
requires std::derived_from<std::remove_cvref_t<Task>, BasicTask>
Task && await_transform (Task &&task) noexcept
 Pass through a concrete task that uses the shared basic task representation.
 
void bind_device (int device)
 Bind the CUDA device before the coroutine starts.
 
std::optional< int > device () const noexcept
 Return the task's established CUDA device affinity, if any.
 
CudaTask get_return_object () noexcept
 
void select_device (int device)
 Select the device used for subsequent CUDA task activations.
 
constexpr TaskPromiseBase () noexcept=default
 Default-construct the promise.
 
template<typename... Args>
 TaskPromiseBase (Args &&... args)
 Construct the promise and process coroutine arguments for debug metadata.
 
- Public Member Functions inherited from uni20::async::TaskPromiseBase
int add_awaiter () noexcept
 Increase the number of active awaiters by one.
 
int add_awaiter (int count) noexcept
 Increase the number of active awaiters by a specified count.
 
template<TaskAwaitable A>
auto await_transform (A &&a)
 Transforms rvalue awaitables into task-aware awaiters.
 
template<TaskFactoryAwaitable A>
auto await_transform (A &&a)
 
template<TaskAwaitable A>
auto await_transform (A &a)
 Transform an awaiter to transfer one task ownership claim.
 
template<TaskFactoryAwaitable A>
auto await_transform (A &a)
 Transform the awaiter to provide transfer of shared ownership of the TaskFactory.
 
template<typename T >
auto await_transform (T &&)
 Fallback await_transform overload that rejects unsupported awaitables.
 
template<typename Task >
requires std::derived_from<std::remove_cvref_t<Task>, BasicTask>
Task && await_transform (Task &&task) noexcept
 Pass through a concrete task that uses the shared basic task representation.
 
TaskHandle destroy_with_continuation () noexcept
 safely destroy this coroutine, returning the continuation_ (which also must now be destroyed)
 
auto final_suspend () noexcept
 
std::exception_ptr get_exception () noexcept
 Get the current exception pointer, or nullptr if there is no current exception.
 
bool has_started () const noexcept
 Query whether the coroutine has begun executing.
 
auto initial_suspend () noexcept
 Suspend immediately on coroutine entry.
 
template<TaskPromise Promise>
TaskHandle initialize_task (std::coroutine_handle< Promise > handle) noexcept
 Cache erased self-identity and register the initial ownership claim.
 
bool is_cancel_on_resume () const noexcept
 Reports whether cancellation-on-resume is currently set.
 
void mark_started () noexcept
 Mark the coroutine as having been scheduled to start executing.
 
std::optional< int > preferred_numa_node () const noexcept
 Retrieve the preferred NUMA node for this coroutine.
 
void register_exception_sink (ExceptionSinkNode &node, std::shared_ptr< EpochContext > epoch, bool explicit_sink)
 Register one exception propagation sink with this promise.
 
bool release_awaiter () noexcept
 Decrease the number of active awaiters by one.
 
bool release_awaiter (int count) noexcept
 Decrease the number of active awaiters by a specified count.
 
TaskHandle release_ownership ()
 Release ownership of the coroutine and return it, if it was exclusively owned.
 
void rethrow_exception ()
 Throw the current exception, if there is one.
 
constexpr void return_void () noexcept
 Called when the coroutine returns normally.
 
IScheduler * scheduler () const noexcept
 Return the scheduler currently recorded for this task.
 
TaskHandle self () noexcept
 Return this promise's erased coroutine identity.
 
void set_cancel_on_resume () noexcept
 Mark the coroutine for cancellation at next resume.
 
void set_exception (std::exception_ptr e) noexcept
 Record an exception for deferred rethrow on resume.
 
void set_preferred_numa_node (std::optional< int > node) noexcept
 Set the preferred NUMA node recorded for this coroutine.
 
BasicTask take_ownership () noexcept
 Acquire exclusive ownership of the coroutine.
 
TaskFactory take_shared_ownership (int count)
 Acquire shared ownership of the coroutine for use with multi-await constructs.
 
constexpr TaskPromiseBase () noexcept=default
 Default-construct the promise.
 
template<typename... Args>
 TaskPromiseBase (Args &&... args)
 Construct the promise and process coroutine arguments for debug metadata.
 
void unhandled_exception ()
 Called on unhandled exception escaping the coroutine.
 
void unregister_exception_sink (ExceptionSinkNode &node, bool from_destructor) noexcept
 Unregister one exception propagation sink from this promise.
 
 ~TaskPromiseBase () noexcept
 

Static Public Attributes

static constexpr TaskDomain task_domain = TaskDomain::cuda
 
- Static Public Attributes inherited from uni20::async::TaskPromiseBase
static constexpr int kNoPreferredNumaNode = std::numeric_limits<int>::min()
 

Additional Inherited Members

- Static Public Member Functions inherited from uni20::async::TaskPromiseBase
static bool can_transfer_directly (TaskHandle from, TaskHandle to) noexcept
 Report whether symmetric transfer is valid for two prepared task routes.
 
static void destroy_and_track (TaskHandle handle) noexcept
 Destroy a coroutine handle while recording destruction in the registry.
 
static void note_leaked (TaskHandle handle) noexcept
 Record that a coroutine has been intentionally leaked.
 
static void note_running (TaskHandle handle) noexcept
 Record that a coroutine has transitioned into a runnable/running state.
 
static void note_suspended (TaskHandle handle) noexcept
 Record that a coroutine has suspended and is waiting for resumption.
 
static void prepare_nested_route (TaskHandle parent, TaskHandle child)
 Complete an unbound child's route before nested execution.
 
static std::coroutine_handle resolve_await_suspend_result (TaskHandle current, BasicTask &&task)
 Resolve an await_suspend task return value into a coroutine transfer handle.
 
static void resume_and_track (TaskHandle handle)
 Resume a coroutine handle while recording the running transition.
 
template<TaskFactoryAwaitable A>
static void suspend_factory_awaitable (TaskHandle current, A &awaitable)
 Execute await_suspend for TaskFactoryAwaitable and apply TaskRegistry tracking.
 
template<TaskAwaitable A>
static auto suspend_task_awaitable (TaskHandle current, A &awaitable)
 Execute await_suspend for TaskAwaitable and apply TaskRegistry tracking.
 
- Public Attributes inherited from uni20::async::TaskPromiseBase
std::atomic< int > awaiter_count_ = 0
 Number of active ownership claims on this coroutine.
 
std::atomic< bool > cancel_on_resume_ {false}
 If true, then when the coroutine is next resumed (i.e.
 
TaskHandle continuation_ {}
 Uni20 task coroutines are nestable.
 
std::exception_ptr * continuation_exception_ = nullptr
 Destination for an exception returned by a directly awaited task.
 
std::exception_ptr eptr_ = nullptr
 
std::atomic< bool > exception_ {false}
 EpochContext can inject an exception into a coroutine, which will be thrown when resuming from an awaiter.
 
ExceptionSinkNode * exception_sinks_head_ {nullptr}
 
uint64_t Instance
 
std::string Name
 
std::atomic< int > preferred_numa_node_ {kNoPreferredNumaNode}
 Preferred NUMA node recorded for the coroutine.
 
std::atomic< bool > started_ {false}
 Tracks whether the coroutine has been scheduled or otherwise started.
 
- Static Protected Member Functions inherited from uni20::async::TaskPromiseBase
static void validate_scheduler_route (IScheduler *scheduler, TaskRoute route)
 Validate a prospective task route without changing promise state.
 

Detailed Description

Promise type for CUDA-constrained CudaTask coroutines.

Member Function Documentation

◆ await_transform() [1/7]

template<TaskAwaitable A>
auto uni20::async::TaskPromiseBase::await_transform ( A &&  a)
inline

Transforms rvalue awaitables into task-aware awaiters.

Transforms rvalue awaitable factories into task-aware awaiters.

Template Parameters
AAwaitable type.
Parameters
aAwaitable object.
Returns
Task-aware awaiter bound to this promise.
Template Parameters
AAwaitable-factory type.
Parameters
aAwaitable factory object.
Returns
Task-aware awaiter bound to this promise.

◆ await_transform() [2/7]

template<TaskFactoryAwaitable A>
auto uni20::async::TaskPromiseBase::await_transform ( A &&  a)

◆ await_transform() [3/7]

template<TaskAwaitable A>
auto uni20::async::TaskPromiseBase::await_transform ( A &  a)
inline

Transform an awaiter to transfer one task ownership claim.

Transforms lvalue awaitable factories into task-aware awaiters.

Transforms lvalue awaitables into task-aware awaiters.

Template Parameters
AAwaitable type.
Parameters
aAwaitable object.
Returns
Task-aware awaiter bound to this promise.
Template Parameters
AAwaitable-factory type.
Parameters
aAwaitable factory object.
Returns
Task-aware awaiter bound to this promise.

◆ await_transform() [4/7]

template<TaskFactoryAwaitable A>
auto uni20::async::TaskPromiseBase::await_transform ( A &  a)

Transform the awaiter to provide transfer of shared ownership of the TaskFactory.

◆ await_transform() [5/7]

template<CudaTaskAwaitable Awaiter>
Awaiter && uni20::async::CudaTaskPromise::await_transform ( Awaiter &&  awaiter)
inlinenoexcept

Pass through an explicitly opted-in CUDA task awaiter.

Template Parameters
AwaiterCUDA backend awaiter type.
Parameters
awaiterAwaiter that requires the concrete CUDA promise handle.
Returns
The forwarded awaiter.

◆ await_transform() [6/7]

template<typename T >
auto uni20::async::TaskPromiseBase::await_transform ( T &&  )
inline

Fallback await_transform overload that rejects unsupported awaitables.

Template Parameters
TUnsupported awaitable type.

◆ await_transform() [7/7]

template<typename Task >
requires std::derived_from<std::remove_cvref_t<Task>, BasicTask>
Task && uni20::async::TaskPromiseBase::await_transform ( Task &&  task)
inlinenoexcept

Pass through a concrete task that uses the shared basic task representation.

Template Parameters
TaskConcrete task or basic task reference type.
Parameters
taskTask being awaited.
Returns
Forwarded task reference.

◆ bind_device()

void uni20::async::CudaTaskPromise::bind_device ( int  device)
inline

Bind the CUDA device before the coroutine starts.

Parameters
deviceNon-negative CUDA runtime device ordinal.
Precondition
The task has not started and is either unbound or already bound to the same device.

◆ device()

std::optional< int > uni20::async::CudaTaskPromise::device ( ) const
inlinenoexcept

Return the task's established CUDA device affinity, if any.

An empty result is valid while the task performs device-neutral work. CUDA schedulers route such activations through their configured default device without changing the promise.

◆ get_return_object()

CudaTask uni20::async::CudaTaskPromise::get_return_object ( )
inlinenoexcept

◆ select_device()

void uni20::async::CudaTaskPromise::select_device ( int  device)
inline

Select the device used for subsequent CUDA task activations.

The caller must exclusively own the suspended coroutine. Unlike initial binding, this operation may change affinity after the task has started.

◆ TaskPromiseBase() [1/2]

constexpr uni20::async::TaskPromiseBase::TaskPromiseBase ( )
constexprdefaultnoexcept

Default-construct the promise.

◆ TaskPromiseBase() [2/2]

template<typename... Args>
uni20::async::TaskPromiseBase::TaskPromiseBase ( Args &&...  args)
inline

Construct the promise and process coroutine arguments for debug metadata.

Template Parameters
ArgsCoroutine argument types.
Parameters
argsCoroutine arguments forwarded for ProcessCoroutineArgument.

Member Data Documentation

◆ task_domain

constexpr TaskDomain uni20::async::CudaTaskPromise::task_domain = TaskDomain::cuda
staticconstexpr

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