diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 839570553f3ce..86a35e5ffac6c 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -667,6 +667,7 @@ class queue_impl : public std::enable_shared_from_this { getAdapter().call(getHandleRef(), 0, nullptr, &UREvent); ResEvent->setHandle(UREvent); + ResEvent->setEnqueued(); return ResEvent; } diff --git a/sycl/unittests/queue/Barrier.cpp b/sycl/unittests/queue/Barrier.cpp index b13d703085fc4..c2df018e16de1 100644 --- a/sycl/unittests/queue/Barrier.cpp +++ b/sycl/unittests/queue/Barrier.cpp @@ -8,13 +8,19 @@ #include #include +#include #include static unsigned NumOfEventsWaitWithBarrierCalls = 0; +static unsigned NumEventsInWaitList = 0; -static ur_result_t redefined_urEnqueueEventsWaitWithBarrierExt(void *) { +static ur_result_t redefined_urEnqueueEventsWaitWithBarrierExt(void *pParams) { NumOfEventsWaitWithBarrierCalls++; + // Get the number of events in the wait list + auto params = + *static_cast(pParams); + NumEventsInWaitList = *params.pnumEventsInWaitList; return UR_RESULT_SUCCESS; } @@ -94,3 +100,17 @@ TEST(Queue, ExtOneAPISubmitBarrierWithWaitList) { ASSERT_EQ(NumOfEventsWaitWithBarrierCalls, 1u); } + +TEST(Queue, BarrierWithBarrierDep) { + sycl::unittest::UrMock<> Mock; + mock::getCallbacks().set_before_callback( + "urEnqueueEventsWaitWithBarrierExt", + &redefined_urEnqueueEventsWaitWithBarrierExt); + sycl::queue Q1(sycl::property::queue::in_order{}); + sycl::queue Q2(sycl::property::queue::in_order{}); + Q1.submit([&](sycl::handler &cgh) { cgh.single_task([=]() {}); }); + sycl::event Barrier1 = Q1.ext_oneapi_submit_barrier(); + NumEventsInWaitList = 0; + Q2.ext_oneapi_submit_barrier({Barrier1}); + ASSERT_EQ(NumEventsInWaitList, 1u); +}