Skip to content

Commit 067e8e7

Browse files
committed
Address review comments
1 parent 6586e3b commit 067e8e7

File tree

2 files changed

+44
-26
lines changed

2 files changed

+44
-26
lines changed
Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
1-
//==-- CommandSubmitWrappers.hpp --- -----==//
1+
//==-- CommandSubmitWrappers.hpp ----- Wrappers for command submission -----==//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#pragma once
10+
911
#include <sycl/event.hpp>
1012
#include <sycl/handler.hpp>
1113

12-
using namespace sycl;
14+
namespace sycl {
15+
16+
inline namespace _V1 {
17+
namespace unittest {
18+
19+
// Wrappers introduced in this file allow for running unit tests
20+
// with two command submission types: Using a handler and handler-less
21+
// shortcut functions.
22+
// This increases the test coverage, especially for the cases,
23+
// where the command submission path implementation differes significantly
24+
// between those two models.
1325

1426
template <typename KernelName, typename KernelType>
15-
event single_task_wrapper(bool ShortcutSubmitFunction, queue &Q,
27+
event single_task_wrapper(bool UseShortcutFunction, queue &Q,
1628
const KernelType &KernelFunc) {
17-
if (ShortcutSubmitFunction) {
29+
if (UseShortcutFunction) {
1830
return Q.single_task<KernelName>(KernelFunc);
1931
} else {
2032
return Q.submit(
@@ -23,14 +35,17 @@ event single_task_wrapper(bool ShortcutSubmitFunction, queue &Q,
2335
}
2436

2537
template <typename KernelName, typename KernelType>
26-
event single_task_wrapper(bool ShortcutSubmitFunction, queue &Q, event DepEvent,
38+
event single_task_wrapper(bool UseShortcutFunction, queue &Q, event &DepEvent,
2739
const KernelType &KernelFunc) {
28-
if (ShortcutSubmitFunction) {
40+
if (UseShortcutFunction) {
2941
return Q.single_task<KernelName>(DepEvent, KernelFunc);
3042
} else {
3143
return Q.submit([&](handler &cgh) {
3244
cgh.depends_on(DepEvent);
3345
cgh.single_task<KernelName>(KernelFunc);
3446
});
3547
}
36-
}
48+
}
49+
} // namespace unittest
50+
} // namespace _V1
51+
} // namespace sycl

sycl/unittests/scheduler/InOrderQueueDeps.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ TEST_P(SchedulerTest, InOrderQueueIsolatedDeps) {
101101
// are handled properly during filtering.
102102
sycl::unittest::UrMock<> Mock;
103103
sycl::platform Plt = sycl::platform();
104-
bool ShortcutSubmitFunction = GetParam();
104+
bool UseShortcutFunction = GetParam();
105105
mock::getCallbacks().set_before_callback(
106106
"urEnqueueEventsWaitWithBarrierExt",
107107
&redefinedEnqueueEventsWaitWithBarrierExt);
@@ -110,17 +110,17 @@ TEST_P(SchedulerTest, InOrderQueueIsolatedDeps) {
110110
context Ctx{Plt.get_devices()[0]};
111111
queue Q1{Ctx, default_selector_v, property::queue::in_order()};
112112
{
113-
event E =
114-
single_task_wrapper<TestKernel>(ShortcutSubmitFunction, Q1, []() {});
113+
event E = sycl::unittest::single_task_wrapper<TestKernel>(
114+
UseShortcutFunction, Q1, []() {});
115115
Q1.ext_oneapi_submit_barrier({E});
116116
EXPECT_FALSE(BarrierCalled);
117117
}
118118
queue Q2{Ctx, default_selector_v, property::queue::in_order()};
119119
{
120-
event E1 =
121-
single_task_wrapper<TestKernel>(ShortcutSubmitFunction, Q1, []() {});
122-
event E2 =
123-
single_task_wrapper<TestKernel>(ShortcutSubmitFunction, Q2, []() {});
120+
event E1 = sycl::unittest::single_task_wrapper<TestKernel>(
121+
UseShortcutFunction, Q1, []() {});
122+
event E2 = sycl::unittest::single_task_wrapper<TestKernel>(
123+
UseShortcutFunction, Q2, []() {});
124124
ExpectedEvent = detail::getSyclObjImpl(E2)->getHandle();
125125
Q1.ext_oneapi_submit_barrier({E1, E2});
126126
EXPECT_TRUE(BarrierCalled);
@@ -138,7 +138,7 @@ inline ur_result_t customEnqueueKernelLaunch(void *pParams) {
138138
TEST_P(SchedulerTest, TwoInOrderQueuesOnSameContext) {
139139
KernelEventListSize.clear();
140140
sycl::unittest::UrMock<> Mock;
141-
bool ShortcutSubmitFunction = GetParam();
141+
bool UseShortcutFunction = GetParam();
142142
mock::getCallbacks().set_before_callback("urEnqueueKernelLaunch",
143143
&customEnqueueKernelLaunch);
144144

@@ -149,10 +149,10 @@ TEST_P(SchedulerTest, TwoInOrderQueuesOnSameContext) {
149149
queue InOrderQueueSecond{Ctx, default_selector_v,
150150
property::queue::in_order()};
151151

152-
event EvFirst = single_task_wrapper<TestKernel>(ShortcutSubmitFunction,
153-
InOrderQueueFirst, []() {});
154-
std::ignore = single_task_wrapper<TestKernel>(
155-
ShortcutSubmitFunction, InOrderQueueSecond, EvFirst, []() {});
152+
event EvFirst = sycl::unittest::single_task_wrapper<TestKernel>(
153+
UseShortcutFunction, InOrderQueueFirst, []() {});
154+
std::ignore = sycl::unittest::single_task_wrapper<TestKernel>(
155+
UseShortcutFunction, InOrderQueueSecond, EvFirst, []() {});
156156

157157
InOrderQueueFirst.wait();
158158
InOrderQueueSecond.wait();
@@ -165,7 +165,7 @@ TEST_P(SchedulerTest, TwoInOrderQueuesOnSameContext) {
165165
TEST_P(SchedulerTest, InOrderQueueNoSchedulerPath) {
166166
KernelEventListSize.clear();
167167
sycl::unittest::UrMock<> Mock;
168-
bool ShortcutSubmitFunction = GetParam();
168+
bool UseShortcutFunction = GetParam();
169169
mock::getCallbacks().set_before_callback("urEnqueueKernelLaunch",
170170
&customEnqueueKernelLaunch);
171171

@@ -174,10 +174,10 @@ TEST_P(SchedulerTest, InOrderQueueNoSchedulerPath) {
174174
context Ctx{Plt};
175175
queue InOrderQueue{Ctx, default_selector_v, property::queue::in_order()};
176176

177-
event EvFirst = single_task_wrapper<TestKernel>(ShortcutSubmitFunction,
178-
InOrderQueue, []() {});
179-
std::ignore = single_task_wrapper<TestKernel>(ShortcutSubmitFunction,
180-
InOrderQueue, EvFirst, []() {});
177+
event EvFirst = sycl::unittest::single_task_wrapper<TestKernel>(
178+
UseShortcutFunction, InOrderQueue, []() {});
179+
std::ignore = sycl::unittest::single_task_wrapper<TestKernel>(
180+
UseShortcutFunction, InOrderQueue, EvFirst, []() {});
181181

182182
InOrderQueue.wait();
183183

@@ -190,5 +190,8 @@ TEST_P(SchedulerTest, InOrderQueueNoSchedulerPath) {
190190

191191
} // anonymous namespace
192192

193-
INSTANTIATE_TEST_SUITE_P(SchedulerTestInstance, SchedulerTest,
194-
testing::Values(true, false));
193+
INSTANTIATE_TEST_SUITE_P(
194+
SchedulerTestInstance, SchedulerTest,
195+
testing::Values(
196+
true,
197+
false)); /* Whether to use the shortcut command submission function */

0 commit comments

Comments
 (0)