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