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_EXECUTION_SPACE_THEN_HPP
2
#define KOKKOS_EXECUTION_EXECUTION_SPACE_THEN_HPP
3
4
#include "
kokkos-execution/execution_space/execution_space_fwd.hpp
"
5
6
#include "
kokkos-execution/execution_space/diagnostics.hpp
"
7
#include "
kokkos-execution/execution_space/parallel_for.hpp
"
8
#include "
kokkos-execution/execution_space/sender_concepts.hpp
"
9
#include "
kokkos-execution/impl/dispatch_label.hpp
"
10
#include "
kokkos-execution/impl/sender_introspection.hpp
"
11
12
namespace
Kokkos::Execution::ExecutionSpaceImpl
{
13
14
template
<Kokkos::ExecutionSpace Exec,
typename
Label,
typename
Functor>
15
struct
ThenClosure
{
16
using
execution_space
= Exec;
17
18
void
submit
() const & {
19
Kokkos::single(
Impl::as_convertible_to_string
(
label
), this->
get_policy
(),
functor
);
20
}
21
23
[[nodiscard]]
24
auto
get_policy
() const & noexcept {
25
return
Kokkos::SinglePolicy<execution_space>{
state
->
exec
};
26
}
27
28
const
Impl::State<execution_space>
*
state
;
29
Label
label
;
30
Functor
functor
;
31
};
32
33
template
<
typename
Tag, stdexec::sender Sndr, Kokkos::ExecutionSpace Exec,
typename
Label,
typename
Functor>
34
struct
ThenSender
{
35
using
sender_concept
= stdexec::sender_tag;
36
37
using
execution_space
= Exec;
38
using
closure_t
=
ThenClosure<execution_space, Label, Functor>
;
39
40
closure_t
clsr
;
41
Sndr
sndr
;
// NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
42
43
KOKKOS_EXECUTION_COMPL_SIGS_ADD
(
ThenSender
, Sndr, stdexec::set_error_t(std::exception_ptr))
44
45
template
<stdexec::receiver Rcvr>
46
constexpr
auto
connect
(Rcvr rcvr) &&
noexcept
(
noexcept
(
make_op_state_t<Sndr, Rcvr, closure_t>
{}(
47
std::declval<Sndr>(),
48
std::declval<Rcvr>(),
49
std::declval<closure_t>()))) ->
op_state_t<Sndr, Rcvr, closure_t>
{
50
return
make_op_state_t<Sndr, Rcvr, closure_t>
{}(std::forward<Sndr>(
sndr
), std::move(rcvr), std::move(
clsr
));
51
}
52
53
KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV
(Sndr,
sndr
)
54
};
55
56
template
<>
57
struct
TransformSenderFor
<
stdexec
::then_t> {
58
template
<
typename
Env,
typename
Functor,
typename
Sndr>
59
struct
Transformer
{
60
using
execution_space
=
Impl::exec_of_t<Sndr, Env>
;
61
62
using
sndr_t
=
63
ThenSender<stdexec::then_t, Sndr, execution_space, std::string_view, std::remove_cvref_t<Functor>
>;
64
65
auto
operator()
(
const
Env& env, std::remove_reference_t<Functor>& functor, std::remove_reference_t<Sndr>& sndr)
66
const
STDEXEC_AUTO_RETURN(
67
sndr_t
{
68
{.state = stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(sndr), env)
69
.state,
70
.label =
KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL
(
execution_space
,
": then"
),
71
.functor = std::forward<Functor>(functor)},
72
std::forward<Sndr>(sndr)
73
})
74
};
75
76
template
<
typename
Env,
typename
Functor,
typename
Sndr>
77
requires
(stdexec::__sends<stdexec::set_value_t, Sndr, Env> &&
execution_space_completing_sender<Sndr, Env>
)
78
auto
operator
()(
79
const
Env& env,
80
stdexec::then_t,
81
Functor&& functor,
// NOLINT(cppcoreguidelines-missing-std-forward)
82
Sndr&& sndr
// NOLINT(cppcoreguidelines-missing-std-forward)
83
)
const
STDEXEC_AUTO_RETURN(
Transformer<Env, Functor, Sndr>
{}(env, functor, sndr))
84
85
template <typename Env, typename Functor, typename Sndr>
86
requires
stdexec::__sends<stdexec::set_value_t, Sndr, Env>
87
auto
operator
()(
const
Env&, stdexec::then_t, Functor&&, Sndr&&)
const
noexcept
{
88
return
no_execution_space_scheduler_in_env<stdexec::then_t, Sndr, Env>
();
89
}
90
};
91
92
}
// namespace Kokkos::Execution::ExecutionSpaceImpl
93
94
#endif
// KOKKOS_EXECUTION_EXECUTION_SPACE_THEN_HPP
KOKKOS_EXECUTION_COMPL_SIGS_ADD
#define KOKKOS_EXECUTION_COMPL_SIGS_ADD(_decayed_self_type_, _sndr_type_,...)
Definition
completion_signatures.hpp:32
Kokkos::Execution::ExecutionSpaceImpl::execution_space_completing_sender
Concept for a sender whose completion scheduler is Kokkos::Execution::ExecutionSpaceImpl::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
diagnostics.hpp
parallel_for.hpp
sender_concepts.hpp
execution_space_fwd.hpp
KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
Definition
attributes.hpp:30
Kokkos::Execution::ExecutionSpaceImpl
Definition
execution_space.hpp:28
Kokkos::Execution::ExecutionSpaceImpl::no_execution_space_scheduler_in_env
auto no_execution_space_scheduler_in_env() noexcept
Show a better compile diagnostic when there is no Kokkos::Execution::ExecutionSpaceImpl::Scheduler fo...
Definition
diagnostics.hpp:26
Kokkos::Execution::ExecutionSpaceImpl::op_state_t
typename make_op_state_t< Sndr, Rcvr, Clsrs... >::type op_state_t
Definition
operation_state.hpp:138
Kokkos::Execution::ExecutionSpaceImpl::make_op_state_t
Impl::MakeOpState< Domain, OpState >::Huddle< Sndr, Rcvr, Clsrs... > make_op_state_t
Definition
operation_state.hpp:135
Kokkos::Execution::Impl::as_convertible_to_string
constexpr auto as_convertible_to_string(T &&value) noexcept(noexcept(std::forward< T >(value))) -> decltype(std::forward< T >(value))
Convert to a value usable as a std::string.
Definition
label.hpp:75
Kokkos::Execution::Impl::exec_of_t
typename ExecOf< Args... >::type exec_of_t
Definition
get_exec.hpp:42
stdexec
Definition
when_all.hpp:16
sender_introspection.hpp
Kokkos::Execution::ExecutionSpaceImpl::ThenClosure
Definition
then.hpp:15
Kokkos::Execution::ExecutionSpaceImpl::ThenClosure< execution_space, Label, Functor >::label
Label label
Definition
then.hpp:29
Kokkos::Execution::ExecutionSpaceImpl::ThenClosure::submit
void submit() const &
Definition
then.hpp:18
Kokkos::Execution::ExecutionSpaceImpl::ThenClosure< execution_space, Label, Functor >::functor
Functor functor
Definition
then.hpp:30
Kokkos::Execution::ExecutionSpaceImpl::ThenClosure< execution_space, Label, Functor >::get_policy
auto get_policy() const &noexcept
Definition
then.hpp:24
Kokkos::Execution::ExecutionSpaceImpl::ThenClosure< execution_space, Label, Functor >::state
const Impl::State< execution_space > * state
Definition
then.hpp:28
Kokkos::Execution::ExecutionSpaceImpl::ThenClosure::execution_space
Exec execution_space
Definition
then.hpp:16
Kokkos::Execution::ExecutionSpaceImpl::ThenSender
Definition
then.hpp:34
Kokkos::Execution::ExecutionSpaceImpl::ThenSender::sender_concept
stdexec::sender_tag sender_concept
Definition
then.hpp:35
Kokkos::Execution::ExecutionSpaceImpl::ThenSender::connect
constexpr auto connect(Rcvr rcvr) &&noexcept(noexcept(make_op_state_t< Sndr, Rcvr, closure_t >{}(std::declval< Sndr >(), std::declval< Rcvr >(), std::declval< closure_t >()))) -> op_state_t< Sndr, Rcvr, closure_t >
Definition
then.hpp:46
Kokkos::Execution::ExecutionSpaceImpl::ThenSender::closure_t
ThenClosure< execution_space, Label, Functor > closure_t
Definition
then.hpp:38
Kokkos::Execution::ExecutionSpaceImpl::ThenSender< stdexec::then_t, Sndr, execution_space, std::string_view, std::remove_cvref_t< Functor > >::clsr
closure_t clsr
Definition
then.hpp:40
Kokkos::Execution::ExecutionSpaceImpl::ThenSender::execution_space
Exec execution_space
Definition
then.hpp:37
Kokkos::Execution::ExecutionSpaceImpl::ThenSender< stdexec::then_t, Sndr, execution_space, std::string_view, std::remove_cvref_t< Functor > >::sndr
Sndr sndr
Definition
then.hpp:41
Kokkos::Execution::ExecutionSpaceImpl::TransformSenderFor< stdexec::then_t >::Transformer
Definition
then.hpp:59
Kokkos::Execution::ExecutionSpaceImpl::TransformSenderFor< stdexec::then_t >::Transformer::operator()
auto operator()(const Env &env, std::remove_reference_t< Functor > &functor, std::remove_reference_t< Sndr > &sndr) const noexcept(noexcept(sndr_t{ {.state=stdexec::get_completion_scheduler< stdexec::set_value_t >(stdexec::get_env(sndr), env) .state,.label=Kokkos::Execution::Impl::dispatch_label< execution_space, ": then">(),.functor=std::forward< Functor >(functor)}, std::forward< Sndr >(sndr) })) -> decltype(sndr_t{ {.state=stdexec::get_completion_scheduler< stdexec::set_value_t >(stdexec::get_env(sndr), env) .state,.label=Kokkos::Execution::Impl::dispatch_label< execution_space, ": then">(),.functor=std::forward< Functor >(functor)}, std::forward< Sndr >(sndr) })
Definition
then.hpp:65
Kokkos::Execution::ExecutionSpaceImpl::TransformSenderFor< stdexec::then_t >::Transformer::execution_space
Impl::exec_of_t< Sndr, Env > execution_space
Definition
then.hpp:60
Kokkos::Execution::ExecutionSpaceImpl::TransformSenderFor< stdexec::then_t >::Transformer::sndr_t
ThenSender< stdexec::then_t, Sndr, execution_space, std::string_view, std::remove_cvref_t< Functor > > sndr_t
Definition
then.hpp:62
Kokkos::Execution::ExecutionSpaceImpl::TransformSenderFor
Definition
execution_space_fwd.hpp:17
Kokkos::Execution::Impl::State
Definition
state.hpp:14
Kokkos::Execution::Impl::State::exec
Exec exec
Definition
state.hpp:15
kokkos-execution
execution_space
then.hpp
Generated on
for kokkos-execution by
1.18.0