Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Fix barrier submission after command which bypasses the scheduler #15697

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sycl/source/detail/queue_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ event queue_impl::submitMemOpHelper(const std::shared_ptr<queue_impl> &Self,
MemOpFunc(MemOpArgs..., getUrEvents(ExpandedDepEvents), &UREvent,
EventImpl);
EventImpl->setHandle(UREvent);
EventImpl->setEnqueued();
}

if (isInOrder()) {
Expand Down
31 changes: 31 additions & 0 deletions sycl/unittests/scheduler/InOrderQueueDeps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <helpers/TestKernel.hpp>
#include <helpers/UrMock.hpp>
#include <sycl/usm.hpp>

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

// Test that barrier is not filtered out when waitlist contains an event
// produced by command which is bypassing the scheduler.
TEST_F(SchedulerTest, BypassSchedulerWithBarrier) {
sycl::unittest::UrMock<> Mock;
sycl::platform Plt = sycl::platform();

mock::getCallbacks().set_before_callback(
"urEnqueueEventsWaitWithBarrier", &redefinedEnqueueEventsWaitWithBarrier);
BarrierCalled = false;

context Ctx{Plt};
queue Q1{Ctx, default_selector_v, property::queue::in_order()};
queue Q2{Ctx, default_selector_v, property::queue::in_order()};
static constexpr size_t Size = 10;

int *X = malloc_host<int>(Size, Ctx);

// Submit a command which bypasses the scheduler.
auto FillEvent = Q2.memset(X, 0, sizeof(int) * Size);
// Submit a barrier which depends on that event.
ExpectedEvent = detail::getSyclObjImpl(FillEvent)->getHandle();
auto BarrierQ1 = Q1.ext_oneapi_submit_barrier({FillEvent});
Q1.wait();
Q2.wait();
// Verify that barrier is not filtered out.
EXPECT_EQ(BarrierCalled, true);

free(X, Ctx);
}

} // anonymous namespace
Loading