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
9
10namespace Kokkos::Execution {
11
12namespace GraphImpl {
13
14template <Kokkos::ExecutionSpace Exec>
15struct State {
16 Exec exec;
17};
18
20template <Kokkos::ExecutionSpace Exec>
21struct Scheduler {
23 using scheduler_concept = stdexec::scheduler_t;
24
25 using execution_space = Exec;
26
27 template <stdexec::receiver Rcvr>
28 struct OpState {
29 using operation_state_concept = stdexec::operation_state_t;
30
31 Rcvr rcvr;
32
34 void start() & noexcept {
35 stdexec::set_value(std::move(rcvr));
36 }
37 };
38
39 struct Sender {
40 using sender_concept = stdexec::sender_t;
41
42 using completion_signatures = stdexec::completion_signatures<stdexec::set_value_t()>;
43
45 struct Attributes {
46 template <typename... Env>
47 [[nodiscard]]
48 constexpr auto
49 query(stdexec::get_completion_scheduler_t<stdexec::set_value_t>, Env...) const noexcept -> Scheduler {
50 return {state};
51 }
52
53 template <typename... Env>
54 [[nodiscard]]
55 constexpr auto
56 query(stdexec::get_completion_domain_t<stdexec::set_value_t>, Env...) const noexcept -> Domain {
57 return {};
58 }
59
61 };
62
63 template <stdexec::receiver_of<completion_signatures> Rcvr>
64 [[nodiscard]]
65 OpState<Rcvr> connect(Rcvr rcvr) && noexcept(std::is_nothrow_move_constructible_v<Rcvr>) {
66 return {std::move(rcvr)};
67 }
68
69 template <stdexec::receiver_of<completion_signatures> Rcvr>
70 [[nodiscard]]
71 OpState<Rcvr> connect(Rcvr rcvr) const & noexcept(std::is_nothrow_move_constructible_v<Rcvr>) {
72 return {std::move(rcvr)};
73 }
74
75 [[nodiscard]]
76 constexpr auto get_env() const noexcept -> const Attributes& {
77 return env;
78 }
79
81 };
82
83 [[nodiscard]]
84 constexpr auto schedule() const noexcept -> Sender {
85 return {state};
86 }
87
88 [[nodiscard]]
89 constexpr auto query(stdexec::get_completion_domain_t<stdexec::set_value_t>) const noexcept -> Domain {
90 return {};
91 }
92
93 [[nodiscard]]
94 constexpr auto query(stdexec::get_completion_scheduler_t<stdexec::set_value_t>) const noexcept -> Scheduler {
95 return {state};
96 }
97
98 [[nodiscard]]
99 friend bool operator==(const Scheduler&, const Scheduler&) noexcept = default;
100
102};
103
104} // namespace GraphImpl
105
107template <Kokkos::ExecutionSpace Exec>
110
112
113 explicit GraphContext(Exec exec) // NOLINT(performance-unnecessary-value-param)
114 : m_state{std::move(exec)} {
115 }
116
117 auto get_scheduler() const noexcept -> GraphImpl::Scheduler<Exec> {
118 return {const_cast<state_t*>(&m_state)};
119 }
120};
121
122} // namespace Kokkos::Execution
123
124#endif // KOKKOS_EXECUTION_GRAPH_HPP
GraphImpl::State< Exec > state_t
Definition graph.hpp:109
auto get_scheduler() const noexcept -> GraphImpl::Scheduler< Exec >
Definition graph.hpp:117
stdexec::operation_state_t operation_state_concept
Definition graph.hpp:29
See https://github.com/NVIDIA/stdexec/blob/5076be2b35de2e78330201b888d82c81b8cb428b/include/nvexec/st...
Definition graph.hpp:45
constexpr auto query(stdexec::get_completion_scheduler_t< stdexec::set_value_t >, Env...) const noexcept -> Scheduler
Definition graph.hpp:49
constexpr auto query(stdexec::get_completion_domain_t< stdexec::set_value_t >, Env...) const noexcept -> Domain
Definition graph.hpp:56
OpState< Rcvr > connect(Rcvr rcvr) &&noexcept(std::is_nothrow_move_constructible_v< Rcvr >)
Definition graph.hpp:65
constexpr auto get_env() const noexcept -> const Attributes &
Definition graph.hpp:76
OpState< Rcvr > connect(Rcvr rcvr) const &noexcept(std::is_nothrow_move_constructible_v< Rcvr >)
Definition graph.hpp:71
stdexec::completion_signatures< stdexec::set_value_t()> completion_signatures
Definition graph.hpp:42
Scheduler for a Kokkos::Experimental::Graph.
Definition graph.hpp:21
constexpr auto query(stdexec::get_completion_domain_t< stdexec::set_value_t >) const noexcept -> Domain
Definition graph.hpp:89
constexpr auto query(stdexec::get_completion_scheduler_t< stdexec::set_value_t >) const noexcept -> Scheduler
Definition graph.hpp:94
friend bool operator==(const Scheduler &, const Scheduler &) noexcept=default
constexpr auto schedule() const noexcept -> Sender
Definition graph.hpp:84
stdexec::scheduler_t scheduler_concept
As per https://eel.is/c++draft/exec.sched#1.
Definition graph.hpp:23