kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
parallel_reduce.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_EXECUTION_EXECUTION_SPACE_PARALLEL_REDUCE_HPP
2
#define KOKKOS_EXECUTION_EXECUTION_SPACE_PARALLEL_REDUCE_HPP
3
4
#include "
kokkos-execution/stdexec.hpp
"
5
6
#include "
kokkos-execution/execution_space/execution_space_fwd.hpp
"
7
8
#include "
kokkos-execution/execution_space/diagnostics.hpp
"
9
#include "
kokkos-execution/execution_space/operation_state.hpp
"
10
#include "
kokkos-execution/execution_space/sender_concepts.hpp
"
11
#include "
kokkos-execution/impl/attributes.hpp
"
12
#include "
kokkos-execution/impl/make_policy.hpp
"
13
#include "
kokkos-execution/impl/sender_introspection.hpp
"
14
#include "
kokkos-execution/parallel_reduce.hpp
"
15
16
namespace
Kokkos::Execution::ExecutionSpaceImpl
{
17
18
template
<Kokkos::ExecutionSpace Exec, Impl::parallel_reduce_data Data>
19
struct
ParallelReduceClosure
{
20
using
execution_space
= Exec;
21
22
void
submit
() const & {
23
if
constexpr
(
Impl::labeled<Data>
) {
24
Kokkos::parallel_reduce(
25
Impl::as_convertible_to_string
(
Impl::get_property<Impl::Label>
(
data
)),
26
this->
get_policy
(),
27
data
.functor,
28
data
.reducer);
29
}
else
{
30
Kokkos::parallel_reduce(this->
get_policy
(),
data
.functor,
data
.reducer);
31
}
32
}
33
34
[[nodiscard]]
35
auto
get_policy
() const & noexcept {
36
return
Impl::make_policy<execution_space>
(
state
->
exec
,
data
.policy_or_iter_space);
37
}
38
39
const
Impl::State<execution_space>
*
state
;
40
Data
data
;
41
};
42
43
template
<
typename
Tag, stdexec::sender Sndr, Kokkos::ExecutionSpace Exec, Impl::parallel_reduce_data Data>
44
struct
ParallelReduceSender
{
45
using
sender_concept
= stdexec::sender_tag;
46
47
using
execution_space
= Exec;
48
using
closure_t
=
ParallelReduceClosure<execution_space, Data>
;
49
50
closure_t
clsr
;
51
Sndr
sndr
;
// NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
52
53
KOKKOS_EXECUTION_COMPL_SIGS_ADD
(
ParallelReduceSender
, Sndr, stdexec::set_error_t(std::exception_ptr))
54
55
template
<stdexec::receiver Rcvr>
56
constexpr
auto
connect
(Rcvr rcvr) &&
noexcept
(
noexcept
(
make_op_state_t<Sndr, Rcvr, closure_t>
{}(
57
std::declval<Sndr>(),
58
std::declval<Rcvr>(),
59
std::declval<closure_t>()))) ->
op_state_t<Sndr, Rcvr, closure_t>
{
60
return
make_op_state_t<Sndr, Rcvr, closure_t>
{}(std::forward<Sndr>(
sndr
), std::move(rcvr), std::move(
clsr
));
61
}
62
63
KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV
(Sndr,
sndr
)
64
};
65
66
template
<>
67
struct
TransformSenderFor
<
Kokkos
::
Execution::parallel_reduce_t
> {
68
template
<
typename
Env,
typename
Data,
typename
Sndr>
69
using
trnsfrmd_sndr_t
=
70
ParallelReduceSender<parallel_reduce_t, Sndr, Impl::exec_of_t<Sndr, Env>
, std::remove_cvref_t<Data>>;
71
72
template
<
typename
Env,
typename
Data,
typename
Sndr>
73
requires
(stdexec::__sends<stdexec::set_value_t, Sndr, Env> &&
execution_space_completing_sender<Sndr, Env>
)
74
auto
operator
()(
75
const
Env& env,
76
Kokkos::Execution::parallel_reduce_t
,
77
Data&& data,
// NOLINT(cppcoreguidelines-missing-std-forward)
78
Sndr&& sndr)
const
79
STDEXEC_AUTO_RETURN(
80
trnsfrmd_sndr_t<Env, Data, Sndr>
{
81
{.state = stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(sndr), env).state,
82
.data = std::forward<Data>(data)},
83
std::forward<Sndr>(sndr)
84
})
85
86
template <typename Env, typename Data, typename Sndr>
87
requires
stdexec::__sends<stdexec::set_value_t, Sndr, Env>
88
auto
operator
()(
const
Env&,
Kokkos::Execution::parallel_reduce_t
, Data&&, Sndr&&)
const
noexcept
{
89
return
no_execution_space_scheduler_in_env<parallel_reduce_t, Sndr, Env>
();
90
}
91
};
92
93
}
// namespace Kokkos::Execution::ExecutionSpaceImpl
94
95
#endif
// KOKKOS_EXECUTION_EXECUTION_SPACE_PARALLEL_REDUCE_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
Kokkos::Execution::Impl::labeled
Definition
label.hpp:60
diagnostics.hpp
operation_state.hpp
sender_concepts.hpp
execution_space_fwd.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
make_policy.hpp
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::make_policy
constexpr make_policy_t< Exec, Properties... > make_policy
Definition
make_policy.hpp:73
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::get_property
constexpr decltype(auto) get_property(Data &&data) noexcept
Definition
properties.hpp:80
Kokkos
parallel_reduce.hpp
sender_introspection.hpp
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceClosure
Definition
parallel_reduce.hpp:19
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceClosure< execution_space, Data >::get_policy
auto get_policy() const &noexcept
Definition
parallel_reduce.hpp:35
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceClosure::submit
void submit() const &
Definition
parallel_reduce.hpp:22
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceClosure< execution_space, Data >::data
Data data
Definition
parallel_reduce.hpp:40
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceClosure::execution_space
Exec execution_space
Definition
parallel_reduce.hpp:20
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceClosure< execution_space, Data >::state
const Impl::State< execution_space > * state
Definition
parallel_reduce.hpp:39
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceSender
Definition
parallel_reduce.hpp:44
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceSender< parallel_reduce_t, Sndr, Impl::exec_of_t< Sndr, Env >, std::remove_cvref_t< Data > >::clsr
closure_t clsr
Definition
parallel_reduce.hpp:50
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceSender::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
parallel_reduce.hpp:56
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceSender::sender_concept
stdexec::sender_tag sender_concept
Definition
parallel_reduce.hpp:45
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceSender::closure_t
ParallelReduceClosure< execution_space, Data > closure_t
Definition
parallel_reduce.hpp:48
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceSender::execution_space
Exec execution_space
Definition
parallel_reduce.hpp:47
Kokkos::Execution::ExecutionSpaceImpl::ParallelReduceSender< parallel_reduce_t, Sndr, Impl::exec_of_t< Sndr, Env >, std::remove_cvref_t< Data > >::sndr
Sndr sndr
Definition
parallel_reduce.hpp:51
Kokkos::Execution::ExecutionSpaceImpl::TransformSenderFor< Kokkos::Execution::parallel_reduce_t >::trnsfrmd_sndr_t
ParallelReduceSender< parallel_reduce_t, Sndr, Impl::exec_of_t< Sndr, Env >, std::remove_cvref_t< Data > > trnsfrmd_sndr_t
Definition
parallel_reduce.hpp:69
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::parallel_reduce_t
Custom algorithm for the Kokkos::parallel_reduce construct.
Definition
parallel_reduce.hpp:51
kokkos-execution
execution_space
parallel_reduce.hpp
Generated on
for kokkos-execution by
1.18.0