6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
+ #include < helpers/CommandSubmitWrappers.hpp>
9
10
#include < helpers/TestKernel.hpp>
10
11
#include < helpers/UrMock.hpp>
11
12
#include < sycl/sycl.hpp>
15
16
static unsigned NumOfEventsWaitWithBarrierCalls = 0 ;
16
17
static unsigned NumEventsInWaitList = 0 ;
17
18
19
+ class Queue : public testing ::TestWithParam<bool > {};
20
+
18
21
static ur_result_t redefined_urEnqueueEventsWaitWithBarrierExt (void *pParams) {
19
22
NumOfEventsWaitWithBarrierCalls++;
20
23
// Get the number of events in the wait list
@@ -25,92 +28,111 @@ static ur_result_t redefined_urEnqueueEventsWaitWithBarrierExt(void *pParams) {
25
28
return UR_RESULT_SUCCESS;
26
29
}
27
30
28
- TEST (Queue, HandlerBarrier) {
31
+ TEST_P (Queue, HandlerBarrier) {
29
32
sycl::unittest::UrMock<> Mock;
30
33
mock::getCallbacks ().set_before_callback (
31
34
" urEnqueueEventsWaitWithBarrierExt" ,
32
35
&redefined_urEnqueueEventsWaitWithBarrierExt);
33
36
NumOfEventsWaitWithBarrierCalls = 0 ;
37
+ bool UseShortcutFunction = GetParam ();
34
38
35
39
sycl::queue Q;
36
40
37
- Q.submit ([&](sycl::handler &cgh) { cgh.single_task <TestKernel>([=]() {}); });
38
- Q.submit ([&](sycl::handler &cgh) { cgh.single_task <TestKernel>([=]() {}); });
41
+ sycl::unittest::single_task_wrapper<TestKernel>(UseShortcutFunction, Q,
42
+ [=]() {});
43
+ sycl::unittest::single_task_wrapper<TestKernel>(UseShortcutFunction, Q,
44
+ [=]() {});
39
45
40
46
Q.submit ([&](sycl::handler &cgh) { cgh.ext_oneapi_barrier (); });
41
47
42
48
ASSERT_EQ (NumOfEventsWaitWithBarrierCalls, 1u );
43
49
}
44
50
45
- TEST (Queue, ExtOneAPISubmitBarrier) {
51
+ TEST_P (Queue, ExtOneAPISubmitBarrier) {
46
52
sycl::unittest::UrMock<> Mock;
47
53
mock::getCallbacks ().set_before_callback (
48
54
" urEnqueueEventsWaitWithBarrierExt" ,
49
55
&redefined_urEnqueueEventsWaitWithBarrierExt);
50
56
NumOfEventsWaitWithBarrierCalls = 0 ;
57
+ bool UseShortcutFunction = GetParam ();
51
58
52
59
sycl::queue Q;
53
60
54
- Q.submit ([&](sycl::handler &cgh) { cgh.single_task <TestKernel>([=]() {}); });
55
- Q.submit ([&](sycl::handler &cgh) { cgh.single_task <TestKernel>([=]() {}); });
61
+ sycl::unittest::single_task_wrapper<TestKernel>(UseShortcutFunction, Q,
62
+ [=]() {});
63
+ sycl::unittest::single_task_wrapper<TestKernel>(UseShortcutFunction, Q,
64
+ [=]() {});
56
65
57
66
Q.ext_oneapi_submit_barrier ();
58
67
59
68
ASSERT_EQ (NumOfEventsWaitWithBarrierCalls, 1u );
60
69
}
61
70
62
- TEST (Queue, HandlerBarrierWithWaitList) {
71
+ TEST_P (Queue, HandlerBarrierWithWaitList) {
63
72
sycl::unittest::UrMock<> Mock;
64
73
mock::getCallbacks ().set_before_callback (
65
74
" urEnqueueEventsWaitWithBarrierExt" ,
66
75
&redefined_urEnqueueEventsWaitWithBarrierExt);
67
76
NumOfEventsWaitWithBarrierCalls = 0 ;
77
+ bool UseShortcutFunction = GetParam ();
68
78
69
79
sycl::queue Q1;
70
80
sycl::queue Q2;
71
81
sycl::queue Q3;
72
82
73
- auto E1 = Q1. submit (
74
- [&](sycl::handler &cgh) { cgh. single_task <TestKernel>( [=]() {}); });
75
- auto E2 = Q2. submit (
76
- [&](sycl::handler &cgh) { cgh. single_task <TestKernel>( [=]() {}); });
83
+ auto E1 = sycl::unittest::single_task_wrapper<TestKernel>(UseShortcutFunction,
84
+ Q1, [=]() {});
85
+ auto E2 = sycl::unittest::single_task_wrapper<TestKernel>(UseShortcutFunction,
86
+ Q2, [=]() {});
77
87
78
88
Q3.submit ([&](sycl::handler &cgh) { cgh.ext_oneapi_barrier ({E1 , E2 }); });
79
89
80
90
ASSERT_EQ (NumOfEventsWaitWithBarrierCalls, 1u );
81
91
}
82
92
83
- TEST (Queue, ExtOneAPISubmitBarrierWithWaitList) {
93
+ TEST_P (Queue, ExtOneAPISubmitBarrierWithWaitList) {
84
94
sycl::unittest::UrMock<> Mock;
85
95
mock::getCallbacks ().set_before_callback (
86
96
" urEnqueueEventsWaitWithBarrierExt" ,
87
97
&redefined_urEnqueueEventsWaitWithBarrierExt);
88
98
NumOfEventsWaitWithBarrierCalls = 0 ;
99
+ bool UseShortcutFunction = GetParam ();
89
100
90
101
sycl::queue Q1;
91
102
sycl::queue Q2;
92
103
sycl::queue Q3;
93
104
94
- auto E1 = Q1. submit (
95
- [&](sycl::handler &cgh) { cgh. single_task <TestKernel>( [=]() {}); });
96
- auto E2 = Q2. submit (
97
- [&](sycl::handler &cgh) { cgh. single_task <TestKernel>( [=]() {}); });
105
+ auto E1 = sycl::unittest::single_task_wrapper<TestKernel>(UseShortcutFunction,
106
+ Q1, [=]() {});
107
+ auto E2 = sycl::unittest::single_task_wrapper<TestKernel>(UseShortcutFunction,
108
+ Q2, [=]() {});
98
109
99
110
Q3.ext_oneapi_submit_barrier ({E1 , E2 });
100
111
101
112
ASSERT_EQ (NumOfEventsWaitWithBarrierCalls, 1u );
102
113
}
103
114
104
- TEST (Queue, BarrierWithBarrierDep) {
115
+ TEST_P (Queue, BarrierWithBarrierDep) {
105
116
sycl::unittest::UrMock<> Mock;
106
117
mock::getCallbacks ().set_before_callback (
107
118
" urEnqueueEventsWaitWithBarrierExt" ,
108
119
&redefined_urEnqueueEventsWaitWithBarrierExt);
120
+ bool UseShortcutFunction = GetParam ();
121
+
109
122
sycl::queue Q1 (sycl::property::queue::in_order{});
110
123
sycl::queue Q2 (sycl::property::queue::in_order{});
111
- Q1.submit ([&](sycl::handler &cgh) { cgh.single_task <TestKernel>([=]() {}); });
124
+
125
+ sycl::unittest::single_task_wrapper<TestKernel>(UseShortcutFunction, Q1,
126
+ [=]() {});
127
+
112
128
sycl::event Barrier1 = Q1.ext_oneapi_submit_barrier ();
113
129
NumEventsInWaitList = 0 ;
114
130
Q2.ext_oneapi_submit_barrier ({Barrier1});
115
131
ASSERT_EQ (NumEventsInWaitList, 1u );
116
132
}
133
+
134
+ INSTANTIATE_TEST_SUITE_P (
135
+ QueueTestInstance, Queue,
136
+ testing::Values (
137
+ true ,
138
+ false )); /* Whether to use the shortcut command submission function */
0 commit comments