-
Notifications
You must be signed in to change notification settings - Fork 792
[NFCI][SYCL][Graph] Refactor graph_impl::add
#19351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sycl
Are you sure you want to change the base?
Changes from all commits
99e9fa1
395f476
948122d
6427df9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,30 +147,30 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> { | |
/// @param CommandGroup The CG which stores all information for this node. | ||
/// @param Deps Dependencies of the created node. | ||
/// @return Created node in the graph. | ||
std::shared_ptr<node_impl> add(node_type NodeType, | ||
std::shared_ptr<sycl::detail::CG> CommandGroup, | ||
nodes_range Deps); | ||
node_impl &add(node_type NodeType, | ||
std::shared_ptr<sycl::detail::CG> CommandGroup, | ||
nodes_range Deps); | ||
|
||
/// Create a CGF node in the graph. | ||
/// @param CGF Command-group function to create node with. | ||
/// @param Args Node arguments. | ||
/// @param Deps Dependencies of the created node. | ||
/// @return Created node in the graph. | ||
std::shared_ptr<node_impl> add(std::function<void(handler &)> CGF, | ||
const std::vector<sycl::detail::ArgDesc> &Args, | ||
std::vector<std::shared_ptr<node_impl>> &Deps); | ||
node_impl &add(std::function<void(handler &)> CGF, | ||
const std::vector<sycl::detail::ArgDesc> &Args, | ||
nodes_range Deps); | ||
|
||
/// Create an empty node in the graph. | ||
/// @param Deps List of predecessor nodes. | ||
/// @return Created node in the graph. | ||
std::shared_ptr<node_impl> add(nodes_range Deps); | ||
node_impl &add(nodes_range Deps); | ||
|
||
/// Create a dynamic command-group node in the graph. | ||
/// @param DynCGImpl Dynamic command-group used to create node. | ||
/// @param Deps List of predecessor nodes. | ||
/// @return Created node in the graph. | ||
std::shared_ptr<node_impl> | ||
add(std::shared_ptr<dynamic_command_group_impl> &DynCGImpl, nodes_range Deps); | ||
node_impl &add(std::shared_ptr<dynamic_command_group_impl> &DynCGImpl, | ||
nodes_range Deps); | ||
|
||
/// Add a queue to the set of queues which are currently recording to this | ||
/// graph. | ||
|
@@ -511,6 +511,12 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> { | |
} | ||
|
||
private: | ||
template <typename... Ts> node_impl &createNode(Ts &&...Args) { | ||
MNodeStorage.push_back( | ||
std::make_shared<node_impl>(std::forward<Ts>(Args)...)); | ||
return *MNodeStorage.back(); | ||
Comment on lines
+515
to
+517
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if
If that's the case, then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
/// Check the graph for cycles by performing a depth-first search of the | ||
/// graph. If a node is visited more than once in a given path through the | ||
/// graph, a cycle is present and the search ends immediately. | ||
|
@@ -525,13 +531,13 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> { | |
/// added as a root node. | ||
/// @param Node The node to add deps for | ||
/// @param Deps List of dependent nodes | ||
void addDepsToNode(const std::shared_ptr<node_impl> &Node, nodes_range Deps) { | ||
void addDepsToNode(node_impl &Node, nodes_range Deps) { | ||
for (node_impl &N : Deps) { | ||
N.registerSuccessor(Node); | ||
this->removeRoot(*Node); | ||
this->removeRoot(Node); | ||
} | ||
if (Node->MPredecessors.empty()) { | ||
this->addRoot(*Node); | ||
if (Node.MPredecessors.empty()) { | ||
this->addRoot(Node); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to preserve the semantics. Not sure if truly necessary, maybe there is a guarantee that it must be empty. And if not, why are we dropping old deps?