kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
graph.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_EXECUTION_GRAPH_HPP
2
#define KOKKOS_EXECUTION_GRAPH_HPP
3
4
#include "
kokkos-execution/stdexec.hpp
"
5
6
#include "Kokkos_Core.hpp"
7
8
#include "
kokkos-execution/graph/bulk.hpp
"
9
#include "
kokkos-execution/graph/continues_on.hpp
"
10
#include "
kokkos-execution/graph/domain.hpp
"
11
#include "
kokkos-execution/graph/parallel_for.hpp
"
12
#include "
kokkos-execution/graph/schedule_from.hpp
"
13
#include "
kokkos-execution/graph/sync_wait.hpp
"
14
#include "
kokkos-execution/graph/then.hpp
"
15
#include "
kokkos-execution/graph/when_all.hpp
"
16
#include "
kokkos-execution/impl/state.hpp
"
17
18
namespace
Kokkos::Execution
{
19
20
namespace
GraphImpl
{
21
23
template
<Kokkos::ExecutionSpace Exec>
24
struct
Scheduler
{
26
using
scheduler_concept
= stdexec::scheduler_t;
27
28
using
execution_space
= Exec;
29
30
template
<stdexec::receiver Rcvr>
31
struct
OpState
{
32
using
operation_state_concept
= stdexec::operation_state_tag;
33
34
Impl::State<execution_space>
*
state
;
35
Rcvr
rcvr
;
36
37
[[nodiscard]]
38
constexpr
auto
query
(
Impl::get_exec_t
)
const
noexcept
->
Impl::ExecutionSpaceRef<execution_space>
{
39
return
Impl::ExecutionSpaceRef
{
state
->
exec
};
40
}
41
43
void
start
() &
noexcept
{
44
stdexec::set_value(std::move(
rcvr
));
45
}
46
47
template
<
typename
R = Rcvr>
48
[[nodiscard]]
49
auto
query
(
get_node_t
)
const
&
noexcept
-> stdexec::__query_result_t<R, get_node_t>
50
requires
std::same_as<GraphComposition::policy_t<R>,
GraphComposition::Attach
>
51
{
52
return
this->rcvr.query(
get_node
);
53
}
54
};
55
56
struct
Sender
{
57
using
sender_concept
= stdexec::sender_tag;
58
59
using
completion_signatures
= stdexec::completion_signatures<stdexec::set_value_t()>;
60
62
struct
Attributes
{
63
template
<
typename
... Env>
64
[[nodiscard]]
65
constexpr
auto
66
query
(stdexec::get_completion_scheduler_t<stdexec::set_value_t>, Env...) const noexcept ->
Scheduler
{
67
return
{
state
};
68
}
69
70
template
<
typename
... Env>
71
[[nodiscard]]
72
constexpr
auto
73
query
(stdexec::get_completion_domain_t<stdexec::set_value_t>, Env...) const noexcept ->
Domain
{
74
return
{};
75
}
76
77
Impl::State<Exec>
*
state
;
78
};
79
80
template
<stdexec::receiver_of<completion_signatures> Rcvr>
81
[[nodiscard]]
82
OpState<Rcvr>
connect
(Rcvr rcvr) &&
noexcept
(std::is_nothrow_move_constructible_v<Rcvr>) {
83
return
{.state =
env
.
state
, .rcvr = std::move(rcvr)};
84
}
85
86
template
<stdexec::receiver_of<completion_signatures> Rcvr>
87
[[nodiscard]]
88
OpState<Rcvr>
connect
(Rcvr rcvr)
const
&
noexcept
(std::is_nothrow_move_constructible_v<Rcvr>) {
89
return
{.state =
env
.
state
, .rcvr = std::move(rcvr)};
90
}
91
92
[[nodiscard]]
93
constexpr
auto
get_env
() const noexcept -> const
Attributes
& {
94
return
env
;
95
}
96
97
Attributes
env
;
98
};
99
100
[[nodiscard]]
101
constexpr
auto
schedule
() const noexcept -> Sender {
102
return
{
state
};
103
}
104
105
[[nodiscard]]
106
constexpr
auto
query
(stdexec::get_completion_domain_t<stdexec::set_value_t>)
const
noexcept
->
Domain
{
107
return
{};
108
}
109
110
[[nodiscard]]
111
constexpr
auto
query
(stdexec::get_completion_scheduler_t<stdexec::set_value_t>)
const
noexcept
->
Scheduler
{
112
return
{
state
};
113
}
114
115
[[nodiscard]]
116
friend
bool
operator==
(
const
Scheduler
&,
const
Scheduler
&)
noexcept
=
default
;
117
118
Impl::State<Exec>
*
state
;
119
};
120
121
}
// namespace GraphImpl
122
124
template
<Kokkos::ExecutionSpace Exec>
125
struct
GraphContext
{
126
using
state_t
=
Impl::State<Exec>
;
127
128
state_t
m_state
;
129
130
explicit
GraphContext
(Exec exec)
// NOLINT(performance-unnecessary-value-param)
131
:
m_state
{std::move(exec)} {
132
}
133
134
auto
get_scheduler
() const noexcept ->
GraphImpl
::Scheduler<Exec> {
135
return
{
const_cast<
state_t
*
>
(&
m_state
)};
136
}
137
};
138
139
}
// namespace Kokkos::Execution
140
141
#endif
// KOKKOS_EXECUTION_GRAPH_HPP
bulk.hpp
continues_on.hpp
parallel_for.hpp
schedule_from.hpp
then.hpp
when_all.hpp
domain.hpp
sync_wait.hpp
stdexec.hpp
Kokkos::Execution::GraphImpl
Definition
graph.hpp:20
Kokkos::Execution::GraphImpl::get_node
constexpr get_node_t get_node
Definition
get_node.hpp:15
Kokkos::Execution
Definition
execution_space.hpp:20
state.hpp
Kokkos::Execution::GraphContext::GraphContext
GraphContext(Exec exec)
Definition
graph.hpp:130
Kokkos::Execution::GraphContext< TEST_EXECUTION_SPACE >::m_state
state_t m_state
Definition
graph.hpp:128
Kokkos::Execution::GraphContext::get_scheduler
auto get_scheduler() const noexcept -> GraphImpl::Scheduler< Exec >
Definition
graph.hpp:134
Kokkos::Execution::GraphContext::state_t
Impl::State< Exec > state_t
Definition
graph.hpp:126
Kokkos::Execution::GraphImpl::Domain
Definition
domain.hpp:13
Kokkos::Execution::GraphImpl::GraphComposition::Attach
Attach to the existing graph of the predecessor.
Definition
get_graph.hpp:33
Kokkos::Execution::GraphImpl::Scheduler::OpState
Definition
graph.hpp:31
Kokkos::Execution::GraphImpl::Scheduler::OpState::rcvr
Rcvr rcvr
Definition
graph.hpp:35
Kokkos::Execution::GraphImpl::Scheduler::OpState::query
auto query(get_node_t) const &noexcept -> stdexec::__query_result_t< R, get_node_t >
Definition
graph.hpp:49
Kokkos::Execution::GraphImpl::Scheduler::OpState::query
constexpr auto query(Impl::get_exec_t) const noexcept -> Impl::ExecutionSpaceRef< execution_space >
Definition
graph.hpp:38
Kokkos::Execution::GraphImpl::Scheduler::OpState::start
void start() &noexcept
Definition
graph.hpp:43
Kokkos::Execution::GraphImpl::Scheduler::OpState::state
Impl::State< execution_space > * state
Definition
graph.hpp:34
Kokkos::Execution::GraphImpl::Scheduler::OpState::operation_state_concept
stdexec::operation_state_tag operation_state_concept
Definition
graph.hpp:32
Kokkos::Execution::GraphImpl::Scheduler::Sender::Attributes
See https://github.com/NVIDIA/stdexec/blob/5076be2b35de2e78330201b888d82c81b8cb428b/include/nvexec/st...
Definition
graph.hpp:62
Kokkos::Execution::GraphImpl::Scheduler::Sender::Attributes::state
Impl::State< Exec > * state
Definition
graph.hpp:77
Kokkos::Execution::GraphImpl::Scheduler::Sender::Attributes::query
constexpr auto query(stdexec::get_completion_scheduler_t< stdexec::set_value_t >, Env...) const noexcept -> Scheduler
Definition
graph.hpp:66
Kokkos::Execution::GraphImpl::Scheduler::Sender::Attributes::query
constexpr auto query(stdexec::get_completion_domain_t< stdexec::set_value_t >, Env...) const noexcept -> Domain
Definition
graph.hpp:73
Kokkos::Execution::GraphImpl::Scheduler::Sender
Definition
graph.hpp:56
Kokkos::Execution::GraphImpl::Scheduler::Sender::connect
OpState< Rcvr > connect(Rcvr rcvr) &&noexcept(std::is_nothrow_move_constructible_v< Rcvr >)
Definition
graph.hpp:82
Kokkos::Execution::GraphImpl::Scheduler::Sender::get_env
constexpr auto get_env() const noexcept -> const Attributes &
Definition
graph.hpp:93
Kokkos::Execution::GraphImpl::Scheduler::Sender::sender_concept
stdexec::sender_tag sender_concept
Definition
graph.hpp:57
Kokkos::Execution::GraphImpl::Scheduler::Sender::env
Attributes env
Definition
graph.hpp:97
Kokkos::Execution::GraphImpl::Scheduler::Sender::connect
OpState< Rcvr > connect(Rcvr rcvr) const &noexcept(std::is_nothrow_move_constructible_v< Rcvr >)
Definition
graph.hpp:88
Kokkos::Execution::GraphImpl::Scheduler::Sender::completion_signatures
stdexec::completion_signatures< stdexec::set_value_t()> completion_signatures
Definition
graph.hpp:59
Kokkos::Execution::GraphImpl::Scheduler
Scheduler for a Kokkos::Experimental::Graph.
Definition
graph.hpp:24
Kokkos::Execution::GraphImpl::Scheduler::query
constexpr auto query(stdexec::get_completion_domain_t< stdexec::set_value_t >) const noexcept -> Domain
Definition
graph.hpp:106
Kokkos::Execution::GraphImpl::Scheduler::query
constexpr auto query(stdexec::get_completion_scheduler_t< stdexec::set_value_t >) const noexcept -> Scheduler
Definition
graph.hpp:111
Kokkos::Execution::GraphImpl::Scheduler::operator==
friend bool operator==(const Scheduler &, const Scheduler &) noexcept=default
Kokkos::Execution::GraphImpl::Scheduler::execution_space
Exec execution_space
Definition
graph.hpp:28
Kokkos::Execution::GraphImpl::Scheduler< TEST_EXECUTION_SPACE >::state
Impl::State< Exec > * state
Definition
graph.hpp:118
Kokkos::Execution::GraphImpl::Scheduler::schedule
constexpr auto schedule() const noexcept -> Sender
Definition
graph.hpp:101
Kokkos::Execution::GraphImpl::Scheduler::scheduler_concept
stdexec::scheduler_t scheduler_concept
As per https://eel.is/c++draft/exec.sched#1.
Definition
graph.hpp:26
Kokkos::Execution::GraphImpl::get_node_t
Definition
get_node.hpp:13
Kokkos::Execution::Impl::ExecutionSpaceRef
Wrap a Kokkos execution space to make it cheap to copy/move in new environments.
Definition
get_exec.hpp:47
Kokkos::Execution::Impl::State
Definition
state.hpp:9
Kokkos::Execution::Impl::State::exec
Exec exec
Definition
state.hpp:10
Kokkos::Execution::Impl::get_exec_t
Definition
get_exec.hpp:15
kokkos-execution
graph.hpp
Generated on
for kokkos-execution by
1.18.0