kokkos-execution 0.0.1
Loading...
Searching...
No Matches
Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs > Struct Template Reference

Operation state for stdexec::when_all. More...

#include <when_all.hpp>

Inheritance diagram for Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >:
Kokkos::Execution::Impl::Immovable Kokkos::Execution::GraphImpl::OpStateBase< Exec, Rcvr >

Classes

struct  WhenAllChildReceiver
 Receiver for a child of stdexec::when_all. More...
struct  JoinOpStateNodes
 Join the nodes of all operation states into one aggregate node. More...

Public Types

using operation_state_concept = stdexec::operation_state_tag
using base_t = OpStateBase<Exec, Rcvr>
using execution_space = Exec
using predecessor_t = GraphComposition::node_t<Exec, Rcvr>
using children_op_states_t = stdexec::__tuple<stdexec::connect_result_t<Sndrs, WhenAllChildReceiver>...>
using node_t = std::invoke_result_t<JoinOpStateNodes, const children_op_states_t&>
using graph_composition_policy_t
using state_t = State<graph_composition_policy_t, execution_space>
Public Types inherited from Kokkos::Execution::GraphImpl::OpStateBase< Exec, Rcvr >
using completion_signal_policy_t = decltype(select_completion_signal_policy())
using completion_signal_t = Impl::CompletionSignal<completion_signal_policy_t, Exec, Rcvr>

Public Member Functions

 WhenAllOpState (stdexec::__tuple< Sndrs... > &&sndrs_, Rcvr &&rcvr_)
const predecessor_t & get_predecessor () const noexcept
auto query (get_node_t) const &noexcept -> const node_t &requires(!Impl::empty< node_t >)
auto query (get_graph_t) const &noexcept -> const typename state_t::graph_t &
void submit () &noexcept
void submit () &noexcept
void complete (stdexec::set_value_t) &noexcept
template<typename Tag, typename... Args>
requires (!std::same_as<Tag, stdexec::set_value_t>)
void complete (Tag, Args &&... args) &noexcept
void start () &noexcept
void start () &noexcept
 If as_one is true, there is no need to start the branches.
void submit_graph () &noexcept
void submit_graph () &noexcept
constexpr auto get_env () const noexcept -> stdexec::env_of_t< Rcvr >
Public Member Functions inherited from Kokkos::Execution::Impl::Immovable
 Immovable ()=default
 Immovable (Immovable &&)=delete
Immovable & operator= (Immovable &&)=delete
 Immovable (const Immovable &)=delete
Immovable & operator= (const Immovable &)=delete
 ~Immovable ()=default
Public Member Functions inherited from Kokkos::Execution::GraphImpl::OpStateBase< Exec, Rcvr >
constexpr OpStateBase (Rcvr rcvr) noexcept(std::is_nothrow_constructible_v< completion_signal_t, Rcvr && >)
template<typename Error>
void complete (stdexec::set_error_t, Error &&error) noexcept
void complete (stdexec::set_stopped_t) noexcept

Public Attributes

state_t state
children_op_states_t children_op_states
PRAGMA_DIAGNOSTIC_PUSH KOKKOS_EXECUTION_PRAGMA_DIAGNOSTIC_IGNORED_DANGLING_REFERENCE node_t node
PRAGMA_DIAGNOSTIC_POP Impl::CompileTimeOptional<!as_one, std::atomic< size_t > > count {num_branches_not_remaining_on_graph}
Public Attributes inherited from Kokkos::Execution::GraphImpl::OpStateBase< Exec, Rcvr >
completion_signal_t completion_signal

Static Public Attributes

static constexpr bool as_one
 Determine if all branches remain fully on the graph, if connected to WhenAllChildReceiver.
static constexpr bool at_least_one_child_adds_a_node
 Determine if at least one child operation state will add a node.
static constexpr std::size_t num_branches = sizeof...(Sndrs)
 Number of branches.
static constexpr std::size_t num_branches_remaining_on_graph
 Determine how many branches remain on graph (and how many don't).
static constexpr std::size_t num_branches_not_remaining_on_graph = num_branches - num_branches_remaining_on_graph

Additional Inherited Members

Static Public Member Functions inherited from Kokkos::Execution::GraphImpl::OpStateBase< Exec, Rcvr >
static consteval auto select_completion_signal_policy () noexcept

Detailed Description

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
struct Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >

Operation state for stdexec::when_all.

It creates the graph, and passes it to its branches through the receiver environment.

Definition at line 44 of file when_all.hpp.

Member Typedef Documentation

◆ base_t

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
using Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::base_t = OpStateBase<Exec, Rcvr>

Definition at line 49 of file when_all.hpp.

◆ children_op_states_t

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
using Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::children_op_states_t = stdexec::__tuple<stdexec::connect_result_t<Sndrs, WhenAllChildReceiver>...>

Definition at line 67 of file when_all.hpp.

◆ execution_space

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
using Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::execution_space = Exec

Definition at line 50 of file when_all.hpp.

◆ graph_composition_policy_t

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
using Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::graph_composition_policy_t
Initial value:
std::conditional_t<at_least_one_child_adds_a_node, GraphComposition::policy_t<Rcvr>, GraphComposition::Attach>
Attach to the existing graph of the predecessor.
Definition get_graph.hpp:34

If at_least_one_child_adds_a_node is false, the composition policy is unconditionally GraphComposition::Attach to avoid creating a useless Kokkos::Experimental::Graph.

Definition at line 143 of file when_all.hpp.

◆ node_t

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
using Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::node_t = std::invoke_result_t<JoinOpStateNodes, const children_op_states_t&>

Definition at line 139 of file when_all.hpp.

◆ operation_state_concept

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
using Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::operation_state_concept = stdexec::operation_state_tag

Definition at line 47 of file when_all.hpp.

◆ predecessor_t

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
using Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::predecessor_t = GraphComposition::node_t<Exec, Rcvr>

Definition at line 52 of file when_all.hpp.

◆ state_t

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
using Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::state_t = State<graph_composition_policy_t, execution_space>

Definition at line 145 of file when_all.hpp.

Constructor & Destructor Documentation

◆ WhenAllOpState()

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::WhenAllOpState ( stdexec::__tuple< Sndrs... > && sndrs_,
Rcvr && rcvr_ )
inline
Warning
Unconditionally not noexcept because both graph and node construction may throw.
Todo
The graph will be created on the default device and submitted on the default execution space instance. The device selection for each node will still happen correctly according to each node properties. A possibility could be to ask the successor of stdexec::when_all for an execution space instance to submit the graph onto.

Definition at line 159 of file when_all.hpp.

References children_op_states, and state.

Member Function Documentation

◆ complete() [1/2]

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
void Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::complete ( stdexec::set_value_t ) &
inlinenoexcept

Definition at line 236 of file when_all.hpp.

References submit().

◆ complete() [2/2]

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
template<typename Tag, typename... Args>
requires (!std::same_as<Tag, stdexec::set_value_t>)
void Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::complete ( Tag ,
Args &&... args ) &
inlinenoexcept

◆ get_env()

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
auto Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::get_env ( ) const -> stdexec::env_of_t< Rcvr >
inlinenodiscardconstexprnoexcept

◆ get_predecessor()

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
const predecessor_t & Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::get_predecessor ( ) const
inlinenoexcept

◆ query() [1/2]

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
auto Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::query ( get_graph_t ) const & -> const typename state_t::graph_t &
inlinenodiscardnoexcept

Definition at line 197 of file when_all.hpp.

References state.

◆ query() [2/2]

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
auto Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::query ( get_node_t ) const & -> const node_t &requires(!Impl::empty< node_t >)
inlinenodiscardnoexcept

Definition at line 191 of file when_all.hpp.

References node.

◆ start() [1/2]

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
void Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::start ( ) &
inlinenoexcept

If as_one is true, there is no need to start the branches.

Definition at line 271 of file when_all.hpp.

References as_one, and submit().

◆ start() [2/2]

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
void Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::start ( ) &
inlinenoexcept

Definition at line 246 of file when_all.hpp.

References as_one, and children_op_states.

◆ submit() [1/2]

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
void Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::submit ( ) &
inlinenoexcept

Definition at line 231 of file when_all.hpp.

References as_one, and submit_graph().

◆ submit() [2/2]

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
void Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::submit ( ) &
inlinenoexcept

Each branch that does not remain on graph calls this method if as_one is false. Once the counter decreases to zero, the graph is submitted. This allows branches that may start with operations that are not part of the graph, implying that the graph cannot be submitted by one of the other branches.

The following schematic illustrates such a situation.

* (branch 1) -> (thread) -> (then) -> (graph) -> (then) -\
*                                                         -> (when_all)
* (branch 0) -> (graph) -> (bulk)                       -/
* 

If the branch 0 submits the graph before calling WhenAllOpState::complete, the graph will be submitted before the branch 1 is started, leading to operations of the graph in branch 1 potentially running before the "thread".

Note
In the future, a solution could be to create one graph per branch in such a setting, but it would require introspecting the sender type of each branch, recursively.

Definition at line 224 of file when_all.hpp.

References as_one, count, and submit_graph().

◆ submit_graph() [1/2]

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
void Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::submit_graph ( ) &
inlinenoexcept

◆ submit_graph() [2/2]

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
void Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::submit_graph ( ) &
inlinenoexcept

Member Data Documentation

◆ as_one

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
bool Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::as_one
staticconstexpr
Initial value:

Determine if all branches remain fully on the graph, if connected to WhenAllChildReceiver.

Definition at line 70 of file when_all.hpp.

◆ at_least_one_child_adds_a_node

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
bool Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::at_least_one_child_adds_a_node
staticconstexpr
Initial value:
= stdexec::__mapply<
stdexec::__many_of<stdexec::__q<Impl::queryable_for<get_node_t>::type>>,
>::value
stdexec::__tuple< stdexec::connect_result_t< Sndrs, WhenAllChildReceiver >... > children_op_states_t
Definition when_all.hpp:67

Determine if at least one child operation state will add a node.

Definition at line 74 of file when_all.hpp.

◆ children_op_states

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
children_op_states_t Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::children_op_states

Definition at line 149 of file when_all.hpp.

◆ count

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
PRAGMA_DIAGNOSTIC_POP Impl::CompileTimeOptional<!as_one, std::atomic<size_t> > Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::count {num_branches_not_remaining_on_graph}

Definition at line 156 of file when_all.hpp.

◆ node

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
PRAGMA_DIAGNOSTIC_PUSH KOKKOS_EXECUTION_PRAGMA_DIAGNOSTIC_IGNORED_DANGLING_REFERENCE node_t Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::node

Definition at line 153 of file when_all.hpp.

◆ num_branches

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
std::size_t Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::num_branches = sizeof...(Sndrs)
staticconstexpr

Number of branches.

Definition at line 80 of file when_all.hpp.

◆ num_branches_not_remaining_on_graph

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
std::size_t Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::num_branches_not_remaining_on_graph = num_branches - num_branches_remaining_on_graph
staticconstexpr

Definition at line 87 of file when_all.hpp.

◆ num_branches_remaining_on_graph

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
std::size_t Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::num_branches_remaining_on_graph
staticconstexpr
Initial value:
= stdexec::__mapply<
stdexec::__mcount_if<stdexec::__mbind_back_q<RemainsOnGraphFor, Exec>>,
>::value

Determine how many branches remain on graph (and how many don't).

Definition at line 83 of file when_all.hpp.

◆ state

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
state_t Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::state

Definition at line 148 of file when_all.hpp.


The documentation for this struct was generated from the following file:
  • /__w/kokkos-execution/kokkos-execution/kokkos-execution/graph/when_all.hpp