7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " CL/sycl/detail/pi.hpp"
10
- #include < detail/plugin.hpp>
11
10
#include < atomic>
11
+ #include < detail/plugin.hpp>
12
12
#include < gtest/gtest.h>
13
13
#include < thread>
14
14
@@ -25,8 +25,7 @@ class EventTest : public testing::TestWithParam<detail::plugin> {
25
25
26
26
EventTest ()
27
27
: _context{nullptr }, _queue{nullptr }, _device{nullptr },
28
- _result{PI_INVALID_VALUE} {
29
- }
28
+ _result{PI_INVALID_VALUE} {}
30
29
31
30
~EventTest () override = default ;
32
31
@@ -65,21 +64,18 @@ class EventTest : public testing::TestWithParam<detail::plugin> {
65
64
66
65
detail::plugin plugin = GetParam ();
67
66
67
+ ASSERT_EQ ((plugin.call_nocheck <detail::PiApiKind::piQueueRelease>(_queue)),
68
+ PI_SUCCESS);
69
+
68
70
ASSERT_EQ (
69
- (plugin.call_nocheck <detail::PiApiKind::piQueueRelease>(_queue )),
71
+ (plugin.call_nocheck <detail::PiApiKind::piContextRelease>(_context )),
70
72
PI_SUCCESS);
71
-
72
- ASSERT_EQ ((plugin.call_nocheck <detail::PiApiKind::piContextRelease>(
73
- _context)),
74
- PI_SUCCESS);
75
73
}
76
74
};
77
75
78
76
static std::vector<detail::plugin> Plugins = detail::pi::initialize();
79
77
80
- INSTANTIATE_TEST_CASE_P (EventTestImpl,
81
- EventTest,
82
- testing::ValuesIn (Plugins),);
78
+ INSTANTIATE_TEST_CASE_P (EventTestImpl, EventTest, testing::ValuesIn(Plugins), );
83
79
84
80
// TODO: need more negative tests to show errors being reported when expected
85
81
// (invalid arguments etc).
@@ -89,9 +85,9 @@ TEST_P(EventTest, PICreateEvent) {
89
85
90
86
detail::plugin plugin = GetParam ();
91
87
92
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piEventCreate>(_context,
93
- &foo)),
94
- PI_SUCCESS);
88
+ ASSERT_EQ (
89
+ (plugin. call_nocheck <detail::PiApiKind::piEventCreate>(_context, &foo)),
90
+ PI_SUCCESS);
95
91
ASSERT_NE (foo, nullptr );
96
92
97
93
EXPECT_EQ ((plugin.call_nocheck <detail::PiApiKind::piEventRelease>(foo)),
@@ -131,8 +127,8 @@ TEST_P(EventTest, piEventSetCallback) {
131
127
// gate event lets us register callbacks before letting the enqueued work be
132
128
// executed.
133
129
pi_event gateEvent;
134
- ASSERT_EQ ((plugin.call_nocheck <detail::PiApiKind::piEventCreate>(
135
- _context, &gateEvent)),
130
+ ASSERT_EQ ((plugin.call_nocheck <detail::PiApiKind::piEventCreate>(_context,
131
+ &gateEvent)),
136
132
PI_SUCCESS);
137
133
138
134
constexpr const size_t dataCount = 1000u ;
@@ -146,11 +142,10 @@ TEST_P(EventTest, piEventSetCallback) {
146
142
PI_SUCCESS);
147
143
148
144
pi_event syncEvent;
149
- ASSERT_EQ (
150
- (plugin.call_nocheck <detail::PiApiKind::piEnqueueMemBufferWrite>(
151
- _queue, memObj, false , 0 , size_in_bytes, data.data (), 1 , &gateEvent,
152
- &syncEvent)),
153
- PI_SUCCESS);
145
+ ASSERT_EQ ((plugin.call_nocheck <detail::PiApiKind::piEnqueueMemBufferWrite>(
146
+ _queue, memObj, false , 0 , size_in_bytes, data.data (), 1 ,
147
+ &gateEvent, &syncEvent)),
148
+ PI_SUCCESS);
154
149
155
150
for (size_t i = 0 ; i < event_type_count; i++) {
156
151
user_data[i].event_type = event_callback_types[i];
@@ -174,22 +169,20 @@ TEST_P(EventTest, piEventSetCallback) {
174
169
EXPECT_TRUE (triggered_flag[k]);
175
170
}
176
171
177
- ASSERT_EQ (
178
- (plugin.call_nocheck <detail::PiApiKind::piEventRelease>(gateEvent)),
179
- PI_SUCCESS);
180
- ASSERT_EQ (
181
- (plugin.call_nocheck <detail::PiApiKind::piEventRelease>(syncEvent)),
182
- PI_SUCCESS);
172
+ ASSERT_EQ ((plugin.call_nocheck <detail::PiApiKind::piEventRelease>(gateEvent)),
173
+ PI_SUCCESS);
174
+ ASSERT_EQ ((plugin.call_nocheck <detail::PiApiKind::piEventRelease>(syncEvent)),
175
+ PI_SUCCESS);
183
176
}
184
177
185
178
TEST_P (EventTest, piEventGetInfo) {
186
179
187
180
detail::plugin plugin = GetParam ();
188
181
189
182
pi_event foo;
190
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piEventCreate>(_context,
191
- &foo)),
192
- PI_SUCCESS);
183
+ ASSERT_EQ (
184
+ (plugin. call_nocheck <detail::PiApiKind::piEventCreate>(_context, &foo)),
185
+ PI_SUCCESS);
193
186
ASSERT_NE (foo, nullptr );
194
187
195
188
pi_uint64 paramValue = 0 ;
@@ -211,9 +204,9 @@ TEST_P(EventTest, piEventSetStatus) {
211
204
detail::plugin plugin = GetParam ();
212
205
213
206
pi_event foo;
214
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piEventCreate>(_context,
215
- &foo)),
216
- PI_SUCCESS);
207
+ ASSERT_EQ (
208
+ (plugin. call_nocheck <detail::PiApiKind::piEventCreate>(_context, &foo)),
209
+ PI_SUCCESS);
217
210
ASSERT_NE (foo, nullptr );
218
211
219
212
pi_event_status paramValue = PI_EVENT_QUEUED;
@@ -243,9 +236,9 @@ TEST_P(EventTest, WaitForManualEventOnOtherThread) {
243
236
detail::plugin plugin = GetParam ();
244
237
245
238
pi_event foo;
246
- ASSERT_EQ ((plugin. call_nocheck <detail::PiApiKind::piEventCreate>(_context,
247
- &foo)),
248
- PI_SUCCESS);
239
+ ASSERT_EQ (
240
+ (plugin. call_nocheck <detail::PiApiKind::piEventCreate>(_context, &foo)),
241
+ PI_SUCCESS);
249
242
ASSERT_NE (foo, nullptr );
250
243
251
244
pi_event_status paramValue = {};
@@ -260,9 +253,8 @@ TEST_P(EventTest, WaitForManualEventOnOtherThread) {
260
253
261
254
auto tWaiter = std::thread ([&]() {
262
255
started = true ;
263
- ASSERT_EQ (
264
- (plugin.call_nocheck <detail::PiApiKind::piEventsWait>(1 , &foo)),
265
- PI_SUCCESS);
256
+ ASSERT_EQ ((plugin.call_nocheck <detail::PiApiKind::piEventsWait>(1 , &foo)),
257
+ PI_SUCCESS);
266
258
});
267
259
268
260
while (!started) {
@@ -302,10 +294,9 @@ TEST_P(EventTest, piEnqueueEventsWait) {
302
294
303
295
pi_event events[4 ] = {nullptr , nullptr , nullptr , nullptr };
304
296
305
- ASSERT_EQ (
306
- (plugin.call_nocheck <detail::PiApiKind::piEnqueueMemBufferWrite>(
307
- _queue, memObj, true , 0 , bytes, data, 0 , nullptr , &events[0 ])),
308
- PI_SUCCESS);
297
+ ASSERT_EQ ((plugin.call_nocheck <detail::PiApiKind::piEnqueueMemBufferWrite>(
298
+ _queue, memObj, true , 0 , bytes, data, 0 , nullptr , &events[0 ])),
299
+ PI_SUCCESS);
309
300
ASSERT_NE (events[0 ], nullptr );
310
301
311
302
ASSERT_EQ (
@@ -314,8 +305,8 @@ TEST_P(EventTest, piEnqueueEventsWait) {
314
305
PI_SUCCESS);
315
306
ASSERT_NE (events[1 ], nullptr );
316
307
317
- ASSERT_EQ ((plugin.call_nocheck <detail::PiApiKind::piEventCreate>(
318
- _context, &events[2 ])),
308
+ ASSERT_EQ ((plugin.call_nocheck <detail::PiApiKind::piEventCreate>(_context,
309
+ &events[2 ])),
319
310
PI_SUCCESS);
320
311
ASSERT_NE (events[2 ], nullptr );
321
312
0 commit comments