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...

Public Types

using operation_state_concept = stdexec::operation_state_tag
using base_t = OpStateBase<Exec, Rcvr>
using execution_space = Exec
using state_t = State<GraphComposition::Create, execution_space>
using root_t = typename state_t::graph_t::root_t
using children_op_states_t = stdexec::__tuple<stdexec::connect_result_t<Sndrs, WhenAllChildReceiver>...>
using node_t
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_)
auto query (get_node_t) const &noexcept -> const 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
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
root_t root
children_op_states_t children_op_states
node_t node
std::atomic< size_t > count = sizeof...(Sndrs)
Public Attributes inherited from Kokkos::Execution::GraphImpl::OpStateBase< Exec, Rcvr >
completion_signal_t completion_signal

Static Public Attributes

static constexpr bool as_one = (remains_on_graph_for<execution_space, Sndrs, WhenAllChildReceiver> && ...)
 Determine if all branches remain fully on the graph, if connected to WhenAllChildReceiver.

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 34 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 39 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 58 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 40 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
Initial value:
decltype(stdexec::__apply(
[](const auto&... ops) { return Kokkos::Experimental::when_all(ops.query(get_node)...); },
std::declval<const children_op_states_t&>()))
constexpr get_node_t get_node
Definition get_node.hpp:15

Definition at line 73 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 37 of file when_all.hpp.

◆ root_t

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
using Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::root_t = typename state_t::graph_t::root_t

Definition at line 43 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<GraphComposition::Create, execution_space>

Definition at line 42 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 occording 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 85 of file when_all.hpp.

References children_op_states, root, 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 159 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

◆ 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 119 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 &
inlinenodiscardnoexcept

Definition at line 114 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 178 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 169 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 154 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 calls this method if as_one is false. Once the counter decreases to zero, the graph is submitted. It is intended, because there is no strong check on the branch content if as_one is false. Indeed, one of the branches 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".

Todo
Add a test for the above schematic.

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 147 of file when_all.hpp.

References as_one, count, and submit_graph().

◆ submit_graph()

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 = (remains_on_graph_for<execution_space, Sndrs, WhenAllChildReceiver> && ...)
staticconstexpr

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

Definition at line 71 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 80 of file when_all.hpp.

◆ count

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

Definition at line 82 of file when_all.hpp.

◆ node

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

Definition at line 81 of file when_all.hpp.

◆ root

template<Kokkos::ExecutionSpace Exec, stdexec::receiver Rcvr, stdexec::sender... Sndrs>
root_t Kokkos::Execution::GraphImpl::WhenAllOpState< Exec, Rcvr, Sndrs >::root
Todo
The root node is stored to avoid reference counting incurred by https://github.com/kokkos/kokkos/blob/1945b637c3fab027fe90208753e8b2ec236302d4/core/src/Kokkos_Graph.hpp#L100.

Definition at line 79 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 77 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