|
Uni20
Asynchronous tensor and runtime library.
|
Promise type for CUDA-constrained CudaTask coroutines. More...
#include <async_task_promise.hpp>
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. | |
Promise type for CUDA-constrained CudaTask coroutines.
|
inline |
Transforms rvalue awaitables into task-aware awaiters.
Transforms rvalue awaitable factories into task-aware awaiters.
| A | Awaitable type. |
| a | Awaitable object. |
| A | Awaitable-factory type. |
| a | Awaitable factory object. |
| 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.
| A | Awaitable type. |
| a | Awaitable object. |
| A | Awaitable-factory type. |
| a | Awaitable factory object. |
| auto uni20::async::TaskPromiseBase::await_transform | ( | A & | a | ) |
Transform the awaiter to provide transfer of shared ownership of the TaskFactory.
|
inlinenoexcept |
Pass through an explicitly opted-in CUDA task awaiter.
| Awaiter | CUDA backend awaiter type. |
| awaiter | Awaiter that requires the concrete CUDA promise handle. |
|
inline |
Fallback await_transform overload that rejects unsupported awaitables.
| T | Unsupported awaitable type. |
|
inlinenoexcept |
Pass through a concrete task that uses the shared basic task representation.
| Task | Concrete task or basic task reference type. |
| task | Task being awaited. |
|
inline |
Bind the CUDA device before the coroutine starts.
| device | Non-negative CUDA runtime device ordinal. |
|
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.
|
inlinenoexcept |
|
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.
|
constexprdefaultnoexcept |
Default-construct the promise.
|
inline |
Construct the promise and process coroutine arguments for debug metadata.
| Args | Coroutine argument types. |
| args | Coroutine arguments forwarded for ProcessCoroutineArgument. |
|
staticconstexpr |