24template <
class BackendSelector, uni20::AsyncTensorOutput MatrixTensor,
class DiagonalAwaiter,
class OffDiagonalAwaiter>
26 DiagonalAwaiter diagonal, OffDiagonalAwaiter off_diagonal,
MatrixRegion const region)
28 auto matrix_awaiter = uni20::detail::mutable_async_tensor_awaiter(matrix);
29 auto awaited =
co_await async::all(matrix_awaiter, diagonal, off_diagonal);
30 decltype(
auto) matrix_value = uni20::detail::mutable_async_tensor_value<MatrixTensor>(std::get<0>(awaited));
32 scalar_type
const diagonal_value =
static_cast<scalar_type
>(std::get<1>(awaited));
33 scalar_type
const off_diagonal_value =
static_cast<scalar_type
>(std::get<2>(awaited));
36 co_await co_dispatch_kernel(selector, matrix_set_op{.region = region}, descriptor, diagonal_value,
41template <
class BackendSelector, uni20::AsyncTensorOutput MatrixTensor,
class DiagonalAwaiter,
class OffDiagonalAwaiter>
45 auto task = co_set_matrix(std::move(selector), matrix.
write(), std::move(diagonal), std::move(off_diagonal), region);
46 task.debug_name(
"set_matrix");
56 AsyncOperationScalar<Diagonal, uni20::tensor_element_t<MatrixTensor>> &&
57 AsyncOperationScalar<OffDiagonal, uni20::tensor_element_t<MatrixTensor>>
61 detail::schedule_async_set_matrix(std::move(selector), matrix,
async::read(std::forward<Diagonal>(diagonal)),
62 async::read(std::forward<OffDiagonal>(off_diagonal)), region);
66template <uni20::AsyncTensorOutput MatrixTensor,
class Diagonal,
class OffDiagonal>
68 AsyncOperationScalar<Diagonal, uni20::tensor_element_t<MatrixTensor>> &&
69 AsyncOperationScalar<OffDiagonal, uni20::tensor_element_t<MatrixTensor>>
74 set_matrix(std::move(selector), matrix, std::forward<Diagonal>(diagonal), std::forward<OffDiagonal>(off_diagonal),
The Async<T> container: coroutineāsafe asynchronous read/write.
Coroutine-aware kernel dispatch with an ordinary blocking fallback.
Utilities for awaiting on Async<T>: co_await overload, all(), try_await().
Canonical host-oriented coroutine task type.
Definition async_task.hpp:196
Async<T> is a container for coroutine-safe asynchronous read/write.
Definition async/async.hpp:93
WriteBuffer< T > write()
Begin exclusive asynchronous access to the payload.
Definition async/async.hpp:346
Exclusive mutable-access buffer for one Async<T> epoch.
Definition buffers.hpp:859
Mutable Tensor output supported by async operation wrappers.
Definition linalg/async/concepts.hpp:25
MutableTensorView with a specified static rank.
Definition tensor/concepts.hpp:166
Coroutine scheduler for AsyncTask.
Capabilities shared by asynchronous Tensor operation wrappers.
Shared output capabilities for Async Tensor operation wrappers.
void schedule(AsyncTask &&task)
Schedule a task on the currently configured global scheduler.
Definition debug_scheduler.hpp:237
auto all(Aw &&... aw) noexcept
Build an awaitable that waits for all of the provided awaitables.
Definition awaiters.hpp:200
ReadBuffer< T > read(Async< T > const &a)
Convenience helper that forwards to Async<T>::read().
Definition async/async.hpp:540
Definition linalg/async.hpp:28
async::AsyncTask co_dispatch_kernel(BackendSelector selector, Op op, Args &... args)
Dispatch a kernel from a coroutine without requiring coroutine wrappers for blocking backends.
Definition async/dispatch.hpp:106
void set_matrix(BackendSelector selector, async::Async< MatrixTensor > &matrix, Diagonal &&diagonal, OffDiagonal &&off_diagonal, MatrixRegion region=MatrixRegion::All)
Schedule structured matrix initialization through an explicit selector.
Definition async/matrix_set.hpp:58
MatrixRegion
Matrix region selected by structured initialization operations.
Definition operation_tags.hpp:208
@ All
All entries, including rectangular portions of the matrix.
constexpr decltype(auto) mdspec_of(Tensor &tensor) noexcept(noexcept(tensor.mdspec()))
Return a tensor's immediate or descriptor-backed multidimensional metadata.
Definition tensor/concepts.hpp:50
std::remove_cv_t< typename tensor_mdspec_t< T >::element_type > tensor_element_t
Scalar value type exposed by a tensor-level object.
Definition tensor/concepts.hpp:126
Structured dense matrix initialization operation.
Structured dense matrix initialization operation tag.
Definition operation_tags.hpp:219
MatrixRegion region
Definition operation_tags.hpp:221