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
19
21
23
30template <Kokkos::ExecutionSpace Exec>
31struct Scheduler {
33 using scheduler_concept = stdexec::scheduler_t;
34
35 using execution_space = Exec;
36
37 template <stdexec::receiver Rcvr>
38 struct OpState {
39 using operation_state_concept = stdexec::operation_state_tag;
40
41 Rcvr rcvr;
42
44 void start() & noexcept {
45 stdexec::set_value(std::move(rcvr));
46 }
47 };
48
49 struct Sender {
50 using sender_concept = stdexec::sender_tag;
51
52 using completion_signatures = stdexec::completion_signatures<stdexec::set_value_t()>;
53
55 struct Attributes {
56 template <typename... Env>
57 [[nodiscard]]
58 constexpr auto
59 query(stdexec::get_completion_scheduler_t<stdexec::set_value_t>, Env...) const noexcept -> Scheduler {
60 return {state};
61 }
62
63 template <typename... Env>
64 [[nodiscard]]
65 constexpr auto
66 query(stdexec::get_completion_domain_t<stdexec::set_value_t>, Env...) const noexcept -> Domain {
67 return {};
68 }
69
71 };
72
73 template <stdexec::receiver_of<completion_signatures> Rcvr>
74 [[nodiscard]]
75 OpState<Rcvr> connect(Rcvr rcvr) && noexcept(std::is_nothrow_move_constructible_v<Rcvr>) {
76 return {std::move(rcvr)};
77 }
78
79 template <stdexec::receiver_of<completion_signatures> Rcvr>
80 [[nodiscard]]
81 OpState<Rcvr> connect(Rcvr rcvr) const & noexcept(std::is_nothrow_move_constructible_v<Rcvr>) {
82 return {std::move(rcvr)};
83 }
84
85 [[nodiscard]]
86 constexpr auto get_env() const noexcept -> const Attributes& {
87 return env;
88 }
89
91 };
92
93 [[nodiscard]]
94 constexpr auto schedule() const noexcept -> Sender {
95 return {state};
96 }
97
98 [[nodiscard]]
99 constexpr auto query(stdexec::get_completion_domain_t<stdexec::set_value_t>) const noexcept -> Domain {
100 return {};
101 }
102
103 [[nodiscard]]
104 constexpr auto query(stdexec::get_completion_scheduler_t<stdexec::set_value_t>) const noexcept -> Scheduler {
105 return {state};
106 }
107
108 [[nodiscard]]
109 friend bool operator==(const Scheduler&, const Scheduler&) noexcept = default;
110
112};
113
114} // namespace ExecutionSpaceImpl
115
123template <Kokkos::ExecutionSpace Exec>
126
128
129 explicit ExecutionSpaceContext(Exec exec) // NOLINT(performance-unnecessary-value-param)
130 : m_state{std::move(exec)} {
131 }
132
133 auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler<Exec> {
134 return {const_cast<state_t*>(&m_state)};
135 }
136};
137
138} // namespace Kokkos::Execution
139
140#endif // KOKKOS_EXECUTION_EXECUTION_SPACE_HPP
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< Exec >
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