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_Macros.hpp"
7#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
8import kokkos.core;
9#else
10# include "Kokkos_Core.hpp"
11#endif
12
25
27
29
36template <Kokkos::ExecutionSpace Exec>
37struct Scheduler {
39 using scheduler_concept = stdexec::scheduler_t;
40
41 using execution_space = Exec;
42
43 template <stdexec::receiver Rcvr>
44 struct OpState {
45 using operation_state_concept = stdexec::operation_state_tag;
46
47 Rcvr rcvr;
48
50 void start() & noexcept {
51 stdexec::set_value(std::move(rcvr));
52 }
53 };
54
55 struct Sender {
56 using sender_concept = stdexec::sender_tag;
57
58 using completion_signatures = stdexec::completion_signatures<stdexec::set_value_t()>;
59
61 struct Attributes {
62 template <typename... Env>
63 [[nodiscard]]
64 constexpr auto
65 query(stdexec::get_completion_scheduler_t<stdexec::set_value_t>, Env...) const noexcept -> Scheduler {
66 return {state};
67 }
68
69 template <typename... Env>
70 [[nodiscard]]
71 constexpr auto
72 query(stdexec::get_completion_domain_t<stdexec::set_value_t>, Env...) const noexcept -> Domain {
73 return {};
74 }
75
77 };
78
79 template <stdexec::receiver_of<completion_signatures> Rcvr>
80 [[nodiscard]]
81 OpState<Rcvr> connect(Rcvr rcvr) && noexcept(std::is_nothrow_move_constructible_v<Rcvr>) {
82 return {std::move(rcvr)};
83 }
84
85 template <stdexec::receiver_of<completion_signatures> Rcvr>
86 [[nodiscard]]
87 OpState<Rcvr> connect(Rcvr rcvr) const & noexcept(std::is_nothrow_move_constructible_v<Rcvr>) {
88 return {std::move(rcvr)};
89 }
90
91 [[nodiscard]]
92 constexpr auto get_env() const noexcept -> const Attributes& {
93 return env;
94 }
95
97 };
98
99 [[nodiscard]]
100 constexpr auto schedule() const noexcept -> Sender {
101 return {state};
102 }
103
104 [[nodiscard]]
105 constexpr auto query(stdexec::get_completion_domain_t<stdexec::set_value_t>) const noexcept -> Domain {
106 return {};
107 }
108
109 [[nodiscard]]
110 constexpr auto query(stdexec::get_completion_scheduler_t<stdexec::set_value_t>) const noexcept -> Scheduler {
111 return {state};
112 }
113
114 [[nodiscard]]
115 friend bool operator==(const Scheduler&, const Scheduler&) noexcept = default;
116
118};
119
120} // namespace ExecutionSpaceImpl
121
129template <Kokkos::ExecutionSpace Exec>
131 using execution_space = Exec;
132
134
136
137 explicit ExecutionSpaceContext(execution_space exec) // NOLINT(performance-unnecessary-value-param)
138 : m_state{std::move(exec)} {
139 }
140
141 auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler<execution_space> {
142 return {const_cast<state_t*>(&m_state)};
143 }
144};
145
146} // namespace Kokkos::Execution
147
148#endif // KOKKOS_EXECUTION_EXECUTION_SPACE_HPP
Impl::State< execution_space > state_t
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< execution_space >
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