kokkos-execution
0.0.1
Toggle main menu visibility
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
4
#include "
kokkos-execution/stdexec.hpp
"
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
12
import
kokkos.core;
13
import
kokkos.graph;
14
import
kokkos.graph_impl;
15
#else
16
# include "Kokkos_Core.hpp"
17
# include "Kokkos_Graph.hpp"
18
#endif
19
20
#include "
kokkos-execution/graph/graph_fwd.hpp
"
21
22
#include "
kokkos-execution/graph/events.hpp
"
23
#include "
kokkos-execution/graph/operation_state.hpp
"
24
#include "
kokkos-execution/graph/sender_concepts.hpp
"
25
#include "
kokkos-execution/impl/attributes.hpp
"
26
#include "
kokkos-execution/impl/completion_signatures.hpp
"
27
#include "
kokkos-execution/impl/dispatch_label.hpp
"
28
#include "
kokkos-execution/impl/env.hpp
"
29
#include "
kokkos-execution/impl/sender_concepts.hpp
"
30
#include "
kokkos-execution/impl/sender_introspection.hpp
"
31
32
namespace
Kokkos::Execution::GraphImpl
{
33
34
template
<Kokkos::ExecutionSpace Exec,
typename
Functor>
35
struct
ThenClosure
{
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)
52
KOKKOS_EXECUTION_IMPL_GRAPH_ADD_NODE_DEBUG_LOGGING
(
label
, node, predecessor)
53
graph_add_node_event
(std::move(
label
), predecessor, node);
54
#endif
55
return
node;
56
}
57
58
node_props_t
node_props
;
59
Functor
functor
;
// NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
60
};
61
63
template
<
typename
Exec,
typename
Sndr,
typename
Functor>
64
struct
ThenSender
{
65
using
sender_concept
= stdexec::sender_tag;
66
67
using
closure_t
=
ThenClosure<Exec, Functor>
;
68
69
KOKKOS_EXECUTION_COMPL_SIGS_ADD
(
ThenSender
, Sndr, stdexec::set_error_t(std::exception_ptr))
70
71
KOKKOS_EXECUTION_GRAPH_OPERATION_STATE_CONNECT
72
73
KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV
(Sndr,
sndr
)
74
75
closure_t
clsr
;
76
Sndr
sndr
;
// NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
77
};
78
79
template <>
80
struct
TransformSenderFor
<
stdexec
::then_t> {
81
template
<
typename
Env,
typename
Functor,
typename
Sndr>
82
using
trnsfrmd_sndr_t
=
ThenSender<Impl::exec_of_t<Sndr, Env>
, Sndr, Functor>;
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<
88
trnsfrmd_sndr_t<Env, Functor, Sndr>
,
89
typename
trnsfrmd_sndr_t<Env, Functor, Sndr>::closure_t
,
90
Sndr&&
91
>) {
92
const
auto
schd = stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(
sndr
), env);
93
94
return
trnsfrmd_sndr_t<Env, Functor, Sndr>
{
95
.clsr =
96
{.node_props = Kokkos::Experimental::node_props(
97
Kokkos::Experimental::get_device_handle(schd.state->exec),
98
std::string(
KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL
((
Impl::exec_of_t<Sndr, Env>
),
": then"
))),
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 {
107
return
no_graph_scheduler_in_env<stdexec::then_t, Sndr, Env>
();
108
}
109
};
110
111
}
// namespace Kokkos::Execution::GraphImpl
112
113
#endif
// KOKKOS_EXECUTION_GRAPH_THEN_HPP
completion_signatures.hpp
KOKKOS_EXECUTION_COMPL_SIGS_ADD
#define KOKKOS_EXECUTION_COMPL_SIGS_ADD(_decayed_self_type_, _sndr_type_,...)
Definition
completion_signatures.hpp:32
Kokkos::Execution::GraphImpl::graph_completing_sender
Concept for a sender whose completion scheduler is Kokkos::Execution::GraphImpl::Scheduler.
Definition
sender_concepts.hpp:12
dispatch_label.hpp
KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL
#define KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(_exec_, _suffix_)
Definition
dispatch_label.hpp:51
operation_state.hpp
KOKKOS_EXECUTION_IMPL_GRAPH_ADD_NODE_DEBUG_LOGGING
#define KOKKOS_EXECUTION_IMPL_GRAPH_ADD_NODE_DEBUG_LOGGING(_type_, _node_, _predecessor_)
Definition
operation_state.hpp:336
KOKKOS_EXECUTION_GRAPH_OPERATION_STATE_CONNECT
#define KOKKOS_EXECUTION_GRAPH_OPERATION_STATE_CONNECT
Definition
operation_state.hpp:322
sender_concepts.hpp
graph_fwd.hpp
env.hpp
sender_concepts.hpp
events.hpp
attributes.hpp
KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
Definition
attributes.hpp:30
stdexec.hpp
Kokkos::Execution::GraphImpl
Definition
graph.hpp:26
Kokkos::Execution::GraphImpl::graph_add_node_event
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
Kokkos::Execution::GraphImpl::no_graph_scheduler_in_env
auto no_graph_scheduler_in_env() noexcept
Show a better compile diagnostic when there is no Kokkos::Execution::GraphImpl::Scheduler found.
Definition
diagnostics.hpp:31
Kokkos::Execution::Impl::exec_of_t
typename ExecOf< Args... >::type exec_of_t
Definition
get_exec.hpp:42
Kokkos::Execution::label
consteval Impl::Label< std::string_view > label(std::string_view str) noexcept
Definition
label.hpp:91
stdexec
Definition
when_all.hpp:16
sender_introspection.hpp
Kokkos::Execution::GraphImpl::ThenClosure
Definition
then.hpp:35
Kokkos::Execution::GraphImpl::ThenClosure::add_node
auto add_node(const Predecessor &predecessor) &&noexcept(false) -> node_t< Predecessor >
Definition
then.hpp:46
Kokkos::Execution::GraphImpl::ThenClosure::node_props
node_props_t node_props
Definition
then.hpp:58
Kokkos::Execution::GraphImpl::ThenClosure::functor
Functor functor
Definition
then.hpp:59
Kokkos::Execution::GraphImpl::ThenClosure::device_handle_t
Kokkos::Impl::DeviceHandle< Exec > device_handle_t
Definition
then.hpp:37
Kokkos::Execution::GraphImpl::ThenClosure::execution_space
Exec execution_space
Definition
then.hpp:36
Kokkos::Execution::GraphImpl::ThenClosure::node_t
decltype(std::declval< const Predecessor & >() .then(std::declval< node_props_t && >(), std::declval< Functor && >())) node_t
Definition
then.hpp:41
Kokkos::Execution::GraphImpl::ThenClosure::node_props_t
typename Kokkos::Impl::NodeCtorProps< device_handle_t, std::string >::uniform_type node_props_t
Definition
then.hpp:38
Kokkos::Execution::GraphImpl::ThenSender
Sender for stdexec::then.
Definition
then.hpp:64
Kokkos::Execution::GraphImpl::ThenSender::sender_concept
stdexec::sender_tag sender_concept
Definition
then.hpp:65
Kokkos::Execution::GraphImpl::ThenSender::closure_t
ThenClosure< Exec, Functor > closure_t
Definition
then.hpp:67
Kokkos::Execution::GraphImpl::ThenSender< Impl::exec_of_t< Sndr, Env >, Sndr, Functor >::sndr
Sndr sndr
Definition
then.hpp:76
Kokkos::Execution::GraphImpl::ThenSender< Impl::exec_of_t< Sndr, Env >, Sndr, Functor >::clsr
closure_t clsr
Definition
then.hpp:75
Kokkos::Execution::GraphImpl::TransformSenderFor< stdexec::then_t >::trnsfrmd_sndr_t
ThenSender< Impl::exec_of_t< Sndr, Env >, Sndr, Functor > trnsfrmd_sndr_t
Definition
then.hpp:82
Kokkos::Execution::GraphImpl::TransformSenderFor< stdexec::then_t >::operator()
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
Kokkos::Execution::GraphImpl::TransformSenderFor< stdexec::then_t >::operator()
auto operator()(const Env &, stdexec::then_t, Functor &&, Sndr &&) const noexcept
Definition
then.hpp:106
Kokkos::Execution::GraphImpl::TransformSenderFor
Definition
graph_fwd.hpp:29
kokkos-execution
graph
then.hpp
Generated on
for kokkos-execution by
1.18.0