Implementation details of command_graph<modifiable>. More...
#include <detail/graph_impl.hpp>
Public Types | |
using | ReadLock = std::shared_lock< std::shared_mutex > |
using | WriteLock = std::unique_lock< std::shared_mutex > |
Public Member Functions | |
graph_impl (const sycl::context &SyclContext, const sycl::device &SyclDevice, const sycl::property_list &PropList={}) | |
Constructor. More... | |
~graph_impl () | |
void | removeRoot (const std::shared_ptr< node_impl > &Root) |
Remove node from list of root nodes. More... | |
std::shared_ptr< node_impl > | add (node_type NodeType, std::unique_ptr< sycl::detail::CG > CommandGroup, const std::vector< std::shared_ptr< node_impl >> &Dep={}) |
Create a kernel node in the graph. More... | |
std::shared_ptr< node_impl > | add (const std::shared_ptr< graph_impl > &Impl, std::function< void(handler &)> CGF, const std::vector< sycl::detail::ArgDesc > &Args, const std::vector< std::shared_ptr< node_impl >> &Dep={}) |
Create a CGF node in the graph. More... | |
std::shared_ptr< node_impl > | add (const std::shared_ptr< graph_impl > &Impl, const std::vector< std::shared_ptr< node_impl >> &Dep={}) |
Create an empty node in the graph. More... | |
std::shared_ptr< node_impl > | add (const std::shared_ptr< graph_impl > &Impl, const std::vector< sycl::detail::EventImplPtr > Events) |
Create an empty node in the graph. More... | |
void | addQueue (const std::shared_ptr< sycl::detail::queue_impl > &RecordingQueue) |
Add a queue to the set of queues which are currently recording to this graph. More... | |
void | removeQueue (const std::shared_ptr< sycl::detail::queue_impl > &RecordingQueue) |
Remove a queue from the set of queues which are currently recording to this graph. More... | |
bool | clearQueues () |
Remove all queues which are recording to this graph, also sets all queues cleared back to the executing state. More... | |
void | addEventForNode (std::shared_ptr< graph_impl > GraphImpl, std::shared_ptr< sycl::detail::event_impl > EventImpl, std::shared_ptr< node_impl > NodeImpl) |
Associate a sycl event with a node in the graph. More... | |
std::shared_ptr< sycl::detail::event_impl > | getEventForNode (std::shared_ptr< node_impl > NodeImpl) const |
Find the sycl event associated with a node. More... | |
std::shared_ptr< node_impl > | getNodeForEvent (std::shared_ptr< sycl::detail::event_impl > EventImpl) |
Find the node associated with a SYCL event. More... | |
sycl::context | getContext () const |
Query for the context tied to this graph. More... | |
sycl::device | getDevice () const |
Query for the device tied to this graph. More... | |
std::shared_ptr< node_impl > | getLastInorderNode (std::shared_ptr< sycl::detail::queue_impl > Queue) |
Find the last node added to this graph from an in-order queue. More... | |
void | setLastInorderNode (std::shared_ptr< sycl::detail::queue_impl > Queue, std::shared_ptr< node_impl > Node) |
Track the last node added to this graph from an in-order queue. More... | |
void | printGraphAsDot (const std::string FilePath, bool Verbose) const |
Prints the contents of the graph to a text file in DOT format. More... | |
void | makeEdge (std::shared_ptr< node_impl > Src, std::shared_ptr< node_impl > Dest) |
Make an edge between two nodes in the graph. More... | |
void | throwIfGraphRecordingQueue (const std::string ExceptionMsg) const |
Throws an invalid exception if this function is called while a queue is recording commands to the graph. More... | |
bool | hasSimilarStructure (std::shared_ptr< detail::graph_impl > Graph, bool DebugPrint=false) const |
Checks if the graph_impl of Graph has a similar structure to the graph_impl of the caller. More... | |
size_t | getNumberOfNodes () const |
Returns the number of nodes in the Graph. More... | |
std::vector< sycl::detail::EventImplPtr > | getExitNodesEvents () |
Traverse the graph recursively to get the events associated with the output nodes of this graph. More... | |
std::vector< sycl::detail::EventImplPtr > | removeBarriersFromExtraDependencies () |
Removes all Barrier nodes from the list of extra dependencies MExtraDependencies. More... | |
Static Public Member Functions | |
static bool | checkNodeRecursive (const std::shared_ptr< node_impl > &NodeA, const std::shared_ptr< node_impl > &NodeB) |
Recursively check successors of NodeA and NodeB to check they are similar. More... | |
Public Attributes | |
std::shared_mutex | MMutex |
Protects all the fields that can be changed by class' methods. More... | |
std::set< std::weak_ptr< node_impl >, std::owner_less< std::weak_ptr< node_impl > > > | MRoots |
List of root nodes. More... | |
std::vector< std::shared_ptr< node_impl > > | MNodeStorage |
Storage for all nodes contained within a graph. More... | |
Implementation details of command_graph<modifiable>.
Definition at line 794 of file graph_impl.hpp.
using sycl::_V1::ext::oneapi::experimental::detail::graph_impl::ReadLock = std::shared_lock<std::shared_mutex> |
Definition at line 796 of file graph_impl.hpp.
using sycl::_V1::ext::oneapi::experimental::detail::graph_impl::WriteLock = std::unique_lock<std::shared_mutex> |
Definition at line 797 of file graph_impl.hpp.
|
inline |
Constructor.
SyclContext | Context to use for graph. |
SyclDevice | Device to create nodes with. |
PropList | Optional list of properties. |
Definition at line 806 of file graph_impl.hpp.
sycl::_V1::ext::oneapi::experimental::detail::graph_impl::~graph_impl | ( | ) |
Definition at line 298 of file graph_impl.cpp.
References clearQueues().
std::shared_ptr< node_impl > sycl::_V1::ext::oneapi::experimental::detail::graph_impl::add | ( | const std::shared_ptr< graph_impl > & | Impl, |
const std::vector< std::shared_ptr< node_impl >> & | Dep = {} |
||
) |
Create an empty node in the graph.
Impl | Graph implementation pointer. |
Dep | List of predecessor nodes. |
Definition at line 348 of file graph_impl.cpp.
References addEventForNode(), and MNodeStorage.
std::shared_ptr< node_impl > sycl::_V1::ext::oneapi::experimental::detail::graph_impl::add | ( | const std::shared_ptr< graph_impl > & | Impl, |
const std::vector< sycl::detail::EventImplPtr > | Events | ||
) |
Create an empty node in the graph.
Impl | Graph implementation pointer. |
Events | List of events associated to this node. |
Definition at line 413 of file graph_impl.cpp.
References add(), and sycl::_V1::invalid.
std::shared_ptr< node_impl > sycl::_V1::ext::oneapi::experimental::detail::graph_impl::add | ( | const std::shared_ptr< graph_impl > & | Impl, |
std::function< void(handler &)> | CGF, | ||
const std::vector< sycl::detail::ArgDesc > & | Args, | ||
const std::vector< std::shared_ptr< node_impl >> & | Dep = {} |
||
) |
Create a CGF node in the graph.
Impl | Graph implementation pointer to create a handler with. |
CGF | Command-group function to create node with. |
Args | Node arguments. |
Dep | Dependencies of the created node. |
Definition at line 367 of file graph_impl.cpp.
References add(), addEventForNode(), sycl::_V1::ext::oneapi::experimental::empty, sycl::_V1::ext::oneapi::experimental::detail::getNodeTypeFromCG(), sycl::_V1::invalid, sycl::_V1::ext::oneapi::experimental::kernel, and sycl::_V1::make_error_code().
std::shared_ptr< node_impl > sycl::_V1::ext::oneapi::experimental::detail::graph_impl::add | ( | node_type | NodeType, |
std::unique_ptr< sycl::detail::CG > | CommandGroup, | ||
const std::vector< std::shared_ptr< node_impl >> & | Dep = {} |
||
) |
Create a kernel node in the graph.
NodeType | User facing type of the node. |
CommandGroup | The CG which stores all information for this node. |
Dep | Dependencies of the created node. |
Definition at line 433 of file graph_impl.cpp.
References sycl::_V1::invalid, sycl::_V1::make_error_code(), and MNodeStorage.
Referenced by add().
|
inline |
Associate a sycl event with a node in the graph.
GraphImpl | shared_ptr to Graph impl associated with this event, aka this. |
EventImpl | Event to associate with a node in map. |
NodeImpl | Node to associate with event in map. |
Definition at line 899 of file graph_impl.hpp.
Referenced by add().
|
inline |
Add a queue to the set of queues which are currently recording to this graph.
RecordingQueue | Queue to add to set. |
Definition at line 876 of file graph_impl.hpp.
|
inlinestatic |
Recursively check successors of NodeA and NodeB to check they are similar.
NodeA | pointer to the first node for comparison |
NodeB | pointer to the second node for comparison |
Definition at line 1026 of file graph_impl.hpp.
Referenced by hasSimilarStructure().
bool sycl::_V1::ext::oneapi::experimental::detail::graph_impl::clearQueues | ( | ) |
Remove all queues which are recording to this graph, also sets all queues cleared back to the executing state.
Definition at line 506 of file graph_impl.cpp.
Referenced by ~graph_impl().
|
inline |
Query for the context tied to this graph.
Definition at line 945 of file graph_impl.hpp.
|
inline |
Query for the device tied to this graph.
Definition at line 949 of file graph_impl.hpp.
|
inline |
Find the sycl event associated with a node.
NodeImpl | Node to find event for. |
Definition at line 911 of file graph_impl.hpp.
References sycl::_V1::invalid, and MMutex.
Referenced by getExitNodesEvents(), and removeBarriersFromExtraDependencies().
std::vector< sycl::detail::EventImplPtr > sycl::_V1::ext::oneapi::experimental::detail::graph_impl::getExitNodesEvents | ( | ) |
Traverse the graph recursively to get the events associated with the output nodes of this graph.
Definition at line 611 of file graph_impl.cpp.
References getEventForNode(), and MNodeStorage.
|
inline |
Find the last node added to this graph from an in-order queue.
Queue | In-order queue to find the last node added to the graph from. |
Queue
recording, or empty shared pointer if none. Definition at line 966 of file graph_impl.hpp.
|
inline |
Find the node associated with a SYCL event.
Throws if no node is found for the given event.
EventImpl | Event to find the node for. |
Definition at line 930 of file graph_impl.hpp.
References sycl::_V1::invalid, and MMutex.
|
inline |
Returns the number of nodes in the Graph.
Definition at line 1129 of file graph_impl.hpp.
References MNodeStorage.
|
inline |
Checks if the graph_impl of Graph has a similar structure to the graph_impl of the caller.
Graphs are considered similar if they have same numbers of nodes of the same type with similar predecessor and successor nodes (number and type). Two nodes are considered similar if they have the same command-group type. For command-groups of type "kernel", the "signature" of the kernel is also compared (i.e. the name of the command-group).
Graph | if reference to the graph to compare with. |
DebugPrint | if set to true throw exception with additional debug information about the spotted graph differences. |
Definition at line 1056 of file graph_impl.hpp.
References checkNodeRecursive(), sycl::_V1::invalid, and MRoots.
void sycl::_V1::ext::oneapi::experimental::detail::graph_impl::makeEdge | ( | std::shared_ptr< node_impl > | Src, |
std::shared_ptr< node_impl > | Dest | ||
) |
Make an edge between two nodes in the graph.
Performs some mandatory error checks as well as an optional check for cycles introduced by making this edge.
Src | The source of the new edge. |
Dest | The destination of the new edge. |
Definition at line 560 of file graph_impl.cpp.
References sycl::_V1::make_error_code(), MNodeStorage, removeRoot(), and throwIfGraphRecordingQueue().
|
inline |
Prints the contents of the graph to a text file in DOT format.
FilePath | Path to the output file. |
Verbose | If true, print additional information about the nodes such as kernel args or memory access where applicable. |
Vector of nodes visited during the graph printing
Definition at line 987 of file graph_impl.hpp.
References MRoots.
|
inline |
Removes all Barrier nodes from the list of extra dependencies MExtraDependencies.
Definition at line 1140 of file graph_impl.hpp.
References getEventForNode().
|
inline |
Remove a queue from the set of queues which are currently recording to this graph.
RecordingQueue | Queue to remove from set. |
Definition at line 884 of file graph_impl.hpp.
void sycl::_V1::ext::oneapi::experimental::detail::graph_impl::removeRoot | ( | const std::shared_ptr< node_impl > & | Root | ) |
Remove node from list of root nodes.
Root | Node to remove from list of root nodes. |
Definition at line 343 of file graph_impl.cpp.
References MRoots.
Referenced by makeEdge().
|
inline |
Track the last node added to this graph from an in-order queue.
Queue | In-order queue to register Node for. |
Node | Last node that was added to this graph from Queue . |
Definition at line 977 of file graph_impl.hpp.
|
inline |
Throws an invalid exception if this function is called while a queue is recording commands to the graph.
ExceptionMsg | Message to append to the exception message |
Definition at line 1013 of file graph_impl.hpp.
References sycl::_V1::make_error_code().
Referenced by makeEdge().
|
mutable |
Protects all the fields that can be changed by class' methods.
Definition at line 800 of file graph_impl.hpp.
Referenced by getEventForNode(), and getNodeForEvent().
std::vector<std::shared_ptr<node_impl> > sycl::_V1::ext::oneapi::experimental::detail::graph_impl::MNodeStorage |
Storage for all nodes contained within a graph.
Nodes are connected to each other via weak_ptrs and so do not extend each other's lifetimes. This storage allows easy iteration over all nodes in the graph, rather than needing an expensive depth first search.
Definition at line 959 of file graph_impl.hpp.
Referenced by add(), getExitNodesEvents(), getNumberOfNodes(), and makeEdge().
std::set<std::weak_ptr<node_impl>, std::owner_less<std::weak_ptr<node_impl> > > sycl::_V1::ext::oneapi::experimental::detail::graph_impl::MRoots |
List of root nodes.
Definition at line 953 of file graph_impl.hpp.
Referenced by hasSimilarStructure(), printGraphAsDot(), and removeRoot().