Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Classes | Concepts | Typedefs | Enumerations | Functions | Variables
uni20::async Namespace Reference

This represents the reverse-mode adjoint for functions of complex variables, assuming a real-valued scalar loss function ( L \colon \mathbb{C} \to \mathbb{R} ). More...

Classes

struct  AllAwaiter
 Awaitable that waits for all provided awaiters to complete. More...
 
class  Async
 Async<T> is a container for coroutine-safe asynchronous read/write. More...
 
class  async_cancellation
 Base class for cancellation-related async exceptions. More...
 
struct  async_do_not_start_t
 Tag type to construct an Async without starting the queue object. More...
 
class  async_error
 Base class for all async subsystem exceptions. More...
 
class  async_state_error
 Base class for invalid async state transitions or accesses. More...
 
class  async_storage_missing
 Thrown when Async storage metadata is missing unexpectedly. More...
 
struct  async_value_type
 Strip Async<T> to T for assignment and expression type deduction. More...
 
struct  async_value_type< Async< T > >
 
struct  async_value_type< ReverseValue< T > >
 
class  async_value_uninitialized
 Thrown when an Async value is accessed before initialization. More...
 
class  AsyncTask
 Canonical host-oriented coroutine task type. More...
 
class  AsyncTaskPromise
 Promise type for ordinary AsyncTask coroutines. More...
 
class  BasicTask
 Move-only promise-neutral ownership claim for a Uni20 coroutine. More...
 
class  buffer_cancelled
 Raised when a buffer read path is cancelled intentionally. More...
 
class  buffer_error
 Base class for buffer-related failures. More...
 
class  buffer_read_uninitialized
 Raised when a reader attempts to access an uninitialized buffer. More...
 
class  buffer_uninitialized
 Base class for access to a buffer without a constructed value. More...
 
class  buffer_write_uninitialized
 Raised when a writer requests a mutable reference before construction. More...
 
class  CudaDeviceAwaiter
 Awaiter that establishes or changes a CUDA task's device affinity. More...
 
class  CudaResourceAcquireAwaiter
 CUDA-task awaiter for one provider resource from a fixed-capacity pool. More...
 
class  CudaStreamAcquireAwaiter
 CUDA-task awaiter for an actually-idle stream-pool lease. More...
 
class  CudaTask
 CUDA-constrained public task type used for typed initial admission. More...
 
struct  CudaTaskAwaiterTag
 Marker base for awaiters that require a CudaTaskPromise handle. More...
 
class  CudaTaskPromise
 Promise type for CUDA-constrained CudaTask coroutines. More...
 
class  DebugCudaScheduler
 Configurable debug scheduler that admits ordinary and CUDA tasks. More...
 
class  DebugScheduler
 Single-threaded scheduler with configurable runnable-batch ordering. More...
 
struct  DebugSchedulerOptions
 Configuration for deterministic debug scheduling. More...
 
class  Defer
 Move-only deferred writer helper for a single WriteBuffer<T>. More...
 
class  EpochContext
 
class  EpochContextReader
 RAII handle representing the writer of a value in an EpochContext. More...
 
class  EpochContextWriter
 RAII-scoped representation of a writer’s participation in an epoch. More...
 
class  EpochQueue
 Coordinates multiple epochs of read/write gates. More...
 
class  FutureValue
 Write-once async value wrapper that retains a pending write buffer. More...
 
class  IAsyncScheduler
 Scheduler interface for initial AsyncTask submission and host-side progress. More...
 
class  ICudaScheduler
 Scheduler interface for initial CudaTask admission. More...
 
struct  is_async_alias
 Identifies payload descriptors requiring shared async alias identity. More...
 
class  IScheduler
 Internal route for resuming an already-bound coroutine task. More...
 
class  LightweightTaskBatch
 Borrowed type-erased description of a synchronous lightweight task batch. More...
 
class  NodeInfo
 Records node information for DAG/debugging visualization. More...
 
class  OwningReadAccessProxy
 Owning proxy returned by co_await read_buffer.transfer(). More...
 
class  OwningReadAwaiter
 Awaiter that transfers a read handle into an owning read proxy. More...
 
class  OwningStorageAccessProxy
 Owning proxy providing access to writer storage. More...
 
class  OwningStorageAwaiter
 Awaiter that yields an owning storage-access proxy. More...
 
class  OwningTakeAwaiter
 Awaiter that takes and releases a value from an owning writer. More...
 
class  OwningWriteAccessProxy
 Owning proxy returned by co_await write_buffer.transfer(). More...
 
class  OwningWriteAwaiter
 Awaiter that transfers a writer handle into an owning write proxy. More...
 
class  PropagateExceptionsAwaiter
 Awaiter that registers explicit exception sinks and then resumes immediately. More...
 
class  ReadBuffer
 RAII handle for reading the value from an Async container at a given epoch. More...
 
class  ReadMaybeAwaiter
 Awaiter returning an optional owning read proxy. More...
 
class  ReadMaybeAwaiter< T const & >
 Awaiter returning pointer-or-null read access for lvalue buffers. More...
 
class  ReadOrCancelAwaiter
 Awaiter returning owning read access or throwing task_cancelled. More...
 
class  ReadOrCancelAwaiter< T const & >
 Awaiter returning borrowed read access or throwing task_cancelled. More...
 
class  ReverseEpochQueue
 Reverse-order epoch queue used by reverse-mode gradient accumulation. More...
 
class  ReverseValue
 Reverse-mode accumulation endpoint with staged input/output gradient channels. More...
 
class  ScopedScheduler
 RAII helper that temporarily overrides the global scheduler. More...
 
class  shared_storage
 A lightweight, thread-safe, reference-counted storage for a single object. More...
 
class  StorageAwaiter
 Awaiter returning direct access to a writer's shared storage object. More...
 
class  TakeAwaiter
 Awaiter that takes the writer value without releasing the writer epoch. More...
 
class  TakeReleaseAwaiter
 Awaiter that takes a value and immediately releases the writer epoch. More...
 
class  task_cancelled
 Raised when an AsyncTask is cancelled before completion. More...
 
struct  TaskAwaiter
 Forwarding awaiter that transfers one task ownership claim to an awaitable. More...
 
class  TaskFactory
 Factory for producing multiple BasicTask ownership claims for one coroutine. More...
 
struct  TaskFactoryAwaiter
 Forwarding awaiter that transfers shared task ownership through a TaskFactory. More...
 
class  TaskHandle
 Non-owning erased identity for one Uni20 coroutine frame. More...
 
class  TaskPromiseBase
 Shared non-polymorphic implementation for Uni20 task promises. More...
 
struct  TaskRoute
 Execution requirements used to validate a scheduler route. More...
 
class  TbbCudaScheduler
 Unified oneTBB scheduler with one host arena and one arena per CUDA device. More...
 
struct  TbbCudaSchedulerOptions
 Arena configuration for the unified host/CUDA TBB scheduler. More...
 
class  TbbNumaScheduler
 NUMA-aware scheduler that balances work across per-node TBB arenas. More...
 
class  TbbScheduler
 
struct  TbbSchedulerBatchOptions
 Runtime policy for synchronous lightweight batches executed by a TBB scheduler. More...
 
struct  TryAwaiter
 Awaiter wrapper that returns an optional result. More...
 
struct  ValueAwaiter
 Always-ready awaitable owning an immediate operation value. More...
 
class  Var
 
class  WriteAccessProxy
 Non-owning proxy returned by co_await on an lvalue WriteBuffer<T>. More...
 
class  WriteAssignProxy
 Assignment-only proxy returned by WriteBuffer::write(). More...
 
class  WriteBuffer
 Exclusive mutable-access buffer for one Async<T> epoch. More...
 

Concepts

concept  read_buffer_awaitable
 concept for a valid type that behaves as a read buffer awaitable This requires that the awaiter has a value_type and await_resume() is available.
 
concept  write_buffer_awaitable
 concept for a valid type that behaves as a write buffer awaitable This requires that value_type x; co_await a = x is valid.
 
concept  emplace_buffer_awaitable
 concept for a valid type that supports in-place construction via emplace(...)
 
concept  emplace_buffer_awaitable_of
 
concept  read_buffer_awaitable_of
 concept for a valid type that behaves as a read buffer awaitable for type T.
 
concept  write_buffer_awaitable_of
 concept for a valid type that behaves as a write buffer awaitable This requires that T x; co_await a = x is valid.
 
concept  read_write_buffer_awaitable
 concept for a valid type that behaves as a write buffer that is also readable This requires that value_type x = co_await a; co_await a = x is valid
 
concept  read_write_buffer_awaitable_of
 concept for a valid type that behaves as a write buffer that is also readable This requires that T x = co_await a; co_await a = x is valid
 
concept  async_reader
 An async_reader is satisfied if .read() returns an async read buffer.
 
concept  async_writer
 An async_writer is satisfied if .write() returns a buffer supporting emplace(...).
 
concept  async_reader_of
 
concept  async_writer_to
 Concept requiring an async writer that accepts values constructible from T.
 
concept  async_movable_to
 Concept for an Awaitable that yields a movable object that can be moved into T.
 
concept  async_mutable_writer_of
 
concept  async_read_writer
 Concept for a type that behaves like an asynchronous writer that is also readable: it has a write() function that returns an awaiter that can be assigned from the nested value_type, and also read from.
 
concept  async_like
 Concept for a type that behaves like an asynchronous reader and writer (like Async<T>).
 
concept  async_binary_applicable
 Concept to determine if Op(T,U) is a candidate for forwarding for Async.
 
concept  async_binary_assignable
 concept for validating a binary operation true if the operation result can be emplaced into the writer output type.
 
concept  is_async_compound_applicable
 
concept  TaskPromise
 Promise concept accepted by Uni20 task machinery.
 
concept  CudaTaskAwaitable
 Identifies an explicitly opted-in CUDA task awaiter.
 
concept  AwaitSuspendResult
 Concept for the valid return types of await_suspend.
 
concept  TaskAwaitable
 Concept for awaitables that accept promise-neutral task ownership.
 
concept  TaskFactoryChildAwaitable
 Awaitable that can hold one ownership claim in a multi-input join.
 
concept  TaskFactoryAwaitable
 Concept for awaitables that support shared promise-neutral ownership.
 
concept  HasMemberCoAwait
 Detects if T has a member operator co_await().
 
concept  HasFreeCoAwait
 Detects if a free operator co_await(t) exists.
 
concept  exception_sink_buffer
 Concept for buffers that can register explicit exception sinks.
 

Typedefs

template<typename T , typename U , typename Op >
using async_binary_result_t = decltype(std::declval< Op >()(std::declval< async_value_t< T > >(), std::declval< async_value_t< U > >()))
 Result type of applying binary op Op to async_value_t<T>, async_value_t
 
template<typename T >
using async_value_t = typename async_value_type< std::remove_cvref_t< T > >::type
 Extract the underlying value type from an immediate value or Async<T>.
 
template<typename T >
using OwningWriteProxy = OwningWriteAccessProxy< T >
 Alias for the owning write access proxy type.
 
template<typename AsyncLike >
using take_awaiter_t = decltype(std::declval< write_buffer_t< AsyncLike > & >().take())
 Alias for the awaiter type returned by write_buffer_t::take().
 
template<typename AsyncLike >
using write_buffer_t = decltype(std::declval< AsyncLike & >().write())
 Alias for the write-buffer type produced by write() on an lvalue.
 
template<typename T >
using WriteAwaitProxy = WriteAccessProxy< T >
 Alias for the non-owning write access proxy type.
 
template<typename T >
using WriteProxy = WriteAssignProxy< T >
 Alias for assignment-only writer proxy.
 

Enumerations

enum class  DebugSchedulerOrder { fifo , reverse , random }
 Runnable-batch ordering policy for DebugScheduler. More...
 
enum class  NodeValueState { Invalid , Unconstructed , Constructed }
 Construction state reported for a debug DAG value node. More...
 
enum class  TaskDomain { none , host , cuda }
 Execution domain declared by a concrete Uni20 task promise. More...
 

Functions

template<TaskFactoryChildAwaitable... Aw>
requires ((!std::is_void_v<decltype(std::declval<Aw>().await_resume())> && ...))
auto all (Aw &&... aw) noexcept
 Build an awaitable that waits for all of the provided awaitables.
 
template<typename T , typename U >
AsyncTask async_accumulate (ReadBuffer< T > a_, ReadBuffer< U > b_, WriteBuffer< T > out_)
 Compute out = a + b while tolerating cancellation of either input.
 
template<typename T , typename U >
AsyncTask async_accumulate_minus (ReadBuffer< T > a_, ReadBuffer< U > b_, WriteBuffer< T > out_)
 Compute out = a - b while tolerating cancellation of either input.
 
template<typename T , typename U >
requires (detail::current_value_assignment_source<T, U> || (is_async_alias_v<T> && detail::async_alias_assignable_from<T, async_value_t<U> const&>))
void async_assign (Async< T > &lhs, U &&rhs)
 Assigns an Async or scalar value into an Async destination.
 
template<typename T , typename U >
requires (!is_async_alias_v<T> && read_buffer_awaitable_of<U, T> && detail::write_proxy_assignable_source<T, T>)
void async_assign (WriteBuffer< T > destination, U &&source)
 Assign an awaitable value into an existing independent-value timeline.
 
template<typename T , typename U >
requires (is_async_alias_v<T> && detail::async_alias_assignment_awaitable<U, T>)
void async_assign (WriteBuffer< T > destination, U &&source)
 Assign through an existing async alias descriptor.
 
template<typename T , typename U >
requires (!read_buffer_awaitable<std::remove_cvref_t<U>>) && (detail::current_value_assignment_source<T, U> || (is_async_alias_v<T> && detail::async_alias_assignable_from<T, async_value_t<U> const&>))
void async_assign (WriteBuffer< T > lhs, U &&rhs)
 Assigns an Async or scalar value into a write buffer destination.
 
template<typename A , typename B , async_writer Writer, typename Op >
requires async_binary_applicable<A, B, Op>
void async_binary_op (Writer &out, A &&a, B &&b, Op op)
 Launch a coroutine computing result = op(a, b)
 
template<typename T , typename U , typename Op >
void async_compound_op (Async< T > &lhs, U &&rhs, Op op)
 Launch a coroutine applying an in-place operation op(lhs, rhs).
 
template<typename T , typename U >
requires (!is_async_alias_v<T> && detail::async_source<U> && std::constructible_from<T, async_value_t<U> const&>)
void async_initialize (Async< T > &destination, U &&source)
 Initialize a fresh independent async value from another async source.
 
template<typename T , typename U >
requires (!is_async_alias_v<T> && detail::async_initialization_awaitable<U, T>)
void async_initialize (WriteBuffer< T > destination, U &&source)
 Initialize empty independent-value storage from an awaitable source.
 
template<typename T , typename U >
requires (!is_async_alias_v<T>)
void async_move (Async< T > &lhs, U &&rhs)
 Move-assign from a source expression into an Async destination.
 
template<typename T , typename U >
requires (!is_async_alias_v<T>) && async_mutable_writer_of<U, T> && async_movable_to<U, T>
void async_move (WriteBuffer< T > lhs, U &&rhs)
 
template<typename T , typename U >
requires (!is_async_alias_v<T>) && (!async_writer<std::remove_cvref_t<U>>) && std::constructible_from<T, U&&>
void async_move (WriteBuffer< T > lhs, U &&rhs)
 
template<typename T , typename U >
requires read_buffer_awaitable_of<U, T>
void async_negate (WriteBuffer< T > lhs, U &&rhs)
 Negate a source value asynchronously and write into a destination buffer.
 
template<typename T >
void async_print (std::string Format, Async< T > x)
 Schedules a formatted print once an async value is ready.
 
template<typename T >
void async_read (std::string Prompt, Async< T > &x)
 Schedules reading a value from std::cin into an async slot.
 
template<typename T >
AsyncTask co_conj (ReadBuffer< T > in, WriteBuffer< T > out)
 Coroutine implementation of complex conjugation over async buffers.
 
template<typename T >
AsyncTask co_cos (ReadBuffer< T > in, WriteBuffer< T > out)
 Coroutine implementation of cos over async buffers.
 
template<typename T >
AsyncTask co_herm (ReadBuffer< T > in, WriteBuffer< T > out)
 Coroutine implementation of Hermitian conjugation over async buffers.
 
template<typename T >
AsyncTask co_imag (ReadBuffer< T > in, WriteBuffer< uni20::make_real_t< T > > out)
 Coroutine implementation of imaginary-part extraction over async buffers.
 
template<typename T >
AsyncTask co_real (ReadBuffer< T > in, WriteBuffer< uni20::make_real_t< T > > out)
 Coroutine implementation of real-part extraction over async buffers.
 
template<typename T >
AsyncTask co_sin (ReadBuffer< T > in, WriteBuffer< T > out)
 Coroutine implementation of sin over async buffers.
 
template<typename T >
Async< T > conj (Async< T > const &x)
 Schedules asynchronous conjugation.
 
template<uni20::TensorView Tensor>
requires uni20::Complex<uni20::tensor_element_t<Tensor>>
auto conj (Async< Tensor > const &tensor)
 Return a lazy conjugating alias of an async complex tensor.
 
template<uni20::TensorView Tensor>
requires (!uni20::Complex<uni20::tensor_element_t<Tensor>>)
auto conj (Async< Tensor > const &tensor)
 Return a lazy read-only identity alias of an async real tensor.
 
template<typename T >
Async< T > cos (Async< T > const &x)
 Schedules asynchronous cosine evaluation.
 
template<typename T >
Var< T > cos (Var< T > x)
 Computes cos(x) and wires reverse-mode accumulation for the input gradient.
 
CudaTaskPromise & cuda_promise (TaskHandle handle) noexcept
 Narrow an erased task promise after verifying that it is CUDA-specific.
 
template<typename T >
 Defer (Async< T > &) -> Defer< T >
 CTAD guide for constructing Defer<T> from Async<T>&.
 
template<typename T >
Defer< T > defer_write (Async< T > &a)
 Create a deferred writer helper for an Async value.
 
template<class Function >
requires std::invocable<Function&, std::size_t>
void execute_batch (std::size_t size, Function &&function)
 Execute a synchronous lightweight batch on the global scheduler.
 
constexpr std::string_view format_as (uni20::async::EpochContext::Phase p)
 
template<typename U >
decltype(auto) get_awaiter (U &&u) noexcept
 for an awaitable a, return the actual Awaitable object returned by co_await
 
IAsyncScheduler * get_global_scheduler ()
 Returns the currently-installed process-wide scheduler.
 
template<typename T >
Async< T > herm (Async< T > const &x)
 Schedules asynchronous Hermitian conjugation.
 
template<typename T >
Async< uni20::make_real_t< T > > imag (Async< T > const &x)
 Schedules asynchronous imaginary-part extraction.
 
template<typename T >
Var< uni20::make_real_t< T > > imag (Var< T > z)
 Computes the imaginary part and propagates gradient to a complex source.
 
template<typename Alias , typename Parent , typename... Args>
Async< Alias > make_async_alias (Async< Parent > const &parent, Args &&... args)
 Construct an async alias that retains a parent value and shares its epoch queue.
 
template<typename Alias , typename Parent , typename... Args>
Async< Alias > make_async_alias_from_parent (Async< Parent > &parent, Args &&... args)
 Construct an async alias from a mutable parent descriptor.
 
template<typename Alias , typename Parent , typename... Args>
Async< Alias > make_async_alias_from_parent (Async< Parent > const &parent, Args &&... args)
 Construct a read-only async alias from a parent descriptor.
 
template<typename T , typename... Args>
shared_storage< T > make_shared_storage (Args &&... args)
 Create a new shared_storage<T> with T(args...) in-place.
 
template<typename T , typename Owner , typename... Args>
shared_storage< T > make_shared_storage_alias (shared_storage< Owner > const &owner, Args &&... args)
 Create storage for a value that keeps another storage value alive.
 
template<typename T >
shared_storage< T > make_unconstructed_shared_storage ()
 Create a new shared_storage<T> with an unconstructed T.
 
template<typename T >
Var< T > operator* (T x, Var< T > y)
 Computes x * y with reverse-mode gradient propagation.
 
template<typename T >
Var< T > operator* (Var< T > x, T y)
 Computes x * y with reverse-mode gradient propagation.
 
template<typename T >
Var< T > operator* (Var< T > x, Var< T > y)
 Computes x * y with reverse-mode gradient propagation.
 
template<typename T >
Var< T > operator+ (T x, Var< T > y)
 Computes x + y with reverse-mode gradient propagation.
 
template<typename T >
Var< T > operator+ (Var< T > x, T y)
 Computes x + y with reverse-mode gradient propagation.
 
template<typename T >
Var< T > operator+ (Var< T > x, Var< T > y)
 Computes x + y with reverse-mode gradient propagation.
 
template<typename T >
requires requires(T t) { -t; }
auto operator- (Async< T > const &x)
 Unary negation overload for Async values.
 
template<typename T >
Var< T > operator- (T x, Var< T > y)
 Computes x - y with reverse-mode gradient propagation.
 
template<typename T >
Var< T > operator- (Var< T > x, T y)
 Computes x - y with reverse-mode gradient propagation.
 
template<typename T >
Var< T > operator- (Var< T > x, Var< T > y)
 Computes x - y with reverse-mode gradient propagation.
 
template<typename T >
void ProcessCoroutineArgument (TaskPromiseBase *promise, ReadBuffer< T > const &x)
 Register coroutine debug dependencies for a read-buffer argument.
 
template<typename T >
void ProcessCoroutineArgument (TaskPromiseBase *promise, T const &value)
 Process a coroutine argument for debug metadata (default no-op).
 
template<typename T >
void ProcessCoroutineArgument (TaskPromiseBase *promise, WriteBuffer< T > const &x)
 Register coroutine debug dependencies and exception sink for a write-buffer argument.
 
template<exception_sink_buffer... Buffers>
auto propagate_exceptions_to (Buffers &... buffers)
 Register buffers that should receive unhandled coroutine exceptions.
 
void propagate_unhandled_writer_exception (EpochContext *epoch, std::exception_ptr eptr) noexcept
 Inject an unhandled writer-side coroutine exception into an epoch.
 
template<typename T >
ReadBuffer< T > read (Async< T > const &a)
 Convenience helper that forwards to Async<T>::read().
 
template<typename T >
ReadBuffer< T > read (ReverseValue< T > const &x)
 Free-function read adapter for ReverseValue.
 
template<typename T >
requires detail::AsyncReadProvider<T>
decltype(auto) read (T &&value)
 Obtain the read awaiter exposed by an async-like value.
 
template<typename T >
requires (!detail::AsyncReadProvider<T>)
auto read (T &&value) -> ValueAwaiter< std::remove_cvref_t< T > >
 Wrap an immediate value in an always-ready read awaiter.
 
template<typename T >
Async< uni20::make_real_t< T > > real (Async< T > const &x)
 Schedules asynchronous real-part extraction.
 
template<typename T >
Var< uni20::make_real_t< T > > real (Var< T > z)
 Computes the real part and propagates gradient to a complex source.
 
template<typename T >
ReadBuffer< T > && release (ReadBuffer< T > &&in)
 Adaptor for forwarding an rvalue ReadBuffer into an await expression.
 
template<typename T >
ReadBuffer< T > && release (ReadBuffer< T > &in)
 Adaptor for transferring ReadBuffer ownership into an await expression.
 
void reset_global_scheduler ()
 Restores the process-wide scheduler to the default debug scheduler.
 
template<uni20::MutableStridedTensorView Tensor, std::integral... Extents>
requires uni20::detail::CanonicalReshapeLayout<typename uni20::tensor_mdspec_t<Tensor>::layout_type>
auto reshape_view (Async< Tensor > &tensor, Extents... requested_extents)
 Return a mutable structural reshape alias of an async tensor.
 
template<uni20::StridedTensorView Tensor, std::integral... Extents>
requires uni20::detail::CanonicalReshapeLayout<typename uni20::tensor_mdspec_t<Tensor>::layout_type>
auto reshape_view (Async< Tensor > const &tensor, Extents... requested_extents)
 Return a read-only structural reshape alias of an async tensor.
 
template<uni20::MutableStridedTensorView Tensor, std::integral... Extents>
auto reshape_view_left (Async< Tensor > &tensor, Extents... requested_extents)
 Return a mutable column-major structural reshape alias.
 
template<uni20::StridedTensorView Tensor, std::integral... Extents>
auto reshape_view_left (Async< Tensor > const &tensor, Extents... requested_extents)
 Return a read-only column-major structural reshape alias.
 
template<uni20::MutableStridedTensorView Tensor, std::integral... Extents>
auto reshape_view_right (Async< Tensor > &tensor, Extents... requested_extents)
 Return a mutable row-major structural reshape alias.
 
template<uni20::StridedTensorView Tensor, std::integral... Extents>
auto reshape_view_right (Async< Tensor > const &tensor, Extents... requested_extents)
 Return a read-only row-major structural reshape alias.
 
void schedule (AsyncTask &&task)
 Schedule a task on the currently configured global scheduler.
 
void schedule (CudaTask &&task)
 Schedule a CUDA task on the currently configured global scheduler.
 
void schedule (CudaTask &&task, int device)
 Schedule a CUDA task with initial device affinity.
 
void set_global_scheduler (IAsyncScheduler *sched)
 Sets the process-wide scheduler used by async helpers.
 
template<typename T >
Async< T > sin (Async< T > const &x)
 Schedules asynchronous sine evaluation.
 
template<typename T >
Var< T > sin (Var< T > x)
 Computes sin(x) and wires reverse-mode accumulation for the input gradient.
 
TaskRoute task_route (TaskHandle handle) noexcept
 Return the current scheduling requirements recorded by a task.
 
template<typename Aw >
constexpr auto try_await (Aw &&aw) noexcept
 Build a non-blocking awaiter from an rvalue awaitable.
 
template<typename Aw >
constexpr auto try_await (Aw &aw) noexcept
 Build a non-blocking awaiter that returns optional<T> instead of suspending.
 
template<typename T >
WriteBuffer< T > write (Async< T > &a)
 Convenience helper that forwards to Async<T>::write().
 
template<typename T , typename Value >
auto write_to (WriteBuffer< T > &&buffer, Value value)
 Create a coroutine awaiter that writes a value to a WriteBuffer<T>.
 

Variables

constexpr async_do_not_start_t async_do_not_start {}
 Tag constant to construct an Async without starting the queue object.
 
template<typename T >
constexpr bool is_async_alias_v = is_async_alias<std::remove_cvref_t<T>>::value
 True when T is an owner-bound async alias descriptor.
 

Detailed Description

This represents the reverse-mode adjoint for functions of complex variables, assuming a real-valued scalar loss function ( L \colon \mathbb{C} \to \mathbb{R} ).

Only the Wirtinger derivative with respect to ( z^* ) is propagated:

\[ \bar{z} := \frac{\partial L}{\partial z^*} \]

For an intermediate variable ( f(z) ), the chain rule is:

\[ \frac{\partial L}{\partial z^*} = \frac{\partial L}{\partial f} \cdot \frac{\partial f}{\partial z^*} + \frac{\partial L}{\partial f^*} \cdot \frac{\partial f^*}{\partial z^*} \]

Under the real-valued loss assumption:

\[ \frac{\partial L}{\partial f^*} = \overline{ \left( \frac{\partial L}{\partial f} \right) }, \quad \frac{\partial f^*}{\partial z^*} = \overline{ \left( \frac{\partial f}{\partial z} \right) } \]

so the full gradient becomes:

\[ \frac{\partial L}{\partial z^*} = \frac{\partial L}{\partial f} \cdot \frac{\partial f}{\partial z^*} + \overline{ \left( \frac{\partial L}{\partial f} \cdot \frac{\partial f}{\partial z} \right) } \]

Note
This implementation assumes the upstream gradient is available via grad, and all reverse-mode propagation targets the Wirtinger ( \partial / \partial z^* ) direction.

Typedef Documentation

◆ async_value_t

template<typename T >
using uni20::async::async_value_t = typedef typename async_value_type<std::remove_cvref_t<T> >::type

Extract the underlying value type from an immediate value or Async<T>.

◆ OwningWriteProxy

template<typename T >
using uni20::async::OwningWriteProxy = typedef OwningWriteAccessProxy<T>

Alias for the owning write access proxy type.

◆ WriteAwaitProxy

template<typename T >
using uni20::async::WriteAwaitProxy = typedef WriteAccessProxy<T>

Alias for the non-owning write access proxy type.

◆ WriteProxy

template<typename T >
using uni20::async::WriteProxy = typedef WriteAssignProxy<T>

Alias for assignment-only writer proxy.

Enumeration Type Documentation

◆ DebugSchedulerOrder

Runnable-batch ordering policy for DebugScheduler.

Enumerator
fifo 

Execute each runnable batch in submission order.

reverse 

Execute each runnable batch in reverse submission order.

random 

Execute each runnable batch in seeded pseudo-random order.

◆ NodeValueState

enum class uni20::async::NodeValueState
strong

Construction state reported for a debug DAG value node.

Enumerator
Invalid 

No storage or fallback value is available.

Unconstructed 

Storage exists but does not currently contain a value.

Constructed 

A value is currently constructed.

◆ TaskDomain

enum class uni20::async::TaskDomain
strong

Execution domain declared by a concrete Uni20 task promise.

Enumerator
none 
host 
cuda 

Function Documentation

◆ all()

template<TaskFactoryChildAwaitable... Aw>
requires ((!std::is_void_v<decltype(std::declval<Aw>().await_resume())> && ...))
auto uni20::async::all ( Aw &&...  aw)
noexcept

Build an awaitable that waits for all of the provided awaitables.

Parameters
awAwaitable arguments.
Returns
An object supporting co_await.

◆ async_accumulate()

template<typename T , typename U >
AsyncTask uni20::async::async_accumulate ( ReadBuffer< T >  a_,
ReadBuffer< U >  b_,
WriteBuffer< T >  out_ 
)

Compute out = a + b while tolerating cancellation of either input.

Template Parameters
TLeft/output value type.
URight input value type.
Parameters
a_Left input read buffer.
b_Right input read buffer.
out_Output write buffer.

◆ async_accumulate_minus()

template<typename T , typename U >
AsyncTask uni20::async::async_accumulate_minus ( ReadBuffer< T >  a_,
ReadBuffer< U >  b_,
WriteBuffer< T >  out_ 
)

Compute out = a - b while tolerating cancellation of either input.

Template Parameters
TLeft/output value type.
URight input value type.
Parameters
a_Left input read buffer.
b_Right input read buffer.
out_Output write buffer.

◆ async_assign() [1/2]

template<typename T , typename U >
requires (is_async_alias_v<T> && detail::async_alias_assignment_awaitable<U, T>)
void uni20::async::async_assign ( WriteBuffer< T >  destination,
U &&  source 
)

Assign through an existing async alias descriptor.

The destination descriptor, lifetime owner, and epoch queue remain intact. The write proxy invokes the alias's ADL customization.

◆ async_assign() [2/2]

template<typename T , typename U >
requires (!read_buffer_awaitable<std::remove_cvref_t<U>>) && (detail::current_value_assignment_source<T, U> || (is_async_alias_v<T> && detail::async_alias_assignable_from<T, async_value_t<U> const&>))
void uni20::async::async_assign ( WriteBuffer< T >  lhs,
U &&  rhs 
)

Assigns an Async or scalar value into a write buffer destination.

Template Parameters
TDestination value type.
USource type (scalar or Async-like).
Parameters
lhsDestination write buffer.
rhsSource expression.

◆ async_move()

template<typename T , typename U >
requires (!is_async_alias_v<T>) && (!async_writer<std::remove_cvref_t<U>>) && std::constructible_from<T, U&&>
void uni20::async::async_move ( WriteBuffer< T >  lhs,
U &&  rhs 
)

◆ async_print()

template<typename T >
void uni20::async::async_print ( std::string  Format,
Async< T >  x 
)

Schedules a formatted print once an async value is ready.

Template Parameters
TValue type.
Parameters
Formatfmt-style format string.
xAsync value to print.

◆ async_read()

template<typename T >
void uni20::async::async_read ( std::string  Prompt,
Async< T > &  x 
)

Schedules reading a value from std::cin into an async slot.

Template Parameters
TValue type.
Parameters
PromptPrompt text printed before reading.
xAsync destination value.

◆ co_conj()

template<typename T >
AsyncTask uni20::async::co_conj ( ReadBuffer< T >  in,
WriteBuffer< T >  out 
)

Coroutine implementation of complex conjugation over async buffers.

Template Parameters
TValue type.
Parameters
inInput read buffer.
outOutput write buffer.

◆ co_cos()

template<typename T >
AsyncTask uni20::async::co_cos ( ReadBuffer< T >  in,
WriteBuffer< T >  out 
)

Coroutine implementation of cos over async buffers.

Template Parameters
TValue type.
Parameters
inInput read buffer.
outOutput write buffer.

◆ co_herm()

template<typename T >
AsyncTask uni20::async::co_herm ( ReadBuffer< T >  in,
WriteBuffer< T >  out 
)

Coroutine implementation of Hermitian conjugation over async buffers.

Template Parameters
TValue type.
Parameters
inInput read buffer.
outOutput write buffer.

◆ co_imag()

template<typename T >
AsyncTask uni20::async::co_imag ( ReadBuffer< T >  in,
WriteBuffer< uni20::make_real_t< T > >  out 
)

Coroutine implementation of imaginary-part extraction over async buffers.

Template Parameters
TValue type.
Parameters
inInput read buffer.
outOutput write buffer.

◆ co_real()

template<typename T >
AsyncTask uni20::async::co_real ( ReadBuffer< T >  in,
WriteBuffer< uni20::make_real_t< T > >  out 
)

Coroutine implementation of real-part extraction over async buffers.

Template Parameters
TValue type.
Parameters
inInput read buffer.
outOutput write buffer.

◆ co_sin()

template<typename T >
AsyncTask uni20::async::co_sin ( ReadBuffer< T >  in,
WriteBuffer< T >  out 
)

Coroutine implementation of sin over async buffers.

Template Parameters
TValue type.
Parameters
inInput read buffer.
outOutput write buffer.

◆ conj() [1/3]

template<typename T >
Async< T > uni20::async::conj ( Async< T > const &  x)

Schedules asynchronous conjugation.

Template Parameters
TValue type.
Parameters
xInput async value.
Returns
Async result of conj(x).

◆ conj() [2/3]

auto uni20::async::conj ( Async< Tensor > const &  tensor)

Return a lazy conjugating alias of an async complex tensor.

The result retains the parent tensor storage and shares its exact epoch queue. Awaiting the alias therefore observes the same causal timeline as awaiting the parent. Default precision is read from that parent epoch rather than copied when the alias is created.

◆ conj() [3/3]

auto uni20::async::conj ( Async< Tensor > const &  tensor)

Return a lazy read-only identity alias of an async real tensor.

◆ cos() [1/2]

template<typename T >
Async< T > uni20::async::cos ( Async< T > const &  x)

Schedules asynchronous cosine evaluation.

Template Parameters
TValue type.
Parameters
xInput async value.
Returns
Async result of cos(x).

◆ cos() [2/2]

template<typename T >
Var< T > uni20::async::cos ( Var< T >  x)

Computes cos(x) and wires reverse-mode accumulation for the input gradient.

Template Parameters
TValue type.
Parameters
xInput variable.
Returns
Output variable representing cos(x).

◆ cuda_promise()

CudaTaskPromise & uni20::async::cuda_promise ( TaskHandle  handle)
inlinenoexcept

Narrow an erased task promise after verifying that it is CUDA-specific.

Parameters
handleErased task identity produced from its original typed coroutine handle.
Returns
The concrete CUDA promise.

◆ Defer()

template<typename T >
uni20::async::Defer ( Async< T > &  ) -> Defer< T >

CTAD guide for constructing Defer<T> from Async<T>&.

◆ defer_write()

template<typename T >
Defer< T > uni20::async::defer_write ( Async< T > &  a)

Create a deferred writer helper for an Async value.

Template Parameters
TStored value type.
Parameters
aAsync value to write.
Returns
Deferred writer helper.

◆ execute_batch()

template<class Function >
requires std::invocable<Function&, std::size_t>
void uni20::async::execute_batch ( std::size_t  size,
Function &&  function 
)

Execute a synchronous lightweight batch on the global scheduler.

Template Parameters
FunctionCallable accepting one std::size_t index.
Parameters
sizeNumber of work items.
functionWork-item callable borrowed until the call returns.

◆ format_as()

constexpr std::string_view uni20::async::format_as ( uni20::async::EpochContext::Phase  p)
constexpr

◆ get_awaiter()

template<typename U >
decltype(auto) uni20::async::get_awaiter ( U &&  u)
noexcept

for an awaitable a, return the actual Awaitable object returned by co_await

Template Parameters
UAwaitable or awaiter type.
Parameters
uThe object to transform.
Returns
The awaiter object to use.
Note
Within a coroutine, this type may be transformed into something else via the promise_type::await_transform() function.

◆ get_global_scheduler()

IAsyncScheduler * uni20::async::get_global_scheduler ( )
inline

Returns the currently-installed process-wide scheduler.

Returns
Pointer to the active scheduler.

◆ herm()

template<typename T >
Async< T > uni20::async::herm ( Async< T > const &  x)

Schedules asynchronous Hermitian conjugation.

Template Parameters
TValue type.
Parameters
xInput async value.
Returns
Async result of herm(x).

◆ imag() [1/2]

template<typename T >
Async< uni20::make_real_t< T > > uni20::async::imag ( Async< T > const &  x)

Schedules asynchronous imaginary-part extraction.

Template Parameters
TValue type.
Parameters
xInput async value.
Returns
Async result containing imag(x).

◆ imag() [2/2]

template<typename T >
Var< uni20::make_real_t< T > > uni20::async::imag ( Var< T >  z)

Computes the imaginary part and propagates gradient to a complex source.

Template Parameters
TComplex-like value type.
Parameters
zInput variable.
Returns
Output variable representing imag(z).

◆ make_async_alias()

template<typename Alias , typename Parent , typename... Args>
Async< Alias > uni20::async::make_async_alias ( Async< Parent > const &  parent,
Args &&...  args 
)

Construct an async alias that retains a parent value and shares its epoch queue.

◆ make_async_alias_from_parent() [1/2]

template<typename Alias , typename Parent , typename... Args>
Async< Alias > uni20::async::make_async_alias_from_parent ( Async< Parent > &  parent,
Args &&...  args 
)

Construct an async alias from a mutable parent descriptor.

The alias constructor receives the address reserved for the parent value followed by args. The address may identify unconstructed storage and must not be dereferenced before the shared epoch is readable.

◆ make_async_alias_from_parent() [2/2]

template<typename Alias , typename Parent , typename... Args>
Async< Alias > uni20::async::make_async_alias_from_parent ( Async< Parent > const &  parent,
Args &&...  args 
)

Construct a read-only async alias from a parent descriptor.

◆ make_shared_storage()

template<typename T , typename... Args>
shared_storage< T > uni20::async::make_shared_storage ( Args &&...  args)
inline

Create a new shared_storage<T> with T(args...) in-place.

Template Parameters
TStored value type.
ArgsConstructor argument types.
Parameters
argsConstructor arguments forwarded to T.
Returns
New shared_storage<T> with a constructed value.

◆ make_shared_storage_alias()

template<typename T , typename Owner , typename... Args>
shared_storage< T > uni20::async::make_shared_storage_alias ( shared_storage< Owner > const &  owner,
Args &&...  args 
)
inline

Create storage for a value that keeps another storage value alive.

The alias has its own local strong count. Its control block retains one reference to owner, which is released after the alias value is destroyed. Copies of the alias increment only the local count.

Template Parameters
TAlias value type.
OwnerLifetime-owner value type.
ArgsAlias constructor argument types.
Parameters
ownerStorage whose lifetime must cover the alias value.
argsArguments forwarded to the alias value constructor.
Returns
Constructed alias storage sharing the owner's lifetime.

◆ make_unconstructed_shared_storage()

template<typename T >
shared_storage< T > uni20::async::make_unconstructed_shared_storage ( )
inline

Create a new shared_storage<T> with an unconstructed T.

◆ operator*() [1/3]

template<typename T >
Var< T > uni20::async::operator* ( T  x,
Var< T >  y 
)

Computes x * y with reverse-mode gradient propagation.

Template Parameters
TValue type.
Parameters
xLeft scalar operand.
yRight input variable.
Returns
Output variable representing x * y.

◆ operator*() [2/3]

template<typename T >
Var< T > uni20::async::operator* ( Var< T >  x,
T  y 
)

Computes x * y with reverse-mode gradient propagation.

Template Parameters
TValue type.
Parameters
xLeft input variable.
yRight scalar operand.
Returns
Output variable representing x * y.

◆ operator*() [3/3]

template<typename T >
Var< T > uni20::async::operator* ( Var< T >  x,
Var< T >  y 
)

Computes x * y with reverse-mode gradient propagation.

Template Parameters
TValue type.
Parameters
xLeft input variable.
yRight input variable.
Returns
Output variable representing x * y.

◆ operator+() [1/3]

template<typename T >
Var< T > uni20::async::operator+ ( T  x,
Var< T >  y 
)

Computes x + y with reverse-mode gradient propagation.

Template Parameters
TValue type.
Parameters
xLeft scalar operand.
yRight input variable.
Returns
Output variable representing x + y.

◆ operator+() [2/3]

template<typename T >
Var< T > uni20::async::operator+ ( Var< T >  x,
T  y 
)

Computes x + y with reverse-mode gradient propagation.

Template Parameters
TValue type.
Parameters
xLeft input variable.
yRight scalar operand.
Returns
Output variable representing x + y.

◆ operator+() [3/3]

template<typename T >
Var< T > uni20::async::operator+ ( Var< T >  x,
Var< T >  y 
)

Computes x + y with reverse-mode gradient propagation.

Template Parameters
TValue type.
Parameters
xLeft input variable.
yRight input variable.
Returns
Output variable representing x + y.

◆ operator-() [1/3]

template<typename T >
Var< T > uni20::async::operator- ( T  x,
Var< T >  y 
)

Computes x - y with reverse-mode gradient propagation.

Template Parameters
TValue type.
Parameters
xLeft scalar operand.
yRight input variable.
Returns
Output variable representing x - y.

◆ operator-() [2/3]

template<typename T >
Var< T > uni20::async::operator- ( Var< T >  x,
T  y 
)

Computes x - y with reverse-mode gradient propagation.

Template Parameters
TValue type.
Parameters
xLeft input variable.
yRight scalar operand.
Returns
Output variable representing x - y.

◆ operator-() [3/3]

template<typename T >
Var< T > uni20::async::operator- ( Var< T >  x,
Var< T >  y 
)

Computes x - y with reverse-mode gradient propagation.

Template Parameters
TValue type.
Parameters
xLeft input variable.
yRight input variable.
Returns
Output variable representing x - y.

◆ ProcessCoroutineArgument() [1/3]

template<typename T >
void uni20::async::ProcessCoroutineArgument ( TaskPromiseBase *  promise,
ReadBuffer< T > const &  x 
)

Register coroutine debug dependencies for a read-buffer argument.

Template Parameters
TStored value type.
Parameters
promisePromise collecting dependency metadata.
xRead buffer argument.

◆ ProcessCoroutineArgument() [2/3]

template<typename T >
void uni20::async::ProcessCoroutineArgument ( TaskPromiseBase *  promise,
T const &  value 
)

Process a coroutine argument for debug metadata (default no-op).

Template Parameters
TArgument type.
Parameters
promisePromise receiving metadata.
valueArgument ignored by default.

◆ ProcessCoroutineArgument() [3/3]

template<typename T >
void uni20::async::ProcessCoroutineArgument ( TaskPromiseBase *  promise,
WriteBuffer< T > const &  x 
)

Register coroutine debug dependencies and exception sink for a write-buffer argument.

Template Parameters
TStored value type.
Parameters
promisePromise collecting dependency metadata.
xWrite buffer argument.

◆ propagate_exceptions_to()

template<exception_sink_buffer... Buffers>
auto uni20::async::propagate_exceptions_to ( Buffers &...  buffers)

Register buffers that should receive unhandled coroutine exceptions.

The registration remains active for as long as each buffer object remains alive.

Note
If a registered explicit sink is destroyed during stack unwinding, the runtime aborts.

◆ propagate_unhandled_writer_exception()

void uni20::async::propagate_unhandled_writer_exception ( EpochContext *  epoch,
std::exception_ptr  eptr 
)
inlinenoexcept

Inject an unhandled writer-side coroutine exception into an epoch.

Parameters
epochTarget epoch context associated with a writer buffer.
eptrException captured by the coroutine promise.

◆ read() [1/4]

template<typename T >
ReadBuffer< T > uni20::async::read ( Async< T > const &  a)

Convenience helper that forwards to Async<T>::read().

Template Parameters
TStored value type.
Parameters
aAsync container providing the read buffer.
Returns
Read buffer obtained from the Async instance.

◆ read() [2/4]

template<typename T >
ReadBuffer< T > uni20::async::read ( ReverseValue< T > const &  x)

Free-function read adapter for ReverseValue.

Template Parameters
TStored value type.
Parameters
xReverse value.
Returns
Input read buffer for the reverse channel.

◆ read() [3/4]

template<typename T >
requires detail::AsyncReadProvider<T>
decltype(auto) uni20::async::read ( T &&  value)

Obtain the read awaiter exposed by an async-like value.

◆ read() [4/4]

template<typename T >
requires (!detail::AsyncReadProvider<T>)
auto uni20::async::read ( T &&  value) -> ValueAwaiter<std::remove_cvref_t<T>>

Wrap an immediate value in an always-ready read awaiter.

◆ real() [1/2]

template<typename T >
Async< uni20::make_real_t< T > > uni20::async::real ( Async< T > const &  x)

Schedules asynchronous real-part extraction.

Template Parameters
TValue type.
Parameters
xInput async value.
Returns
Async result containing real(x).

◆ real() [2/2]

template<typename T >
Var< uni20::make_real_t< T > > uni20::async::real ( Var< T >  z)

Computes the real part and propagates gradient to a complex source.

Template Parameters
TComplex-like value type.
Parameters
zInput variable.
Returns
Output variable representing real(z).

◆ release() [1/2]

template<typename T >
ReadBuffer< T > && uni20::async::release ( ReadBuffer< T > &&  in)

Adaptor for forwarding an rvalue ReadBuffer into an await expression.

This is a synonym for std::move.

◆ release() [2/2]

template<typename T >
ReadBuffer< T > && uni20::async::release ( ReadBuffer< T > &  in)

Adaptor for transferring ReadBuffer ownership into an await expression.

This is a synonym for std::move.

◆ reset_global_scheduler()

void uni20::async::reset_global_scheduler ( )
inline

Restores the process-wide scheduler to the default debug scheduler.

◆ reshape_view() [1/2]

template<uni20::MutableStridedTensorView Tensor, std::integral... Extents>
requires uni20::detail::CanonicalReshapeLayout<typename uni20::tensor_mdspec_t<Tensor>::layout_type>
auto uni20::async::reshape_view ( Async< Tensor > &  tensor,
Extents...  requested_extents 
)

Return a mutable structural reshape alias of an async tensor.

The descriptor retains the parent storage and shares its exact epoch queue. Shape and layout validation occurs when the shared parent epoch first becomes readable. Default precision follows the parent state observed by each operation through the alias.

◆ reshape_view() [2/2]

template<uni20::StridedTensorView Tensor, std::integral... Extents>
requires uni20::detail::CanonicalReshapeLayout<typename uni20::tensor_mdspec_t<Tensor>::layout_type>
auto uni20::async::reshape_view ( Async< Tensor > const &  tensor,
Extents...  requested_extents 
)

Return a read-only structural reshape alias of an async tensor.

◆ reshape_view_left() [1/2]

template<uni20::MutableStridedTensorView Tensor, std::integral... Extents>
auto uni20::async::reshape_view_left ( Async< Tensor > &  tensor,
Extents...  requested_extents 
)

Return a mutable column-major structural reshape alias.

◆ reshape_view_left() [2/2]

template<uni20::StridedTensorView Tensor, std::integral... Extents>
auto uni20::async::reshape_view_left ( Async< Tensor > const &  tensor,
Extents...  requested_extents 
)

Return a read-only column-major structural reshape alias.

◆ reshape_view_right() [1/2]

template<uni20::MutableStridedTensorView Tensor, std::integral... Extents>
auto uni20::async::reshape_view_right ( Async< Tensor > &  tensor,
Extents...  requested_extents 
)

Return a mutable row-major structural reshape alias.

◆ reshape_view_right() [2/2]

template<uni20::StridedTensorView Tensor, std::integral... Extents>
auto uni20::async::reshape_view_right ( Async< Tensor > const &  tensor,
Extents...  requested_extents 
)

Return a read-only row-major structural reshape alias.

◆ schedule() [1/3]

void uni20::async::schedule ( AsyncTask &&  task)
inline

Schedule a task on the currently configured global scheduler.

Parameters
taskTask to schedule.

◆ schedule() [2/3]

void uni20::async::schedule ( CudaTask &&  task)
inline

Schedule a CUDA task on the currently configured global scheduler.

The installed scheduler must implement CUDA task admission.

Parameters
taskCUDA task to schedule without establishing device affinity.

◆ schedule() [3/3]

void uni20::async::schedule ( CudaTask &&  task,
int  device 
)
inline

Schedule a CUDA task with initial device affinity.

Initial admission to the correct device avoids a later scheduler migration when the task first selects that device.

Parameters
taskCUDA task to schedule.
deviceCUDA runtime device ordinal.

◆ set_global_scheduler()

void uni20::async::set_global_scheduler ( IAsyncScheduler *  sched)
inline

Sets the process-wide scheduler used by async helpers.

Parameters
schedScheduler pointer to install.

◆ sin() [1/2]

template<typename T >
Async< T > uni20::async::sin ( Async< T > const &  x)

Schedules asynchronous sine evaluation.

Template Parameters
TValue type.
Parameters
xInput async value.
Returns
Async result of sin(x).

◆ sin() [2/2]

template<typename T >
Var< T > uni20::async::sin ( Var< T >  x)

Computes sin(x) and wires reverse-mode accumulation for the input gradient.

Template Parameters
TValue type.
Parameters
xInput variable.
Returns
Output variable representing sin(x).

◆ task_route()

TaskRoute uni20::async::task_route ( TaskHandle  handle)
inlinenoexcept

Return the current scheduling requirements recorded by a task.

◆ try_await() [1/2]

template<typename Aw >
constexpr auto uni20::async::try_await ( Aw &&  aw)
constexprnoexcept

Build a non-blocking awaiter from an rvalue awaitable.

Template Parameters
AwAwaitable type.
Parameters
awAwaitable value moved into the try-await wrapper.
Returns
A TryAwaiter that owns the awaitable value.

◆ try_await() [2/2]

template<typename Aw >
constexpr auto uni20::async::try_await ( Aw &  aw)
constexprnoexcept

Build a non-blocking awaiter that returns optional<T> instead of suspending.

If you pass an lvalue awaiter, it’s stored by reference. If you pass a prvalue awaiter (e.g. a proxy type you’ve designed), it’s stored by value. Exceptions from the readiness probe or result extraction propagate normally.

Example:

ReadBuffer<int> rbuf = I.read();
// ok: Aw = ReadBuffer<int>&, builder holds rbuf by reference
auto maybe_i = co_await try_await(rbuf);
// also ok if AsyncProxyAwaiter is a small, copyable awaiter
auto proxy = AsyncProxyAwaiter{/*…*&zwj;/};
auto maybe_v = co_await try_await(proxy);
RAII handle for reading the value from an Async container at a given epoch.
Definition buffers.hpp:53
constexpr auto try_await(Aw &aw) noexcept
Build a non-blocking awaiter that returns optional<T> instead of suspending.
Definition awaiters.hpp:349
Parameters
awAn awaitable (must outlive the coroutine for references).
Returns
A TryAwaiter wrapper around the supplied awaitable.

◆ write()

template<typename T >
WriteBuffer< T > uni20::async::write ( Async< T > &  a)

Convenience helper that forwards to Async<T>::write().

Template Parameters
TStored value type.
Parameters
aAsync container providing the write buffer.
Returns
Write buffer obtained from the Async instance.

◆ write_to()

template<typename T , typename Value >
auto uni20::async::write_to ( WriteBuffer< T > &&  buffer,
Value  value 
)

Create a coroutine awaiter that writes a value to a WriteBuffer<T>.

Constructs an awaitable object that can be co_awaited to write a given value into an Async<T> via its WriteBuffer. Ensures lifetime safety and correct causal ordering when the buffer is a temporary.

Parameters
bufferA WriteBuffer<T>, moved into the coroutine.
valueThe value to assign, moved into the awaiter frame.
Returns
An awaitable object that performs the write upon resumption.

Variable Documentation

◆ async_do_not_start

constexpr async_do_not_start_t uni20::async::async_do_not_start {}
inlineconstexpr

Tag constant to construct an Async without starting the queue object.

◆ is_async_alias_v

template<typename T >
constexpr bool uni20::async::is_async_alias_v = is_async_alias<std::remove_cvref_t<T>>::value
inlineconstexpr

True when T is an owner-bound async alias descriptor.