Skip to content

Commit 332febc

Browse files
committed
[SYCL] Reintroduce barrier trivial event for empty in-order queue
The changes in #20159 removed a test case checking that barriers on empty queues would be considered complete immediately. This commit reintroduces it with a fix for the case. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent b76f12e commit 332febc

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

sycl/source/queue.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,14 @@ event queue::ext_oneapi_submit_barrier(const std::vector<event> &WaitList,
366366
!EventImpl.hasCommandGraph();
367367
});
368368

369+
// If we have an empty in-order queue and no dependencies, we can just return
370+
// a trivially finished event.
371+
if (is_in_order() && !impl->hasCommandGraph() && !impl->MIsProfilingEnabled &&
372+
AllEventsEmptyOrNop && ext_oneapi_empty()) {
373+
return detail::createSyclObjFromImpl<event>(
374+
detail::event_impl::create_default_event());
375+
}
376+
369377
if (WaitList.empty() || AllEventsEmptyOrNop)
370378
return submit([=](handler &CGH) { CGH.ext_oneapi_barrier(); }, CodeLoc);
371379
else

sycl/test-e2e/InorderQueue/in_order_ext_oneapi_submit_barrier.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ int main() {
6060
Q.wait();
6161
assert(*Res == 10);
6262
}
63+
{
64+
// Test cast 3 - empty queue.
65+
std::cout << "Test 3" << std::endl;
66+
sycl::queue EmptyQ({sycl::property::queue::in_order{}});
67+
auto BarrierEvent = EmptyQ.ext_oneapi_submit_barrier();
68+
assert(
69+
BarrierEvent.get_info<sycl::info::event::command_execution_status>() ==
70+
sycl::info::event_command_status::complete);
71+
BarrierEvent.wait();
72+
}
6373
{
6474
// Test cast 4 - graph.
6575
sycl::queue GQueue{sycl::property::queue::in_order{}};

0 commit comments

Comments
 (0)