kokkos-execution 0.0.1
Loading...
Searching...
No Matches
execution_space.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_EXECUTION_SPACE_HPP
2#define KOKKOS_EXECUTION_EXECUTION_SPACE_HPP
3
5
6#include "Kokkos_Core.hpp"
7
17
19
21
22template <Kokkos::ExecutionSpace Exec>
23struct State {
24 Exec exec;
25};
26
33template <Kokkos::ExecutionSpace Exec>
34struct Scheduler {
36 using scheduler_concept = stdexec::scheduler_t;
37
38 using execution_space = Exec;
39
40 template <stdexec::receiver Rcvr>
41 struct OpState {
42 using operation_state_concept = stdexec::operation_state_t;
43
44 Rcvr rcvr;
45
47 void start() & noexcept {
48 stdexec::set_value(std::move(rcvr));
49 }
50 };
51
52 struct Sender {
53 using sender_concept = stdexec::sender_t;
54
55 using completion_signatures = stdexec::completion_signatures<stdexec::set_value_t()>;
56
58 struct Attributes {
59 template <typename... Env>
60 [[nodiscard]]
61 constexpr auto
62 query(stdexec::get_completion_scheduler_t<stdexec::set_value_t>, Env...) const noexcept -> Scheduler {
63 return {state};
64 }
65
66 template <typename... Env>
67 [[nodiscard]]
68 constexpr auto
69 query(stdexec::get_completion_domain_t<stdexec::set_value_t>, Env...) const noexcept -> Domain {
70 return {};
71 }
72
74 };
75
76 template <stdexec::receiver_of<completion_signatures> Rcvr>
77 [[nodiscard]]
78 OpState<Rcvr> connect(Rcvr rcvr) && noexcept(std::is_nothrow_move_constructible_v<Rcvr>) {
79 return {std::move(rcvr)};
80 }
81
82 template <stdexec::receiver_of<completion_signatures> Rcvr>
83 [[nodiscard]]
84 OpState<Rcvr> connect(Rcvr rcvr) const & noexcept(std::is_nothrow_move_constructible_v<Rcvr>) {
85 return {std::move(rcvr)};
86 }
87
88 [[nodiscard]]
89 constexpr auto get_env() const noexcept -> const Attributes& {
90 return env;
91 }
92
94 };
95
96 [[nodiscard]]
97 constexpr auto schedule() const noexcept -> Sender {
98 return {state};
99 }
100
101 [[nodiscard]]
102 constexpr auto query(stdexec::get_completion_domain_t<stdexec::set_value_t>) const noexcept -> Domain {
103 return {};
104 }
105
106 [[nodiscard]]
107 constexpr auto query(stdexec::get_completion_scheduler_t<stdexec::set_value_t>) const noexcept -> Scheduler {
108 return {state};
109 }
110
111 [[nodiscard]]
112 friend bool operator==(const Scheduler&, const Scheduler&) noexcept = default;
113
115};
116
117} // namespace ExecutionSpaceImpl
118
126template <Kokkos::ExecutionSpace Exec>
129
131
132 explicit ExecutionSpaceContext(Exec exec) // NOLINT(performance-unnecessary-value-param)
133 : m_state{std::move(exec)} {
134 }
135
136 auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler<Exec> {
137 return {const_cast<state_t*>(&m_state)};
138 }
139};
140
141} // namespace Kokkos::Execution
142
143#endif // KOKKOS_EXECUTION_EXECUTION_SPACE_HPP
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< Exec >
ExecutionSpaceImpl::State< Exec > state_t
See https://github.com/NVIDIA/stdexec/blob/5076be2b35de2e78330201b888d82c81b8cb428b/include/nvexec/st...
constexpr auto query(stdexec::get_completion_domain_t< stdexec::set_value_t >, Env...) const noexcept -> Domain
constexpr auto query(stdexec::get_completion_scheduler_t< stdexec::set_value_t >, Env...) const noexcept -> Scheduler
OpState< Rcvr > connect(Rcvr rcvr) &&noexcept(std::is_nothrow_move_constructible_v< Rcvr >)
OpState< Rcvr > connect(Rcvr rcvr) const &noexcept(std::is_nothrow_move_constructible_v< Rcvr >)
constexpr auto get_env() const noexcept -> const Attributes &
stdexec::completion_signatures< stdexec::set_value_t()> completion_signatures
Scheduler for a Kokkos execution space.
stdexec::scheduler_t scheduler_concept
As per https://eel.is/c++draft/exec.sched#1.
friend bool operator==(const Scheduler &, const Scheduler &) noexcept=default
constexpr auto schedule() const noexcept -> Sender
constexpr auto query(stdexec::get_completion_domain_t< stdexec::set_value_t >) const noexcept -> Domain
constexpr auto query(stdexec::get_completion_scheduler_t< stdexec::set_value_t >) const noexcept -> Scheduler