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_Graph.hpp"
11
12
#include "
kokkos-execution/graph/graph_fwd.hpp
"
13
14
#include "
kokkos-execution/graph/events.hpp
"
15
#include "
kokkos-execution/graph/operation_state.hpp
"
16
#include "
kokkos-execution/graph/sender_concepts.hpp
"
17
#include "
kokkos-execution/impl/attributes.hpp
"
18
#include "
kokkos-execution/impl/completion_signatures.hpp
"
19
#include "
kokkos-execution/impl/dispatch_label.hpp
"
20
#include "
kokkos-execution/impl/env.hpp
"
21
#include "
kokkos-execution/impl/sender_concepts.hpp
"
22
#include "
kokkos-execution/impl/sender_introspection.hpp
"
23
24
namespace
Kokkos::Execution::GraphImpl
{
25
26
template
<Kokkos::ExecutionSpace Exec,
typename
Functor>
27
struct
ThenClosure
{
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
const
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
));
41
KOKKOS_EXECUTION_IMPL_GRAPH_ADD_NODE_DEBUG_LOGGING
(
"then"
, node, predecessor)
42
graph_add_node_event
(predecessor, node, device_handle);
43
return
node;
44
}
45
node_props_t
node_props
;
46
Functor
functor
;
// NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
47
};
48
50
template
<
typename
Exec,
typename
Sndr,
typename
Functor>
51
struct
ThenSender
{
52
using
sender_concept
= stdexec::sender_tag;
53
54
using
closure_t
=
ThenClosure<Exec, Functor>
;
55
56
KOKKOS_EXECUTION_COMPL_SIGS_ADD
(
ThenSender
, Sndr, stdexec::set_error_t(std::exception_ptr))
57
58
KOKKOS_EXECUTION_GRAPH_OPERATION_STATE_CONNECT
59
60
KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV
(Sndr,
sndr
)
61
62
closure_t
clsr
;
63
Sndr
sndr
;
// NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
64
};
65
66
template <>
67
struct
TransformSenderFor
<
stdexec
::then_t> {
68
template
<
typename
Env,
typename
Functor,
typename
Sndr>
69
using
trnsfrmd_sndr_t
=
ThenSender<Impl::exec_of_t<Sndr, Env>
, Sndr, Functor>;
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<
75
trnsfrmd_sndr_t<Env, Functor, Sndr>
,
76
typename
trnsfrmd_sndr_t<Env, Functor, Sndr>::closure_t
,
77
Sndr&&
78
>) {
79
if
constexpr
(
graph_completing_sender<Sndr, Env>
) {
80
const
auto
schd = stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(
sndr
), env);
81
82
return
trnsfrmd_sndr_t<Env, Functor, Sndr>
{
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
{
91
return
no_graph_scheduler_in_env<stdexec::then_t, Sndr, Env>
();
92
}
93
}
94
};
95
96
}
// namespace Kokkos::Execution::GraphImpl
97
98
// NOLINTBEGIN(bugprone-reserved-identifier)
99
namespace
stdexec::__detail
{
100
template
<
typename
Exec,
typename
Sndr,
typename
Functor>
101
extern
__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
attributes.hpp
KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
Definition
attributes.hpp:30
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
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:311
KOKKOS_EXECUTION_GRAPH_OPERATION_STATE_CONNECT
#define KOKKOS_EXECUTION_GRAPH_OPERATION_STATE_CONNECT
Definition
operation_state.hpp:297
sender_concepts.hpp
graph_fwd.hpp
env.hpp
sender_concepts.hpp
events.hpp
stdexec.hpp
Kokkos::Execution::GraphImpl
Definition
graph.hpp:20
Kokkos::Execution::GraphImpl::graph_add_node_event
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:132
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
sender_concepts.hpp:31
Kokkos::Execution::Impl::exec_of_t
typename ExecOf< Args... >::type exec_of_t
Definition
get_exec.hpp:37
Kokkos::Execution::Impl::dispatch_label
consteval std::string_view dispatch_label() noexcept
View the dispatch label as a std::string_view.
Definition
dispatch_label.hpp:47
stdexec::__detail
Definition
operation_state.hpp:316
stdexec
Definition
when_all.hpp:16
sender_introspection.hpp
Kokkos::Execution::GraphImpl::ThenClosure
Definition
then.hpp:27
Kokkos::Execution::GraphImpl::ThenClosure::add_node
auto add_node(const Predecessor &predecessor) &&noexcept(false) -> node_t< Predecessor >
Definition
then.hpp:38
Kokkos::Execution::GraphImpl::ThenClosure::node_props_t
typename Kokkos::Impl::NodeCtorProps< std::string, device_handle_t >::uniform_type node_props_t
Definition
then.hpp:30
Kokkos::Execution::GraphImpl::ThenClosure::node_props
node_props_t node_props
Definition
then.hpp:45
Kokkos::Execution::GraphImpl::ThenClosure::functor
Functor functor
Definition
then.hpp:46
Kokkos::Execution::GraphImpl::ThenClosure::device_handle_t
Kokkos::Impl::DeviceHandle< Exec > device_handle_t
Definition
then.hpp:29
Kokkos::Execution::GraphImpl::ThenClosure::execution_space
Exec execution_space
Definition
then.hpp:28
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:33
Kokkos::Execution::GraphImpl::ThenSender
Sender for stdexec::then.
Definition
then.hpp:51
Kokkos::Execution::GraphImpl::ThenSender::sender_concept
stdexec::sender_tag sender_concept
Definition
then.hpp:52
Kokkos::Execution::GraphImpl::ThenSender::closure_t
ThenClosure< Exec, Functor > closure_t
Definition
then.hpp:54
Kokkos::Execution::GraphImpl::ThenSender< Impl::exec_of_t< Sndr, Env >, Sndr, Functor >::sndr
Sndr sndr
Definition
then.hpp:63
Kokkos::Execution::GraphImpl::ThenSender< Impl::exec_of_t< Sndr, Env >, Sndr, Functor >::clsr
closure_t clsr
Definition
then.hpp:62
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:73
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:69
Kokkos::Execution::GraphImpl::TransformSenderFor
Definition
graph_fwd.hpp:21
kokkos-execution
graph
then.hpp
Generated on
for kokkos-execution by
1.18.0