kokkos-execution 0.0.1
Loading...
Searching...
No Matches
schedule_from.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_GRAPH_SCHEDULE_FROM_HPP
2#define KOKKOS_EXECUTION_GRAPH_SCHEDULE_FROM_HPP
3
5
7
15
17
18template <stdexec::receiver Rcvr>
20 Rcvr rcvr;
21
22 KOKKOS_EXECUTION_GET_ENV(Rcvr, this->rcvr)
23};
24
26template <Kokkos::ExecutionSpace Exec, stdexec::sender Sndr, stdexec::receiver Rcvr>
28 : public Impl::Immovable
29 , public ScheduleFromOpStateBase<Rcvr> {
31
32 using execution_space = Exec;
33
35
37 using inner_op_state_t = stdexec::connect_result_t<Sndr, rcvr_t>;
38
40
42
43 ScheduleFromOpState(Sndr&& sndr, Rcvr rcvr) noexcept( // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
44 stdexec::__nothrow_connectable<Sndr&&, rcvr_t>)
45 : base_t(std::move(rcvr))
46 , inner_op_state(stdexec::connect(std::forward<Sndr>(sndr), rcvr_t{this})) {
47 }
48
49 [[nodiscard]]
50 constexpr auto query(Impl::get_exec_t) const noexcept -> decltype(auto)
51 requires stdexec::__queryable_with<inner_op_state_t, Impl::get_exec_t>
52 {
54 }
55
56 void complete(stdexec::set_value_t) noexcept {
57 stdexec::set_value(std::move(this->rcvr));
58 }
59
60 template <typename Error>
61 void complete(stdexec::set_error_t, Error&& error) noexcept {
62 stdexec::set_error(std::move(this->rcvr), std::forward<Error>(error));
63 }
64
65 void complete(stdexec::set_stopped_t) noexcept {
66 stdexec::set_stopped(std::move(this->rcvr));
67 }
68
69 void start() & noexcept {
70 stdexec::start(inner_op_state);
71 }
72
74 void submit() noexcept requires std::same_as<completion_signal_policy_t, Impl::SubmittedPolicy::OrderOnExec>
75 {
76 std::move(this->rcvr).submitted();
77 }
78
80 void submit() noexcept requires std::same_as<completion_signal_policy_t, Impl::SyncPolicy::InlineFenceExec>
81 {
82 try {
84 .get()
85 .fence(
86 std::string(
87 KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(Impl::exec_of_t<decltype(*this)>, ": schedule_from")));
88 } catch (...) {
89 stdexec::set_error(std::move(this->rcvr), std::current_exception());
90 return;
91 }
92 stdexec::set_value(std::move(this->rcvr));
93 }
94};
95
97template <stdexec::operation_state OpState, Kokkos::ExecutionSpace Exec>
98requires(
99 stdexec::__is_instance_of<OpState, Kokkos::Execution::GraphImpl::ScheduleFromOpState>
100 && std::same_as<typename OpState::execution_space, Exec>)
101struct GraphOperationStateFor<OpState, Exec> : public std::true_type { };
102
104template <typename Exec, typename Sndr>
106 using sender_concept = stdexec::sender_tag;
107
108 using execution_space = Exec;
109
111
112 template <typename Self, typename Rcvr>
114
115 template <typename Self, typename Rcvr>
116 static constexpr bool is_nothrow_connectable_v = std::is_nothrow_constructible_v<
119 Rcvr&&
120 >;
121
122 template <stdexec::__decays_to<ScheduleFromSender> Self, stdexec::receiver Rcvr>
123 STDEXEC_EXPLICIT_THIS_BEGIN(
124 auto connect)(this Self&& self, Rcvr rcvr) // NOLINT(cppcoreguidelines-missing-std-forward)
126 return {std::forward<Self>(self).sndr, std::move(rcvr)};
127 }
128 STDEXEC_EXPLICIT_THIS_END(connect)
129
131
132 Sndr sndr; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
133};
134
135template <>
136struct TransformSenderFor<stdexec::schedule_from_t> {
137 template <typename Env, stdexec::sender Sndr>
138 requires stdexec::__sends<stdexec::set_value_t, Sndr, Env>
139 auto operator()(const Env&, stdexec::schedule_from_t, stdexec::__ignore, Sndr&& sndr) const
140 noexcept(std::is_nothrow_constructible_v<ScheduleFromSender<Impl::exec_of_t<Sndr, Env>, Sndr>, Sndr&&>) {
142 return ScheduleFromSender<Impl::exec_of_t<Sndr, Env>, Sndr>{.sndr = std::forward<Sndr>(sndr)};
143 } else {
145 }
146 }
147};
148
149} // namespace Kokkos::Execution::GraphImpl
150
151#endif // KOKKOS_EXECUTION_GRAPH_SCHEDULE_FROM_HPP
#define KOKKOS_EXECUTION_COMPL_SIGS_KEEP(_decayed_self_type_, _sndr_type_)
Concept for a sender whose completion scheduler is Kokkos::Execution::GraphImpl::Scheduler.
#define KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(_exec_, _suffix_)
#define KOKKOS_EXECUTION_GET_ENV(_type_, _obj_)
Retrieve the environment of _obj_. // NOLINTNEXTLINE(cppcoreguidelines-macro-usage).
Definition env.hpp:14
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
auto no_graph_scheduler_in_env() noexcept
Show a better compile diagnostic when there is no Kokkos::Execution::GraphImpl::Scheduler found.
std::conditional_t< ScheduleFrom::signals_submitted< InnerOp, Rcvr >, Impl::SubmittedPolicy::OrderOnExec, Impl::SyncPolicy::InlineFenceExec > completion_signal_policy_t
constexpr get_exec_t get_exec
Definition get_exec.hpp:24
typename ExecOf< Args... >::type exec_of_t
Definition get_exec.hpp:42
Operation state for stdexec::schedule_from.
void complete(stdexec::set_value_t) noexcept
ScheduleFromOpState(Sndr &&sndr, Rcvr rcvr) noexcept(//NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) stdexec::__nothrow_connectable< Sndr &&, rcvr_t >)
Impl::Receiver< ScheduleFromOpState, stdexec::env_of_t< Rcvr > > rcvr_t
Impl::ScheduleFrom::completion_signal_policy_t< inner_op_state_t, Rcvr > completion_signal_policy_t
void complete(stdexec::set_error_t, Error &&error) noexcept
void submit() noexcept
Transition to another domain.
stdexec::connect_result_t< Sndr, rcvr_t > inner_op_state_t
void submit() noexcept
Stay in the Kokkos::Execution::GraphImpl::Domain.
void complete(stdexec::set_stopped_t) noexcept
Impl::SubmittedOperationStateTag operation_state_concept
constexpr auto query(Impl::get_exec_t) const noexcept -> decltype(auto)
ScheduleFromOpState< execution_space, stdexec::__copy_cvref_t< Self, Sndr >, Rcvr > connect_result_t
auto connect(this Self &&self, Rcvr rcvr) noexcept(is_nothrow_connectable_v< Self, Rcvr >) -> connect_result_t< Self, Rcvr >
auto operator()(const Env &, stdexec::schedule_from_t, stdexec::__ignore, Sndr &&sndr) const noexcept(std::is_nothrow_constructible_v< ScheduleFromSender< Impl::exec_of_t< Sndr, Env >, Sndr >, Sndr && >)
Receiver for an object parent_op that implements complete.
Definition receiver.hpp:13
#define KOKKOS_EXECUTION_IMPL_MEMBER_CVREF_T(_Self_, _member_)
Yields the type of member _member_ as accessed from expression _Self_, preserving the cv and ref qual...