kokkos-execution 0.0.1
Loading...
Searching...
No Matches
then.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_GRAPH_THEN_HPP
2#define KOKKOS_EXECUTION_GRAPH_THEN_HPP
3
5
6#if defined(KOKKOS_EXECUTION_ENABLE_DEBUG_LOGGING)
7# include "plog/Log.h"
8#endif
9
10#include "Kokkos_Graph.hpp"
11
13
23
25
26template <Kokkos::ExecutionSpace Exec, typename Functor>
28 using execution_space = Exec;
29 using device_handle_t = Kokkos::Impl::DeviceHandle<Exec>;
30 using node_props_t = typename Kokkos::Impl::NodeCtorProps<std::string, device_handle_t>::uniform_type;
31
32 template <NodeRef Predecessor>
33 using node_t = decltype(std::declval<const Predecessor&>()
34 .then(std::declval<node_props_t&&>(), std::declval<Functor&&>()));
35
37 template <NodeRef Predecessor>
38 auto add_node(const Predecessor& predecessor) && noexcept(false) -> node_t<Predecessor> {
39 auto node = predecessor.then(std::move(node_props), std::forward<Functor>(functor));
41 graph_add_node_event(predecessor, node);
42 return node;
43 }
45 Functor functor; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
46};
47
49template <typename Exec, typename Sndr, typename Functor>
50struct ThenSender {
51 using sender_concept = stdexec::sender_tag;
52
54
55 KOKKOS_EXECUTION_COMPL_SIGS_ADD(ThenSender, stdexec::set_error_t(std::exception_ptr))
56
58
60
62 Sndr sndr; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
63};
64
65template <>
66struct TransformSenderFor<stdexec::then_t> {
67 template <typename Env, typename Functor, typename Sndr>
69
70 template <typename Env, typename Functor, typename Sndr>
71 requires stdexec::__sends<stdexec::set_value_t, Sndr, Env>
72 auto operator()(const Env& env, stdexec::then_t, Functor&& functor, Sndr&& sndr) const
73 noexcept(std::is_nothrow_constructible_v<
76 Sndr&&
77 >) {
79 auto schd = stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(sndr), env);
80
82 .clsr =
83 {.node_props = Kokkos::Experimental::node_props(
84 std::string(Impl::dispatch_label<Impl::exec_of_t<Sndr, Env>, ": then">()),
85 Kokkos::Experimental::get_device_handle(schd.state->exec)),
86 .functor = std::forward<Functor>(functor)},
87 .sndr = std::forward<Sndr>(sndr)
88 };
89 } else {
91 }
92 }
93};
94
95} // namespace Kokkos::Execution::GraphImpl
96
97// NOLINTBEGIN(bugprone-reserved-identifier)
98namespace stdexec::__detail {
99template <typename Exec, typename Sndr, typename Functor>
100extern __mtype<Kokkos::Execution::GraphImpl::ThenSender<Exec, __demangle_t<Sndr>, Functor>>
101 __demangle_v<Kokkos::Execution::GraphImpl::ThenSender<Exec, Sndr, Functor>>;
102} // namespace stdexec::__detail
103// NOLINTEND(bugprone-reserved-identifier)
104
105#endif // KOKKOS_EXECUTION_GRAPH_THEN_HPP
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
#define KOKKOS_EXECUTION_COMPL_SIGS_ADD(_sndr_type_,...)
Completion signatures of _sndr_type_.
Concept for a sender whose completion scheduler is Kokkos::Execution::GraphImpl::Scheduler.
#define KOKKOS_EXECUTION_IMPL_GRAPH_ADD_NODE_DEBUG_LOGGING(_type_, _node_, _predecessor_)
#define KOKKOS_EXECUTION_GRAPH_OPERATION_STATE_CONNECT
void graph_add_node_event(const Predecessor &predecessor, const NodeType &node)
Record an event for a node added after predecessor.
Definition events.hpp:112
auto no_graph_scheduler_in_env() noexcept
Show a better compile diagnostic when there is no Kokkos::Execution::GraphImpl::Scheduler found.
typename completion_scheduler_of_t< stdexec::set_value_t, Sndr, Env... >::execution_space exec_of_t
Type of the execution space extracted from a sender's completion scheduler.
consteval std::string_view dispatch_label() noexcept
View the dispatch label as a std::string_view.
auto add_node(const Predecessor &predecessor) &&noexcept(false) -> node_t< Predecessor >
Definition then.hpp:38
typename Kokkos::Impl::NodeCtorProps< std::string, device_handle_t >::uniform_type node_props_t
Definition then.hpp:30
Kokkos::Impl::DeviceHandle< Exec > device_handle_t
Definition then.hpp:29
decltype(std::declval< const Predecessor & >() .then(std::declval< node_props_t && >(), std::declval< Functor && >())) node_t
Definition then.hpp:33
Sender for stdexec::then.
Definition then.hpp:50
stdexec::sender_tag sender_concept
Definition then.hpp:51
ThenClosure< Exec, Functor > closure_t
Definition then.hpp:53
auto operator()(const Env &env, stdexec::then_t, Functor &&functor, Sndr &&sndr) const noexcept(std::is_nothrow_constructible_v< trnsfrmd_sndr_t< Env, Functor, Sndr >, typename trnsfrmd_sndr_t< Env, Functor, Sndr >::closure_t, Sndr && >)
Definition then.hpp:72
ThenSender< Impl::exec_of_t< Sndr, Env >, Sndr, Functor > trnsfrmd_sndr_t
Definition then.hpp:68