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 device_handle = Kokkos::Impl::get_property<device_handle_t>(node_props);
40 auto node = predecessor.then(std::move(node_props), std::forward<Functor>(functor));
42 graph_add_node_event(predecessor, node, device_handle);
43 return node;
44 }
46 Functor functor; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
47};
48
50template <typename Exec, typename Sndr, typename Functor>
51struct ThenSender {
52 using sender_concept = stdexec::sender_tag;
53
55
56 KOKKOS_EXECUTION_COMPL_SIGS_ADD(ThenSender, Sndr, stdexec::set_error_t(std::exception_ptr))
57
59
61
63 Sndr sndr; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
64};
65
66template <>
67struct TransformSenderFor<stdexec::then_t> {
68 template <typename Env, typename Functor, typename Sndr>
70
71 template <typename Env, typename Functor, typename Sndr>
72 requires stdexec::__sends<stdexec::set_value_t, Sndr, Env>
73 auto operator()(const Env& env, stdexec::then_t, Functor&& functor, Sndr&& sndr) const
74 noexcept(std::is_nothrow_constructible_v<
77 Sndr&&
78 >) {
80 auto schd = stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(sndr), env);
81
83 .clsr =
84 {.node_props = Kokkos::Experimental::node_props(
85 std::string(Impl::dispatch_label<Impl::exec_of_t<Sndr, Env>, ": then">()),
86 Kokkos::Experimental::get_device_handle(schd.state->exec)),
87 .functor = std::forward<Functor>(functor)},
88 .sndr = std::forward<Sndr>(sndr)
89 };
90 } else {
92 }
93 }
94};
95
96} // namespace Kokkos::Execution::GraphImpl
97
98// NOLINTBEGIN(bugprone-reserved-identifier)
99namespace stdexec::__detail {
100template <typename Exec, typename Sndr, typename Functor>
101extern __mtype<Kokkos::Execution::GraphImpl::ThenSender<Exec, __demangle_t<Sndr>, Functor>>
102 __demangle_v<Kokkos::Execution::GraphImpl::ThenSender<Exec, Sndr, Functor>>;
103} // namespace stdexec::__detail
104// NOLINTEND(bugprone-reserved-identifier)
105
106#endif // KOKKOS_EXECUTION_GRAPH_THEN_HPP
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
#define KOKKOS_EXECUTION_COMPL_SIGS_ADD(_decayed_self_type_, _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, const Kokkos::Impl::DeviceHandle< Exec > &device_handle)
Record an event for a node added after predecessor.
Definition events.hpp:129
auto no_graph_scheduler_in_env() noexcept
Show a better compile diagnostic when there is no Kokkos::Execution::GraphImpl::Scheduler found.
typename ExecOf< Args... >::type exec_of_t
Definition get_exec.hpp:37
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:51
stdexec::sender_tag sender_concept
Definition then.hpp:52
ThenClosure< Exec, Functor > closure_t
Definition then.hpp:54
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:73
ThenSender< Impl::exec_of_t< Sndr, Env >, Sndr, Functor > trnsfrmd_sndr_t
Definition then.hpp:69