Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
linalg/async/conjugate_inplace.hpp
Go to the documentation of this file.
1#pragma once
2
14
15#include <tuple>
16#include <utility>
17
18namespace uni20
19{
20namespace detail
21{
22template <class BackendSelector, AsyncTensorOutput Tensor>
23async::AsyncTask co_conjugate_inplace(BackendSelector const selector, async::WriteBuffer<Tensor> tensor)
24{
25 auto tensor_awaiter = mutable_async_tensor_awaiter(tensor);
26 auto awaited = co_await async::all(tensor_awaiter);
27 decltype(auto) tensor_value = mutable_async_tensor_value<Tensor>(std::get<0>(awaited));
28 auto descriptor = mdspec_of(tensor_value);
29 co_await linalg::co_dispatch_kernel(selector, linalg::conjugate_inplace_op{}, descriptor);
30 co_return;
31}
32
33template <class BackendSelector, AsyncTensorOutput Tensor>
34void schedule_async_conjugate_inplace(BackendSelector selector, async::Async<Tensor>& tensor)
35{
36 auto task = co_conjugate_inplace(std::move(selector), tensor.write());
37 task.debug_name("conjugate_inplace");
38 async::schedule(std::move(task));
39}
40} // namespace detail
41
43template <class BackendSelector, AsyncTensorOutput Tensor>
44void conjugate_inplace(BackendSelector selector, async::Async<Tensor>& tensor)
45{
46 detail::schedule_async_conjugate_inplace(std::move(selector), tensor);
47}
48
50template <AsyncTensorOutput Tensor> void conjugate_inplace(async::Async<Tensor>& tensor)
51{
52 auto selector = linalg::select_backend_for<Tensor>(linalg::conjugate_inplace_op{});
53 detail::schedule_async_conjugate_inplace(std::move(selector), tensor);
54}
55
56} // namespace uni20
The Async<T> container: coroutine‐safe asynchronous read/write.
Coroutine-aware kernel dispatch with an ordinary blocking fallback.
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
Coroutine scheduler for AsyncTask.
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
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
Definition async/async.hpp:26
void conjugate_inplace(BackendSelector selector, async::Async< Tensor > &tensor)
Schedule eager in-place conjugation through an explicit selector.
Definition linalg/async/conjugate_inplace.hpp:44
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
Accessor-respecting in-place scalar conjugation operation tag.
Definition operation_tags.hpp:39
Backend-dispatched in-place conjugation of tensor elements.