Skip to content

Commit

Permalink
Merge pull request #237 from reble/julianmi/fix-double-root-nodes
Browse files Browse the repository at this point in the history
Fix adding empty nodes to the graph results in two root nodes
  • Loading branch information
julianmi authored and EwanC committed Jun 29, 2023
1 parent b4c24ba commit be7c202
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
3 changes: 0 additions & 3 deletions sycl/source/detail/graph_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ graph_impl::add(const std::shared_ptr<graph_impl> &Impl,
if (Handler.MSubgraphNode) {
return Handler.MSubgraphNode;
}
if (Handler.MCGType == sycl::detail::CG::None) {
return this->add(Dep);
}
return this->add(Handler.MCGType, std::move(Handler.MGraphNodeCG), Dep);
}

Expand Down
9 changes: 3 additions & 6 deletions sycl/source/detail/graph_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ class node_impl {
/// Command group object which stores all args etc needed to enqueue the node
std::unique_ptr<sycl::detail::CG> MCommandGroup;

/// True if an empty node, false otherwise.
bool MIsEmpty = false;

/// Add successor to the node.
/// @param Node Node to add as a successor.
/// @param Prev Predecessor to \p node being added as successor.
Expand All @@ -65,7 +62,7 @@ class node_impl {
}

/// Construct an empty node.
node_impl() : MIsEmpty(true) {}
node_impl() {}

/// Construct a node representing a command-group.
/// @param CGType Type of the command-group.
Expand Down Expand Up @@ -106,7 +103,7 @@ class node_impl {

/// Query if this is an empty node.
/// @return True if this is an empty node, false otherwise.
bool isEmpty() const { return MIsEmpty; }
bool isEmpty() const { return MCGType == sycl::detail::CG::None; }

/// Get a deep copy of this node's command group
/// @return A unique ptr to the new command group object.
Expand Down Expand Up @@ -366,7 +363,7 @@ class exec_graph_impl {

/// Turns the internal graph representation into UR command-buffers for a
/// device.
/// @param D Device to create backend command-buffers for.
/// @param Device Device to create backend command-buffers for.
void createURCommandBuffers(sycl::device Device);

/// Query for the context tied to this graph.
Expand Down
13 changes: 5 additions & 8 deletions sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,23 +380,20 @@ event handler::finalize() {
if (detail::pi::trace(detail::pi::TraceLevel::PI_TRACE_ALL)) {
std::cout << "WARNING: An empty command group is submitted." << std::endl;
}
std::shared_ptr<ext::oneapi::experimental::detail::graph_impl> GraphImpl;
if (MGraph) {
GraphImpl = MGraph;
CommandGroup.reset(
new detail::CG(detail::CG::None, std::move(CGData), MCodeLoc));
MGraphNodeCG = std::move(CommandGroup);
} else if (auto QueueGraph = MQueue->getCommandGraph(); QueueGraph) {
GraphImpl = QueueGraph;
}

if (GraphImpl) {
auto EventImpl = std::make_shared<detail::event_impl>();

// Extract relevant data from the handler and pass to graph to create a
// new node representing this command group.
std::shared_ptr<ext::oneapi::experimental::detail::node_impl> NodeImpl =
GraphImpl->add(CGData.MEvents);
QueueGraph->add(CGData.MEvents);

// Associate an event with this new node and return the event.
GraphImpl->addEventForNode(EventImpl, NodeImpl);
QueueGraph->addEventForNode(EventImpl, NodeImpl);

return detail::createSyclObjFromImpl<event>(EventImpl);
}
Expand Down

0 comments on commit be7c202

Please sign in to comment.