1#ifndef KOKKOS_EXECUTION_GRAPH_EVENTS_HPP
2#define KOKKOS_EXECUTION_GRAPH_EVENTS_HPP
4#include "Kokkos_Core.hpp"
5#include "Kokkos_Graph.hpp"
7#if defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
25 return out <<
"GraphCreateEvent: {graph = " <<
event.graph <<
", root_node = " <<
event.root_node
26 <<
", dev_id = " <<
event.dev_id <<
", event_id = " <<
event.event_id <<
'}';
45 return out <<
"GraphAddNodeEvent: {graph = " <<
event.graph <<
", predecessor = " <<
event.predecessor
46 <<
", node = " <<
event.node <<
", dev_id = " <<
event.dev_id <<
'}';
59 using Kokkos::Execution::Utils::operator<<;
60 return out <<
"GraphAddAggregateNodeEvent: {graph = " <<
event.graph
61 <<
", predecessors = " <<
event.predecessors <<
", node = " <<
event.node <<
'}';
72 return out <<
"GraphInstantiateEvent: {graph = " <<
event.graph <<
'}';
84 return out <<
"GraphSubmitEvent: {graph = " <<
event.graph <<
", dev_id = " <<
event.dev_id <<
'}';
90concept NodeRef = Kokkos::Impl::is_specialization_of_v<T, Kokkos::Experimental::GraphNodeRef>;
93template <NodeRef NodeType>
95 return Kokkos::Impl::GraphAccess::get_graph_weak_ptr(node).lock().get();
99template <NodeRef NodeType>
101 return Kokkos::Impl::GraphAccess::get_node_ptr(node).get();
105template <Kokkos::ExecutionSpace Exec>
107#if defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
108 const auto root = graph.root_node();
113 .dev_id = Kokkos::Tools::Experimental::device_id(graph.get_device_handle().m_exec),
119template <Kokkos::ExecutionSpace Exec,
typename... Args>
120auto create_graph(
const Kokkos::Impl::DeviceHandle<Exec>& device_handle, Args&&... args) {
121 Kokkos::Experimental::Graph<Exec> graph{device_handle, std::forward<Args>(args)...};
131template <NodeRef Predecessor, NodeRef NodeType, Kokkos::ExecutionSpace Exec>
133 const Predecessor& predecessor,
134 const NodeType& node,
135 const Kokkos::Impl::DeviceHandle<Exec>& device_handle) {
136#if defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
142 .dev_id = Kokkos::Tools::Experimental::device_id(device_handle.m_exec)});
147template <NodeRef NodeType, NodeRef... Predecessors>
149#if defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
159template <Kokkos::ExecutionSpace Exec>
161#if defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
168template <Kokkos::ExecutionSpace Exec>
170#if defined(KOKKOS_EXECUTION_ENABLE_EVENT_DISPATCH)
173 .graph =
get_graph_impl_ptr(graph.root_node()), .dev_id = Kokkos::Tools::Experimental::device_id(exec)});
178template <Kokkos::ExecutionSpace Exec>
179void submit_graph(
const Kokkos::Experimental::Graph<Exec>& graph,
const Exec& exec) {
Constrain a type that is a specialization of Kokkos::Experimental::GraphNodeRef.
void graph_add_aggregate_node_event(const NodeType &aggregate, const Predecessors &... predecessors)
Record an event for an aggregate node added after predecessors.
void graph_add_node_event(const Predecessor &predecessor, const NodeType &node, const Kokkos::Impl::DeviceHandle< Exec > &device_handle)
Record an event for a node added after predecessor.
void graph_create_event(const Kokkos::Experimental::Graph< Exec > &graph)
Record a GraphCreateEvent event.
auto * get_node_ptr(const NodeType &node) noexcept
Retrieve the raw node pointer.
auto create_graph(const Kokkos::Impl::DeviceHandle< Exec > &device_handle, Args &&... args)
Create a graph and record the associated event with graph_create_event.
void graph_instantiate_event(const Kokkos::Experimental::Graph< Exec > &graph)
Record a GraphInstantiateEvent event.
void graph_submit_event(const Kokkos::Experimental::Graph< Exec > &graph, const Exec &exec)
Record a GraphSubmitEvent event.
auto * get_graph_impl_ptr(const NodeType &node) noexcept
Retrieve the raw graph pointer from a node.
void submit_graph(const Kokkos::Experimental::Graph< Exec > &graph, const Exec &exec)
Submit a graph and record the associated event with graph_submit_event.
auto get_next_event_id() noexcept
void dispatch(const EventType &event)
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph aggregate node is added.
friend std::ostream & operator<<(std::ostream &out, const GraphAddAggregateNodeEvent &event)
constexpr auto operator<=>(const GraphAddAggregateNodeEvent &) const =default
std::vector< void * > predecessors
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph node is added.
constexpr auto operator<=>(const GraphAddNodeEvent &) const =default
friend std::ostream & operator<<(std::ostream &out, const GraphAddNodeEvent &event)
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is created.
constexpr auto operator<=>(const GraphCreateEvent &) const =default
friend std::ostream & operator<<(std::ostream &out, const GraphCreateEvent &event)
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is instantiated.
friend std::ostream & operator<<(std::ostream &out, const GraphInstantiateEvent &event)
constexpr auto operator<=>(const GraphInstantiateEvent &) const =default
Event to be sent to Kokkos::utils::callbacks::dispatch when a Kokkos graph is submitted.
constexpr auto operator<=>(const GraphSubmitEvent &) const =default
friend std::ostream & operator<<(std::ostream &out, const GraphSubmitEvent &event)