kokkos-execution 0.0.1
Loading...
Searching...
No Matches
graph.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_GRAPH_HPP
2#define KOKKOS_EXECUTION_GRAPH_HPP
3
5
6#include "Kokkos_Core.hpp"
7
17
18namespace Kokkos::Execution {
19
20namespace GraphImpl {
21
23template <Kokkos::ExecutionSpace Exec>
24struct Scheduler {
26 using scheduler_concept = stdexec::scheduler_t;
27
28 using execution_space = Exec;
29
30 template <stdexec::receiver Rcvr>
31 struct OpState {
32 using operation_state_concept = stdexec::operation_state_tag;
33
35 Rcvr rcvr;
36
37 [[nodiscard]]
39 return Impl::ExecutionSpaceRef{state->exec};
40 }
41
43 void start() & noexcept {
44 stdexec::set_value(std::move(rcvr));
45 }
46 };
47
48 struct Sender {
49 using sender_concept = stdexec::sender_tag;
50
51 using completion_signatures = stdexec::completion_signatures<stdexec::set_value_t()>;
52
54 struct Attributes {
55 template <typename... Env>
56 [[nodiscard]]
57 constexpr auto
58 query(stdexec::get_completion_scheduler_t<stdexec::set_value_t>, Env...) const noexcept -> Scheduler {
59 return {state};
60 }
61
62 template <typename... Env>
63 [[nodiscard]]
64 constexpr auto
65 query(stdexec::get_completion_domain_t<stdexec::set_value_t>, Env...) const noexcept -> Domain {
66 return {};
67 }
68
70 };
71
72 template <stdexec::receiver_of<completion_signatures> Rcvr>
73 [[nodiscard]]
74 OpState<Rcvr> connect(Rcvr rcvr) && noexcept(std::is_nothrow_move_constructible_v<Rcvr>) {
75 return {.state = env.state, .rcvr = std::move(rcvr)};
76 }
77
78 template <stdexec::receiver_of<completion_signatures> Rcvr>
79 [[nodiscard]]
80 OpState<Rcvr> connect(Rcvr rcvr) const & noexcept(std::is_nothrow_move_constructible_v<Rcvr>) {
81 return {.state = env.state, .rcvr = std::move(rcvr)};
82 }
83
84 [[nodiscard]]
85 constexpr auto get_env() const noexcept -> const Attributes& {
86 return env;
87 }
88
90 };
91
92 [[nodiscard]]
93 constexpr auto schedule() const noexcept -> Sender {
94 return {state};
95 }
96
97 [[nodiscard]]
98 constexpr auto query(stdexec::get_completion_domain_t<stdexec::set_value_t>) const noexcept -> Domain {
99 return {};
100 }
101
102 [[nodiscard]]
103 constexpr auto query(stdexec::get_completion_scheduler_t<stdexec::set_value_t>) const noexcept -> Scheduler {
104 return {state};
105 }
106
107 [[nodiscard]]
108 friend bool operator==(const Scheduler&, const Scheduler&) noexcept = default;
109
111};
112
113} // namespace GraphImpl
114
116template <Kokkos::ExecutionSpace Exec>
119
121
122 explicit GraphContext(Exec exec) // NOLINT(performance-unnecessary-value-param)
123 : m_state{std::move(exec)} {
124 }
125
126 auto get_scheduler() const noexcept -> GraphImpl::Scheduler<Exec> {
127 return {const_cast<state_t*>(&m_state)};
128 }
129};
130
131} // namespace Kokkos::Execution
132
133#endif // KOKKOS_EXECUTION_GRAPH_HPP
auto get_scheduler() const noexcept -> GraphImpl::Scheduler< Exec >
Definition graph.hpp:126
Impl::State< Exec > state_t
Definition graph.hpp:118
constexpr auto query(Impl::get_exec_t) const noexcept -> Impl::ExecutionSpaceRef< execution_space >
Definition graph.hpp:38
Impl::State< execution_space > * state
Definition graph.hpp:34
stdexec::operation_state_tag operation_state_concept
Definition graph.hpp:32
See https://github.com/NVIDIA/stdexec/blob/5076be2b35de2e78330201b888d82c81b8cb428b/include/nvexec/st...
Definition graph.hpp:54
constexpr auto query(stdexec::get_completion_scheduler_t< stdexec::set_value_t >, Env...) const noexcept -> Scheduler
Definition graph.hpp:58
constexpr auto query(stdexec::get_completion_domain_t< stdexec::set_value_t >, Env...) const noexcept -> Domain
Definition graph.hpp:65
OpState< Rcvr > connect(Rcvr rcvr) &&noexcept(std::is_nothrow_move_constructible_v< Rcvr >)
Definition graph.hpp:74
constexpr auto get_env() const noexcept -> const Attributes &
Definition graph.hpp:85
OpState< Rcvr > connect(Rcvr rcvr) const &noexcept(std::is_nothrow_move_constructible_v< Rcvr >)
Definition graph.hpp:80
stdexec::completion_signatures< stdexec::set_value_t()> completion_signatures
Definition graph.hpp:51
Scheduler for a Kokkos::Experimental::Graph.
Definition graph.hpp:24
constexpr auto query(stdexec::get_completion_domain_t< stdexec::set_value_t >) const noexcept -> Domain
Definition graph.hpp:98
constexpr auto query(stdexec::get_completion_scheduler_t< stdexec::set_value_t >) const noexcept -> Scheduler
Definition graph.hpp:103
friend bool operator==(const Scheduler &, const Scheduler &) noexcept=default
constexpr auto schedule() const noexcept -> Sender
Definition graph.hpp:93
stdexec::scheduler_t scheduler_concept
As per https://eel.is/c++draft/exec.sched#1.
Definition graph.hpp:26
Wrap a Kokkos execution space to make it cheap to copy/move in new environments.
Definition get_exec.hpp:47