kokkos-execution 0.0.1
Loading...
Searching...
No Matches
then.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_EXECUTION_SPACE_THEN_HPP
2#define KOKKOS_EXECUTION_EXECUTION_SPACE_THEN_HPP
3
5
11
13
14template <Kokkos::ExecutionSpace Exec, typename Label, typename Functor>
16 using execution_space = Exec;
17
18 void submit() const & {
19 Kokkos::single(Impl::as_convertible_to_string(label), this->get_policy(), functor);
20 }
21
23 [[nodiscard]]
24 auto get_policy() const & noexcept {
25 return Kokkos::SinglePolicy<execution_space>{state->exec};
26 }
27
29 Label label;
30 Functor functor;
31};
32
33template <typename Tag, stdexec::sender Sndr, Kokkos::ExecutionSpace Exec, typename Label, typename Functor>
34struct ThenSender {
35 using sender_concept = stdexec::sender_tag;
36
37 using execution_space = Exec;
39
41 Sndr sndr; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
42
43 KOKKOS_EXECUTION_COMPL_SIGS_ADD(ThenSender, Sndr, stdexec::set_error_t(std::exception_ptr))
44
45 template <stdexec::receiver Rcvr>
46 constexpr auto connect(Rcvr rcvr) && noexcept(noexcept(make_op_state_t<Sndr, Rcvr, closure_t>{}(
47 std::declval<Sndr>(),
48 std::declval<Rcvr>(),
49 std::declval<closure_t>()))) -> op_state_t<Sndr, Rcvr, closure_t> {
50 return make_op_state_t<Sndr, Rcvr, closure_t>{}(std::forward<Sndr>(sndr), std::move(rcvr), std::move(clsr));
51 }
52
54};
55
56template <>
57struct TransformSenderFor<stdexec::then_t> {
58 template <typename Env, typename Functor, typename Sndr>
59 struct Transformer {
61
62 using sndr_t =
64
65 auto operator()(const Env& env, std::remove_reference_t<Functor>& functor, std::remove_reference_t<Sndr>& sndr)
66 const STDEXEC_AUTO_RETURN(
67 sndr_t{
68 {.state = stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(sndr), env)
69 .state,
71 .functor = std::forward<Functor>(functor)},
72 std::forward<Sndr>(sndr)
73 })
74 };
75
76 template <typename Env, typename Functor, typename Sndr>
77 requires(stdexec::__sends<stdexec::set_value_t, Sndr, Env> && execution_space_completing_sender<Sndr, Env>)
78 auto operator()(
79 const Env& env,
80 stdexec::then_t,
81 Functor&& functor, // NOLINT(cppcoreguidelines-missing-std-forward)
82 Sndr&& sndr // NOLINT(cppcoreguidelines-missing-std-forward)
83 ) const STDEXEC_AUTO_RETURN(Transformer<Env, Functor, Sndr>{}(env, functor, sndr))
84
85 template <typename Env, typename Functor, typename Sndr>
86 requires stdexec::__sends<stdexec::set_value_t, Sndr, Env>
87 auto operator()(const Env&, stdexec::then_t, Functor&&, Sndr&&) const noexcept {
89 }
90};
91
92} // namespace Kokkos::Execution::ExecutionSpaceImpl
93
94#endif // KOKKOS_EXECUTION_EXECUTION_SPACE_THEN_HPP
#define KOKKOS_EXECUTION_COMPL_SIGS_ADD(_decayed_self_type_, _sndr_type_,...)
Concept for a sender whose completion scheduler is Kokkos::Execution::ExecutionSpaceImpl::Scheduler.
#define KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(_exec_, _suffix_)
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
auto no_execution_space_scheduler_in_env() noexcept
Show a better compile diagnostic when there is no Kokkos::Execution::ExecutionSpaceImpl::Scheduler fo...
typename make_op_state_t< Sndr, Rcvr, Clsrs... >::type op_state_t
Impl::MakeOpState< Domain, OpState >::Huddle< Sndr, Rcvr, Clsrs... > make_op_state_t
constexpr auto as_convertible_to_string(T &&value) noexcept(noexcept(std::forward< T >(value))) -> decltype(std::forward< T >(value))
Convert to a value usable as a std::string.
Definition label.hpp:75
typename ExecOf< Args... >::type exec_of_t
Definition get_exec.hpp:42
constexpr auto connect(Rcvr rcvr) &&noexcept(noexcept(make_op_state_t< Sndr, Rcvr, closure_t >{}(std::declval< Sndr >(), std::declval< Rcvr >(), std::declval< closure_t >()))) -> op_state_t< Sndr, Rcvr, closure_t >
Definition then.hpp:46
ThenClosure< execution_space, Label, Functor > closure_t
Definition then.hpp:38
auto operator()(const Env &env, std::remove_reference_t< Functor > &functor, std::remove_reference_t< Sndr > &sndr) const noexcept(noexcept(sndr_t{ {.state=stdexec::get_completion_scheduler< stdexec::set_value_t >(stdexec::get_env(sndr), env) .state,.label=Kokkos::Execution::Impl::dispatch_label< execution_space, ": then">(),.functor=std::forward< Functor >(functor)}, std::forward< Sndr >(sndr) })) -> decltype(sndr_t{ {.state=stdexec::get_completion_scheduler< stdexec::set_value_t >(stdexec::get_env(sndr), env) .state,.label=Kokkos::Execution::Impl::dispatch_label< execution_space, ": then">(),.functor=std::forward< Functor >(functor)}, std::forward< Sndr >(sndr) })
Definition then.hpp:65
ThenSender< stdexec::then_t, Sndr, execution_space, std::string_view, std::remove_cvref_t< Functor > > sndr_t
Definition then.hpp:62