Skip to content

Commit 43b4b3a

Browse files
committed
Change the LaunchGroupedShortcutMoveKernelNoEvent unit test,
to reflect the new logic behind HostKernel construction.
1 parent bcf270f commit 43b4b3a

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

sycl/unittests/Extensions/FreeFunctionCommands/FreeFunctionCommandsEvents.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,46 @@ TEST_F(FreeFunctionCommandsEventsTests,
235235

236236
TestMoveFunctor::MoveCtorCalls = 0;
237237
TestMoveFunctor MoveOnly;
238+
std::mutex CvMutex;
239+
std::condition_variable Cv;
240+
bool ready = false;
241+
242+
// This kernel submission uses scheduler-bypass path, so the HostKernel
243+
// shouldn't be constructed.
244+
245+
sycl::khr::launch_grouped(Queue, sycl::range<1>{32}, sycl::range<1>{32},
246+
std::move(MoveOnly));
247+
248+
ASSERT_EQ(TestMoveFunctor::MoveCtorCalls, 0);
249+
ASSERT_EQ(counter_urEnqueueKernelLaunch, size_t{1});
250+
251+
// Another kernel submission is queued behind a host task,
252+
// to force the scheduler-based submission. In this case, the HostKernel
253+
// should be constructed.
254+
255+
Queue.submit([&](sycl::handler &CGH) {
256+
CGH.host_task([&] {
257+
std::unique_lock<std::mutex> lk(CvMutex);
258+
Cv.wait(lk, [&ready] { return ready; });
259+
});
260+
});
261+
238262
sycl::khr::launch_grouped(Queue, sycl::range<1>{32}, sycl::range<1>{32},
239263
std::move(MoveOnly));
264+
265+
{
266+
std::unique_lock<std::mutex> lk(CvMutex);
267+
ready = true;
268+
}
269+
Cv.notify_one();
270+
271+
Queue.wait();
272+
240273
// Move ctor for TestMoveFunctor is called during move construction of
241274
// HostKernel. Copy ctor is called by InstantiateKernelOnHost, can't delete
242275
// it.
243276
ASSERT_EQ(TestMoveFunctor::MoveCtorCalls, 1);
244-
245-
ASSERT_EQ(counter_urEnqueueKernelLaunch, size_t{1});
277+
ASSERT_EQ(counter_urEnqueueKernelLaunch, size_t{2});
246278
}
247279
#endif
248280

0 commit comments

Comments
 (0)