kokkos-execution 0.0.1
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
5
7
15
17
18template <Kokkos::ExecutionSpace Exec, Impl::parallel_for_data Data>
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
36 Data data;
37};
38
39template <typename Tag, stdexec::sender Sndr, Kokkos::ExecutionSpace Exec, Impl::parallel_for_data Data>
41 using sender_concept = stdexec::sender_tag;
42
43 using execution_space = Exec;
45
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
60};
61
62template <>
64 template <typename Env, typename Data, typename Sndr>
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,
73 Data&& data, // NOLINT(cppcoreguidelines-missing-std-forward)
74 Sndr&& sndr) const
75 STDEXEC_AUTO_RETURN(
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 {
86 }
87};
88
89} // namespace Kokkos::Execution::ExecutionSpaceImpl
90
91#endif // KOKKOS_EXECUTION_EXECUTION_SPACE_PARALLEL_FOR_HPP
#define KOKKOS_EXECUTION_COMPL_SIGS_ADD(_decayed_self_type_, _sndr_type_,...)
Concept for a sender whose completion scheduler is Kokkos::Execution::ExecutionSpaceImpl::Scheduler.
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
auto no_execution_space_scheduler_in_env() noexcept
Show a better compile diagnostic when there is no Kokkos::Execution::ExecutionSpaceImpl::Scheduler fo...
typename make_op_state_t< Sndr, Rcvr, Clsrs... >::type op_state_t
Impl::MakeOpState< Domain, OpState >::Huddle< Sndr, Rcvr, Clsrs... > make_op_state_t
constexpr make_policy_t< Exec, Properties... > make_policy
constexpr decltype(auto) get_property(Data &&data) noexcept
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 >
ParallelForSender< parallel_for_t, Sndr, Impl::exec_of_t< Sndr, Env >, std::remove_cvref_t< Data > > trnsfrmd_sndr_t
Custom algorithm for the Kokkos::parallel_for construct.