Skip to content

Commit 52c2bc9

Browse files
fabiomestreEwanC
andauthored
[SYCL][Graph] Fix issue when updating HostTasks with whole graph update (#17645)
When updating a HostTask using whole graph update, we rely on the Sycl Scheduler to execute the HostTask and all its dependencies. The Scheduler executes this work asynchronously using a separate thread. Since exec_graph.update() was non-blocking, this was causing issues, where the user code could, for example, free resources, before the update() command (which is a dependent on the HostTask completion) could execute. This commit fixes this issue by making exec_graph.update() blocking when host_tasks are used. Co-authored-by: Ewan Crawford <[email protected]>
1 parent 1426736 commit 52c2bc9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sycl/source/detail/graph_impl.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,14 @@ void exec_graph_impl::update(
13981398
this, Nodes, AllocaQueue, UpdateRequirements, MExecutionEvents);
13991399

14001400
MExecutionEvents.push_back(UpdateEvent);
1401+
1402+
if (MContainsHostTask) {
1403+
// If the graph has HostTasks, the update has to be blocking. This is
1404+
// needed because HostTask nodes (and all the nodes that depend on
1405+
// HostTasks), are scheduled using a separate thread. This wait call
1406+
// acts as a synchronization point for that thread.
1407+
UpdateEvent->wait(UpdateEvent);
1408+
}
14011409
} else {
14021410
// For each partition in the executable graph, call UR update on the
14031411
// command-buffer with the nodes to update.

0 commit comments

Comments
 (0)