Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions sycl/source/detail/graph/graph_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,14 @@ void graph_impl::beginRecording(sycl::detail::queue_impl &Queue) {
addQueue(Queue);
}
}
void graph_impl::endRecording() {
// Collect attribute(s) for recorded Graph
if (MRecordingQueues.size() == 1) {
if (auto ValidQueue = MRecordingQueues.begin()->lock(); ValidQueue) {
MIsLinearRecorded = ValidQueue->isInOrder();
}
}
}

// Check if nodes do not require enqueueing and if so loop back through
// predecessors until we find the real dependency.
Expand Down Expand Up @@ -1262,6 +1270,11 @@ exec_graph_impl::enqueue(sycl::detail::queue_impl &Queue,
}

void exec_graph_impl::duplicateNodes() {
if (MGraphImpl->isLinearRecorded() && !MGraphImpl->hasSubGraph()) {
MNodeStorage = MGraphImpl->MNodeStorage;
return;
}

// Map of original modifiable nodes (keys) to new duplicated nodes (values)
std::map<node_impl *, node_impl *> NodesMap;

Expand Down Expand Up @@ -1965,6 +1978,7 @@ void modifiable_command_graph::begin_recording(

void modifiable_command_graph::end_recording() {
graph_impl::WriteLock Lock(impl->MMutex);
impl->endRecording();
impl->clearQueues();
}

Expand Down
10 changes: 10 additions & 0 deletions sycl/source/detail/graph/graph_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> {
/// of recording queues associated with this graph.
/// @param[in] Queue The queue to be recorded from.
void beginRecording(sycl::detail::queue_impl &Queue);
void endRecording();

bool isLinearRecorded() const { return MIsLinearRecorded; }
void setHasSubGraph() { MOriginGraphHasSubGraph = true; }
bool hasSubGraph() const { return MOriginGraphHasSubGraph; }

/// Store the last barrier node that was submitted to the queue.
/// @param[in] Queue The queue the barrier was recorded from.
Expand Down Expand Up @@ -600,6 +605,11 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> {
// The number of live executable graphs that have been created from this
// modifiable graph
std::atomic<size_t> MExecGraphCount = 0;

// True if the graph is recorded from a single in-order queue
bool MIsLinearRecorded = false;
// True if the graph contains subgraph when constructed by recording
bool MOriginGraphHasSubGraph = false;
};

/// Class representing the implementation of command_graph<executable>.
Expand Down
1 change: 1 addition & 0 deletions sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ event handler::finalize() {
ParentLock = ext::oneapi::experimental::detail::graph_impl::WriteLock(
ParentGraph->MMutex);
}
ParentGraph->setHasSubGraph();
impl->CGData.MRequirements = impl->MExecGraph->getRequirements();
// Here we are using the CommandGroup without passing a CommandBuffer to
// pass the exec_graph_impl and event dependencies. Since this subgraph CG
Expand Down
Loading