1#ifndef KOKKOS_EXECUTION_EXECUTION_SPACE_SCOPED_REGION_HPP
2#define KOKKOS_EXECUTION_EXECUTION_SPACE_SCOPED_REGION_HPP
8#include "impl/Kokkos_Profiling.hpp"
28enum class Kind : std::uint8_t {
33template <Kind kind, stdexec::__is_instance_of<Scheduler> Schd, stdexec::receiver Rcvr>
41 template <
typename Tag,
typename... Args>
42 void complete(Tag tag, Args&&... args) &&
noexcept {
43 schd.state->exec.fence(
46 Kokkos::Impl::TypeInfo<typename Schd::execution_space>::name(),
50 Kokkos::Profiling::pushRegion(
name);
52 Kokkos::Profiling::popRegion();
55 std::invoke(tag, std::move(
rcvr), std::forward<Args>(args)...);
59 std::move(*this).complete(stdexec::set_value);
62 template <
typename Error>
64 std::move(*this).complete(stdexec::set_error, std::forward<Error>(err));
70template <Kind kind, stdexec::sender Sndr>
76 template <
typename Rcvr>
77 using schd_t = stdexec::__completion_scheduler_of_t<stdexec::set_value_t, Sndr, stdexec::env_of_t<Rcvr>>;
79 template <
typename Rcvr>
82 template <stdexec::receiver Rcvr>
83 stdexec::operation_state
auto connect(Rcvr rcvr) &&
noexcept(
84 std::is_nothrow_constructible_v<rcvr_t<Rcvr>, std::string&&,
schd_t<Rcvr>&&, Rcvr&&>
85 && stdexec::__nothrow_connectable<Sndr&&, rcvr_t<Rcvr>>) {
87 stdexec::get_completion_scheduler<stdexec::set_value_t>(stdexec::get_env(
sndr), stdexec::get_env(rcvr));
89 return stdexec::connect(
90 std::forward<Sndr>(
sndr),
91 rcvr_t<Rcvr>{.name = std::move(
name), .schd = std::move(schd), .rcvr = std::move(rcvr)});
101 template <stdexec::sender Sndr,
typename T>
103 return {.name = std::forward<T>(name), .sndr = std::forward<Sndr>(sndr)};
106 template <
typename T>
108 return stdexec::__closure{*
this, std::forward<T>(name)};
113 template <stdexec::sender Sndr>
115 return {.sndr = std::forward<Sndr>(sndr)};
119 return stdexec::__closure{*
this};
125 template <stdexec::sender Sndr,
typename T, stdexec::__sender_adaptor_closure Closure>
127 return std::forward<Sndr>(sndr) |
Push{}(std::forward<T>(name)) | std::forward<Closure>(closure) |
Pop{}();
130 template <
typename T, stdexec::__sender_adaptor_closure Closure>
132 return stdexec::__closure{*
this, std::forward<T>(name), std::forward<Closure>(closure)};
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
#define KOKKOS_EXECUTION_COMPL_SIGS_KEEP(_sndr_type_)
#define KOKKOS_EXECUTION_FORWARDING_GET_ENV(_type_, _obj_)
Retrieve the environment of _obj_ (with forwarding). // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)...
Kind
Kind of region action.
constexpr Kokkos::Execution::ExecutionSpaceImpl::Push push
constexpr Kokkos::Execution::ExecutionSpaceImpl::ScopedRegion scoped_region
constexpr Kokkos::Execution::ExecutionSpaceImpl::Pop pop
auto operator()() const noexcept
auto operator()(Sndr &&sndr) const noexcept -> RegionSender< Kind::POP, Sndr >
auto operator()(T &&name) const noexcept
auto operator()(Sndr &&sndr, T &&name) const noexcept -> RegionSender< Kind::PUSH, Sndr >
stdexec::receiver_t receiver_concept
void set_error(Error &&err) &&noexcept
void complete(Tag tag, Args &&... args) &&noexcept
void set_value() &&noexcept
RegionReceiver< kind, schd_t< Rcvr >, Rcvr > rcvr_t
stdexec::__completion_scheduler_of_t< stdexec::set_value_t, Sndr, stdexec::env_of_t< Rcvr > > schd_t
stdexec::sender_t sender_concept
stdexec::operation_state auto connect(Rcvr rcvr) &&noexcept(std::is_nothrow_constructible_v< rcvr_t< Rcvr >, std::string &&, schd_t< Rcvr > &&, Rcvr && > &&stdexec::__nothrow_connectable< Sndr &&, rcvr_t< Rcvr > >)
Helper for Kokkos::Profiling::scoped_region.
auto operator()(Sndr &&sndr, T &&name, Closure &&closure) const noexcept
auto operator()(T &&name, Closure &&closure) const noexcept