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_PARALLEL_FOR_HPP
2
#define KOKKOS_EXECUTION_PARALLEL_FOR_HPP
3
4
#include "
kokkos-execution/impl/attributes.hpp
"
5
#include "
kokkos-execution/impl/completion_signatures.hpp
"
6
#include "
kokkos-execution/impl/env.hpp
"
7
8
namespace
Kokkos::Execution
{
9
10
namespace
Impl
{
11
12
template
<stdexec::sender Sndr,
typename
Label,
typename
Functor, Kokkos::ExecutionPolicy ExecPolicy>
13
struct
ParallelForSender
;
14
15
}
// namespace Impl
16
18
struct
parallel_for_t
{
19
template
<
typename
Functor, Kokkos::ExecutionPolicy ExecPolicy>
20
constexpr
auto
operator()
(std::string label, ExecPolicy policy, Functor functor)
const
{
21
return
stdexec::__closure(*
this
, std::move(label), std::move(policy), std::move(functor));
22
}
23
24
template
<
typename
Functor, Kokkos::ExecutionPolicy ExecPolicy>
25
constexpr
auto
operator()
(ExecPolicy policy, Functor functor)
const
{
26
return
this->
operator()
(
""
, std::move(policy), std::move(functor));
27
}
28
29
template
<
typename
Functor, std::
int
egral T>
30
constexpr
auto
operator()
(std::string label,
const
T work_count, Functor functor)
const
{
31
using
execution_space
=
32
typename
Kokkos::Impl::FunctorPolicyExecutionSpace<std::remove_cvref_t<Functor>,
void
>
::execution_space
;
33
using
policy_t = Kokkos::RangePolicy<execution_space>;
34
35
return
this->
operator()
(std::move(label), policy_t(0, work_count), std::move(functor));
36
}
37
39
template
<
typename
Functor, std::
int
egral T>
40
constexpr
auto
operator()
(
const
T work_count, Functor functor)
const
{
41
return
this->
operator()
(
""
, work_count, std::move(functor));
42
}
43
44
template
<stdexec::sender Sndr,
typename
Functor, Kokkos::ExecutionPolicy ExecPolicy>
45
constexpr
auto
operator()
(Sndr&& sndr, std::string label, ExecPolicy policy, Functor functor)
const
{
46
return
Impl::ParallelForSender<Sndr, std::string, Functor, ExecPolicy>
(
47
{std::move(label), std::move(functor), std::move(policy)}, std::forward<Sndr>(sndr));
48
}
49
};
50
51
namespace
Impl {
52
53
template
<
typename
Label,
typename
Functor, Kokkos::ExecutionPolicy ExecPolicy>
54
struct
ParallelForData
{
55
using
label_t
= Label;
56
using
functor_t
= Functor;
57
using
policy_t
= ExecPolicy;
58
59
label_t
label
;
60
functor_t
functor
;
61
policy_t
policy
;
62
};
63
64
template
<stdexec::sender Sndr,
typename
Label,
typename
Functor, Kokkos::ExecutionPolicy ExecPolicy>
65
struct
ParallelForSender
: stdexec::__tuple<parallel_for_t, ParallelForData<Label, Functor, ExecPolicy>, Sndr> {
66
using
sender_concept
= stdexec::sender_tag;
67
68
using
base_t
= stdexec::__tuple<parallel_for_t, ParallelForData<Label, Functor, ExecPolicy>, Sndr>;
69
70
ParallelForSender
(
71
ParallelForData<Label, Functor, ExecPolicy>
data,
72
Sndr&& sndr)
// NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
73
:
base_t
{
parallel_for_t
{}, std::move(data), std::forward<Sndr>(sndr)} {
74
}
75
76
KOKKOS_EXECUTION_COMPL_SIGS_ADD
(
ParallelForSender
, Sndr, stdexec::set_error_t(std::exception_ptr))
77
78
template
<stdexec::receiver Rcvr>
79
constexpr
auto
connect
(Rcvr) && =
delete
;
80
81
template
<stdexec::receiver Rcvr>
82
constexpr
auto
connect
(Rcvr)
const
& =
delete
;
83
84
static
constexpr
size_t
idx_sndr
= 2;
85
KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV
(
86
Sndr,
87
stdexec::__get<idx_sndr>(
static_cast<
const
base_t
&
>
(*
this
)))
88
};
89
90
}
// namespace Impl
91
92
inline
constexpr
parallel_for_t
parallel_for
{};
93
94
}
// namespace Kokkos::Execution
95
96
#endif
// KOKKOS_EXECUTION_PARALLEL_FOR_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
env.hpp
Kokkos::Execution::Impl
Definition
attributes.hpp:6
Kokkos::Execution
Definition
execution_space.hpp:20
Kokkos::Execution::parallel_for
constexpr parallel_for_t parallel_for
Definition
parallel_for.hpp:92
Kokkos::Execution::Impl::ParallelForData
Definition
parallel_for.hpp:54
Kokkos::Execution::Impl::ParallelForData::label_t
Label label_t
Definition
parallel_for.hpp:55
Kokkos::Execution::Impl::ParallelForData< std::string, Tests::Utils::Functors::SumIndices< view_s_t >, Kokkos::RangePolicy< TEST_EXECUTION_SPACE > >::policy
policy_t policy
Definition
parallel_for.hpp:61
Kokkos::Execution::Impl::ParallelForData::policy_t
ExecPolicy policy_t
Definition
parallel_for.hpp:57
Kokkos::Execution::Impl::ParallelForData< std::string, Tests::Utils::Functors::SumIndices< view_s_t >, Kokkos::RangePolicy< TEST_EXECUTION_SPACE > >::label
label_t label
Definition
parallel_for.hpp:59
Kokkos::Execution::Impl::ParallelForData::functor_t
Functor functor_t
Definition
parallel_for.hpp:56
Kokkos::Execution::Impl::ParallelForData< std::string, Tests::Utils::Functors::SumIndices< view_s_t >, Kokkos::RangePolicy< TEST_EXECUTION_SPACE > >::functor
functor_t functor
Definition
parallel_for.hpp:60
Kokkos::Execution::Impl::ParallelForSender
Definition
parallel_for.hpp:65
Kokkos::Execution::Impl::ParallelForSender::ParallelForSender
ParallelForSender(ParallelForData< Label, Functor, ExecPolicy > data, Sndr &&sndr)
Definition
parallel_for.hpp:70
Kokkos::Execution::Impl::ParallelForSender::connect
constexpr auto connect(Rcvr) const &=delete
Kokkos::Execution::Impl::ParallelForSender::base_t
stdexec::__tuple< parallel_for_t, ParallelForData< Label, Functor, ExecPolicy >, Sndr > base_t
Definition
parallel_for.hpp:68
Kokkos::Execution::Impl::ParallelForSender::idx_sndr
static constexpr size_t idx_sndr
Definition
parallel_for.hpp:84
Kokkos::Execution::Impl::ParallelForSender::connect
constexpr auto connect(Rcvr) &&=delete
Kokkos::Execution::Impl::ParallelForSender::sender_concept
stdexec::sender_tag sender_concept
Definition
parallel_for.hpp:66
Kokkos::Execution::parallel_for_t
Custom algorithm for the Kokkos::parallel_for construct.
Definition
parallel_for.hpp:18
Kokkos::Execution::parallel_for_t::operator()
constexpr auto operator()(std::string label, const T work_count, Functor functor) const
Definition
parallel_for.hpp:30
Kokkos::Execution::parallel_for_t::operator()
constexpr auto operator()(const T work_count, Functor functor) const
Definition
parallel_for.hpp:40
Kokkos::Execution::parallel_for_t::operator()
constexpr auto operator()(Sndr &&sndr, std::string label, ExecPolicy policy, Functor functor) const
Definition
parallel_for.hpp:45
Kokkos::Execution::parallel_for_t::operator()
constexpr auto operator()(std::string label, ExecPolicy policy, Functor functor) const
Definition
parallel_for.hpp:20
Kokkos::Execution::parallel_for_t::operator()
constexpr auto operator()(ExecPolicy policy, Functor functor) const
Definition
parallel_for.hpp:25
execution_space
Kokkos::DefaultExecutionSpace execution_space
kokkos-execution
parallel_for.hpp
Generated on
for kokkos-execution by
1.18.0