@@ -257,8 +257,16 @@ TEST_F(CommandGraphTest, InOrderQueueWithPreviousHostTask) {
257
257
experimental::command_graph<experimental::graph_state::modifiable>
258
258
InOrderGraph{InOrderQueue.get_context (), InOrderQueue.get_device ()};
259
259
260
- auto EventInitial =
261
- InOrderQueue.submit ([&](handler &CGH) { CGH.host_task ([=]() {}); });
260
+ // Event dependency build depends on host task completion. Making it
261
+ // predictable with mutex in host task.
262
+ std::mutex HostTaskMutex;
263
+ std::unique_lock<std::mutex> Lock (HostTaskMutex, std::defer_lock);
264
+ Lock.lock ();
265
+ auto EventInitial = InOrderQueue.submit ([&](handler &CGH) {
266
+ CGH.host_task ([&HostTaskMutex]() {
267
+ std::lock_guard<std::mutex> HostTaskLock (HostTaskMutex);
268
+ });
269
+ });
262
270
auto EventInitialImpl = sycl::detail::getSyclObjImpl (EventInitial);
263
271
264
272
// Record in-order queue with three nodes.
@@ -305,10 +313,12 @@ TEST_F(CommandGraphTest, InOrderQueueWithPreviousHostTask) {
305
313
306
314
auto EventLastImpl = sycl::detail::getSyclObjImpl (EventLast);
307
315
auto WaitList = EventLastImpl->getWaitList ();
316
+ Lock.unlock ();
308
317
// Previous task is a host task. Explicit dependency is needed to enforce the
309
318
// execution order.
310
319
ASSERT_EQ (WaitList.size (), 1lu);
311
320
ASSERT_EQ (WaitList[0 ], EventInitialImpl);
321
+ InOrderQueue.wait ();
312
322
}
313
323
314
324
TEST_F (CommandGraphTest, InOrderQueueHostTaskAndGraph) {
0 commit comments