Skip to content

Commit 9faf0e0

Browse files
authored
[SYCL] Fix barrier submission after command which bypasses the scheduler (#15697)
Currently we mistakenly don't mark commands like memcpy, copy, fill etc. as enqueued, this happens because they are enqueued differently bypassing the scheduler. Problem is that if barrier is submitted depending on such event then it is just omitted. So, fix the problem by marking such commands as enqueued.
1 parent 7082efa commit 9faf0e0

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

sycl/source/detail/queue_impl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ event queue_impl::submitMemOpHelper(const std::shared_ptr<queue_impl> &Self,
455455
MemOpFunc(MemOpArgs..., getUrEvents(ExpandedDepEvents), &UREvent,
456456
EventImpl);
457457
EventImpl->setHandle(UREvent);
458+
EventImpl->setEnqueued();
458459
}
459460

460461
if (isInOrder()) {

sycl/unittests/scheduler/InOrderQueueDeps.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <helpers/TestKernel.hpp>
1313
#include <helpers/UrMock.hpp>
14+
#include <sycl/usm.hpp>
1415

1516
#include <iostream>
1617
#include <memory>
@@ -189,4 +190,34 @@ TEST_F(SchedulerTest, InOrderQueueNoSchedulerPath) {
189190
EXPECT_EQ(KernelEventListSize[1] /*EventsCount*/, 0u);
190191
}
191192

193+
// Test that barrier is not filtered out when waitlist contains an event
194+
// produced by command which is bypassing the scheduler.
195+
TEST_F(SchedulerTest, BypassSchedulerWithBarrier) {
196+
sycl::unittest::UrMock<> Mock;
197+
sycl::platform Plt = sycl::platform();
198+
199+
mock::getCallbacks().set_before_callback(
200+
"urEnqueueEventsWaitWithBarrier", &redefinedEnqueueEventsWaitWithBarrier);
201+
BarrierCalled = false;
202+
203+
context Ctx{Plt};
204+
queue Q1{Ctx, default_selector_v, property::queue::in_order()};
205+
queue Q2{Ctx, default_selector_v, property::queue::in_order()};
206+
static constexpr size_t Size = 10;
207+
208+
int *X = malloc_host<int>(Size, Ctx);
209+
210+
// Submit a command which bypasses the scheduler.
211+
auto FillEvent = Q2.memset(X, 0, sizeof(int) * Size);
212+
// Submit a barrier which depends on that event.
213+
ExpectedEvent = detail::getSyclObjImpl(FillEvent)->getHandle();
214+
auto BarrierQ1 = Q1.ext_oneapi_submit_barrier({FillEvent});
215+
Q1.wait();
216+
Q2.wait();
217+
// Verify that barrier is not filtered out.
218+
EXPECT_EQ(BarrierCalled, true);
219+
220+
free(X, Ctx);
221+
}
222+
192223
} // anonymous namespace

0 commit comments

Comments
 (0)