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_Macros.hpp"
11#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
12import kokkos.core;
13import kokkos.graph;
14import kokkos.graph_impl;
15#else
16# include "Kokkos_Core.hpp"
17# include "Kokkos_Graph.hpp"
18#endif
19
21
31
33
34template <Kokkos::ExecutionSpace Exec, typename Functor>
36 using execution_space = Exec;
37 using device_handle_t = Kokkos::Impl::DeviceHandle<Exec>;
38 using node_props_t = typename Kokkos::Impl::NodeCtorProps<device_handle_t, std::string>::uniform_type;
39
40 template <NodeRef Predecessor>
41 using node_t = decltype(std::declval<const Predecessor&>()
42 .then(std::declval<node_props_t&&>(), std::declval<Functor&&>()));
43
45 template <NodeRef Predecessor>
46 auto add_node(const Predecessor& predecessor) && noexcept(false) -> node_t<Predecessor> {
47#if defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH) || defined(KOKKOS_EXECUTION_ENABLE_DEBUG_LOGGING)
48 auto label = Kokkos::Impl::get_property<std::string>(node_props);
49#endif
50 auto node = predecessor.then(std::move(node_props), std::forward<Functor>(functor));
51#if defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH) || defined(KOKKOS_EXECUTION_ENABLE_DEBUG_LOGGING)
53 graph_add_node_event(std::move(label), predecessor, node);
54#endif
55 return node;
56 }
57
59 Functor functor; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
60};
61
63template <typename Exec, typename Sndr, typename Functor>
64struct ThenSender {
65 using sender_concept = stdexec::sender_tag;
66
68
69 KOKKOS_EXECUTION_COMPL_SIGS_ADD(ThenSender, Sndr, stdexec::set_error_t(std::exception_ptr))
70
72
74
76 Sndr sndr; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
77};
78
79template <>
80struct TransformSenderFor<stdexec::then_t> {
81 template <typename Env, typename Functor, typename Sndr>
83
84 template <typename Env, typename Functor, typename Sndr>
85 requires(stdexec::__sends<stdexec::set_value_t, Sndr, Env> && graph_completing_sender<Sndr, Env>)
86 auto operator()(const Env& env, stdexec::then_t, Functor&& functor, Sndr&& sndr) const
87 noexcept(std::is_nothrow_constructible_v<
90 Sndr&&
91 >) {
92 const auto schd = stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(sndr), env);
93
95 .clsr =
96 {.node_props = Kokkos::Experimental::node_props(
97 Kokkos::Experimental::get_device_handle(schd.state->exec),
99 .functor = std::forward<Functor>(functor)},
100 .sndr = std::forward<Sndr>(sndr)
101 };
102 }
103
104 template <typename Env, typename Functor, typename Sndr>
105 requires stdexec::__sends<stdexec::set_value_t, Sndr, Env>
106 auto operator()(const Env&, stdexec::then_t, Functor&&, Sndr&&) const noexcept {
108 }
109};
110
111} // namespace Kokkos::Execution::GraphImpl
112
113#endif // KOKKOS_EXECUTION_GRAPH_THEN_HPP
#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_DISPATCH_LABEL(_exec_, _suffix_)
#define KOKKOS_EXECUTION_IMPL_GRAPH_ADD_NODE_DEBUG_LOGGING(_type_, _node_, _predecessor_)
#define KOKKOS_EXECUTION_GRAPH_OPERATION_STATE_CONNECT
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
void graph_add_node_event(Label &&label, const Predecessor &predecessor, const NodeType &node)
Record an event for a node added after predecessor.
Definition events.hpp:151
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:42
consteval Impl::Label< std::string_view > label(std::string_view str) noexcept
Definition label.hpp:91
auto add_node(const Predecessor &predecessor) &&noexcept(false) -> node_t< Predecessor >
Definition then.hpp:46
Kokkos::Impl::DeviceHandle< Exec > device_handle_t
Definition then.hpp:37
decltype(std::declval< const Predecessor & >() .then(std::declval< node_props_t && >(), std::declval< Functor && >())) node_t
Definition then.hpp:41
typename Kokkos::Impl::NodeCtorProps< device_handle_t, std::string >::uniform_type node_props_t
Definition then.hpp:38
Sender for stdexec::then.
Definition then.hpp:64
stdexec::sender_tag sender_concept
Definition then.hpp:65
ThenClosure< Exec, Functor > closure_t
Definition then.hpp:67
ThenSender< Impl::exec_of_t< Sndr, Env >, Sndr, Functor > trnsfrmd_sndr_t
Definition then.hpp:82
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:86
auto operator()(const Env &, stdexec::then_t, Functor &&, Sndr &&) const noexcept
Definition then.hpp:106