kokkos-execution 0.0.1
Loading...
Searching...
No Matches
get_exec.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_IMPL_GET_EXEC_HPP
2#define KOKKOS_EXECUTION_IMPL_GET_EXEC_HPP
3
4#include "Kokkos_Core.hpp"
5
7
9
15struct get_exec_t : public stdexec::__query<get_exec_t> {
16 using stdexec::__query<get_exec_t>::operator();
17};
18
19inline constexpr get_exec_t get_exec{};
20
21template <typename... Args>
22struct ExecOf;
23
25template <stdexec::sender Sndr, typename... Env>
26struct ExecOf<Sndr, Env...> {
27 using type = typename completion_scheduler_of_t<stdexec::set_value_t, Sndr, Env...>::execution_space;
28};
29
31template <stdexec::__queryable_with<get_exec_t> T>
32struct ExecOf<T> {
33 using type = typename std::remove_cvref_t<stdexec::__query_result_t<T, get_exec_t>>::execution_space;
34};
35
36template <typename... Args>
37using exec_of_t = typename ExecOf<Args...>::type;
38
46template <Kokkos::ExecutionSpace Exec>
48 using execution_space = Exec;
49
51
52 explicit constexpr ExecutionSpaceRef(const execution_space& exec) noexcept
53 : m_exec_ptr(&exec) {
54 }
55
57 ExecutionSpaceRef(const ExecutionSpaceRef&) noexcept = default;
58 ExecutionSpaceRef& operator=(const ExecutionSpaceRef&) noexcept = default;
59 ExecutionSpaceRef(ExecutionSpaceRef&&) noexcept = default;
60 ExecutionSpaceRef& operator=(ExecutionSpaceRef&&) noexcept = default;
61 ~ExecutionSpaceRef() noexcept = default;
62
63 const execution_space& get() const noexcept {
64 return *m_exec_ptr;
65 }
66
67 friend constexpr auto operator<=>(const ExecutionSpaceRef&, const ExecutionSpaceRef&) noexcept = default;
68
69 [[nodiscard]]
70 constexpr const ExecutionSpaceRef& query(const get_exec_t&) const noexcept {
71 return *this;
72 }
73};
74
75} // namespace Kokkos::Execution::Impl
76
77#endif // KOKKOS_EXECUTION_IMPL_GET_EXEC_HPP
constexpr get_exec_t get_exec
Definition get_exec.hpp:19
std::invoke_result_t< stdexec::get_completion_scheduler_t< Tag >, stdexec::env_of_t< Sndr >, Env... > completion_scheduler_of_t
Retrieve the completion scheduler for a given completion tag.
typename ExecOf< Args... >::type exec_of_t
Definition get_exec.hpp:37
typename completion_scheduler_of_t< stdexec::set_value_t, Sndr, Env... >::execution_space type
Definition get_exec.hpp:27
typename std::remove_cvref_t< stdexec::__query_result_t< T, get_exec_t > >::execution_space type
Definition get_exec.hpp:33
ExecutionSpaceRef & operator=(const ExecutionSpaceRef &) noexcept=default
ExecutionSpaceRef(const ExecutionSpaceRef &) noexcept=default
ExecutionSpaceRef(ExecutionSpaceRef &&) noexcept=default
friend constexpr auto operator<=>(const ExecutionSpaceRef &, const ExecutionSpaceRef &) noexcept=default
const execution_space & get() const noexcept
Definition get_exec.hpp:63
constexpr ExecutionSpaceRef(const execution_space &exec) noexcept
Definition get_exec.hpp:52
constexpr const ExecutionSpaceRef & query(const get_exec_t &) const noexcept
Definition get_exec.hpp:70
Kokkos::DefaultExecutionSpace execution_space