kokkos-execution 0.0.1
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
7
8namespace Kokkos::Execution {
9
10namespace Impl {
11
12template <stdexec::sender Sndr, typename Label, typename Functor, Kokkos::ExecutionPolicy ExecPolicy>
14
15} // namespace Impl
16
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::integral 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::integral 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 {
47 {std::move(label), std::move(functor), std::move(policy)}, std::forward<Sndr>(sndr));
48 }
49};
50
51namespace Impl {
52
53template <typename Label, typename Functor, Kokkos::ExecutionPolicy ExecPolicy>
55 using label_t = Label;
56 using functor_t = Functor;
57 using policy_t = ExecPolicy;
58
62};
63
64template <stdexec::sender Sndr, typename Label, typename Functor, Kokkos::ExecutionPolicy ExecPolicy>
65struct ParallelForSender : stdexec::__tuple<parallel_for_t, ParallelForData<Label, Functor, ExecPolicy>, Sndr> {
66 using sender_concept = stdexec::sender_t;
67
68 using base_t = stdexec::__tuple<parallel_for_t, ParallelForData<Label, Functor, ExecPolicy>, Sndr>;
69
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, 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;
86 Sndr,
87 stdexec::__get<idx_sndr>(static_cast<const base_t&>(*this)))
88};
89
90} // namespace Impl
91
92inline constexpr parallel_for_t parallel_for{};
93
94} // namespace Kokkos::Execution
95
96#endif // KOKKOS_EXECUTION_PARALLEL_FOR_HPP
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
#define KOKKOS_EXECUTION_COMPL_SIGS_ADD(_sndr_type_,...)
Completion signatures of _sndr_type_.
constexpr parallel_for_t parallel_for
ParallelForSender(ParallelForData< Label, Functor, ExecPolicy > data, Sndr &&sndr)
constexpr auto connect(Rcvr) const &=delete
stdexec::__tuple< parallel_for_t, ParallelForData< Label, Functor, ExecPolicy >, Sndr > base_t
constexpr auto connect(Rcvr) &&=delete
Custom algorithm for the Kokkos::parallel_for construct.
constexpr auto operator()(std::string label, const T work_count, Functor functor) const
constexpr auto operator()(const T work_count, Functor functor) const
constexpr auto operator()(Sndr &&sndr, std::string label, ExecPolicy policy, Functor functor) const
constexpr auto operator()(std::string label, ExecPolicy policy, Functor functor) const
constexpr auto operator()(ExecPolicy policy, Functor functor) const
Kokkos::DefaultExecutionSpace execution_space