Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 6dff186

Browse files
[SYCL] Adjust multiple tests to queue::wait() changes (#338)
Adjust tests to expect a call to piQueueFinish rather than piEventsWait as part of queue::wait(), as well as release of events for queue USM operations or non-host commands with no implicit dependencies right after their submission. Additionally, blocked commands are no longer always waited for before enqueueing of their users. This introduces more cases where host tasks are used to "glue" events from different contexts, which makes it so that the order of some calls in the enqueue-arg-order-image test may vary from run to run.
1 parent 7e07c5a commit 6dff186

File tree

4 files changed

+59
-46
lines changed

4 files changed

+59
-46
lines changed

SYCL/Basic/queue/release.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ int main() {
1313
return 0;
1414
}
1515

16-
//CHECK: ---> piEnqueueKernelLaunch(
17-
//CHECK: ---> piQueueRelease(
18-
//CHECK: ---> piEventRelease(
19-
//CHECK: ---> piContextRelease(
20-
//CHECK: ---> piKernelRelease(
21-
//CHECK: ---> piProgramRelease(
22-
//CHECK: ---> piDeviceRelease(
16+
// CHECK: ---> piEnqueueKernelLaunch(
17+
// FIXME the order of these 2 varies between plugins due to a Level Zero
18+
// specific queue workaround.
19+
// CHECK-DAG: ---> piEventRelease(
20+
// CHECK-DAG: ---> piQueueRelease(
21+
// CHECK: ---> piContextRelease(
22+
// CHECK: ---> piKernelRelease(
23+
// CHECK: ---> piProgramRelease(
24+
// CHECK: ---> piDeviceRelease(

SYCL/Basic/subdevice_pi.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static bool check_separate(device dev, buffer<int, 1> buf,
6161
// CHECK-SEPARATE: ---> piQueueCreate
6262
// CHECK-SEPARATE: ---> piMemBufferCreate
6363
// CHECK-SEPARATE: ---> piEnqueueKernelLaunch
64-
// CHECK-SEPARATE: ---> piEventsWait
64+
// CHECK-SEPARATE: ---> piQueueFinish
6565

6666
log_pi("Test sub device 1");
6767
{
@@ -78,7 +78,7 @@ static bool check_separate(device dev, buffer<int, 1> buf,
7878
// CHECK-SEPARATE: ---> piEnqueueMemBufferWrite
7979
//
8080
// CHECK-SEPARATE: ---> piEnqueueKernelLaunch
81-
// CHECK-SEPARATE: ---> piEventsWait
81+
// CHECK-SEPARATE: ---> piQueueFinish
8282

8383
return true;
8484
}
@@ -113,7 +113,7 @@ static bool check_shared_context(device dev, buffer<int, 1> buf,
113113
// see --implicit-check-not above.
114114
//
115115
// CHECK-SHARED: ---> piEnqueueKernelLaunch
116-
// CHECK-SHARED: ---> piEventsWait
116+
// CHECK-SHARED: ---> piQueueFinish
117117

118118
log_pi("Test sub device 1");
119119
{
@@ -123,7 +123,7 @@ static bool check_shared_context(device dev, buffer<int, 1> buf,
123123
// CHECK-SHARED: Test sub device 1
124124
// CHECK-SHARED: ---> piQueueCreate
125125
// CHECK-SHARED: ---> piEnqueueKernelLaunch
126-
// CHECK-SHARED: ---> piEventsWait
126+
// CHECK-SHARED: ---> piQueueFinish
127127
// CHECK-SHARED: ---> piEnqueueMemBufferRead
128128

129129
return true;
@@ -162,7 +162,7 @@ static bool check_fused_context(device dev, buffer<int, 1> buf,
162162
// *and* the root device): see --implicit-check-not above.
163163
//
164164
// CHECK-FUSED: ---> piEnqueueKernelLaunch
165-
// CHECK-FUSED: ---> piEventsWait
165+
// CHECK-FUSED: ---> piQueueFinish
166166

167167
log_pi("Test sub device 0");
168168
{
@@ -172,7 +172,7 @@ static bool check_fused_context(device dev, buffer<int, 1> buf,
172172
// CHECK-FUSED: Test sub device 0
173173
// CHECK-FUSED: ---> piQueueCreate
174174
// CHECK-FUSED: ---> piEnqueueKernelLaunch
175-
// CHECK-FUSED: ---> piEventsWait
175+
// CHECK-FUSED: ---> piQueueFinish
176176

177177
log_pi("Test sub device 1");
178178
{
@@ -182,7 +182,7 @@ static bool check_fused_context(device dev, buffer<int, 1> buf,
182182
// CHECK-FUSED: Test sub device 1
183183
// CHECK-FUSED: ---> piQueueCreate
184184
// CHECK-FUSED: ---> piEnqueueKernelLaunch
185-
// CHECK-FUSED: ---> piEventsWait
185+
// CHECK-FUSED: ---> piQueueFinish
186186
// CHECK-FUSED: ---> piEnqueueMemBufferRead
187187

188188
return true;

SYCL/Plugin/enqueue-arg-order-image.cpp

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ void testcopyH2DImage() {
190190
writeAcc.write(int(Item[0]), Data);
191191
});
192192
});
193+
otherQueue.wait();
193194
std::cout << "about to destruct 1D" << std::endl;
194195
} // ~image 1D
195196

@@ -224,6 +225,7 @@ void testcopyH2DImage() {
224225
writeAcc.write(sycl::int2{Item[0], Item[1]}, Data);
225226
});
226227
});
228+
otherQueue.wait();
227229
std::cout << "about to destruct 2D" << std::endl;
228230
} // ~image 2D
229231

@@ -260,6 +262,7 @@ void testcopyH2DImage() {
260262
writeAcc.write(sycl::int4{Item[0], Item[1], Item[2], 0}, Data);
261263
});
262264
});
265+
otherQueue.wait();
263266
std::cout << "about to destruct 3D" << std::endl;
264267
} // ~image 3D
265268

@@ -279,6 +282,7 @@ int main() {
279282

280283
// ----------- IMAGES
281284

285+
// clang-format off
282286
//CHECK: start copyD2H-Image
283287
//CHECK: -- 1D
284288
//CHECK: ---> piMemImageCreate(
@@ -319,14 +323,16 @@ int main() {
319323
//CHECK: image_desc w/h/d : 16 / 1 / 1 -- arrSz/row/slice : 0 / 0 / 0 -- num_mip_lvls/num_smpls/image_type : 0 / 0 / 4340
320324
//CHECK: ---> piEnqueueMemImageRead(
321325
//CHECK: pi_image_region width/height/depth : 16/1/1
322-
//CHECK: ---> piEnqueueMemImageWrite(
323-
//CHECK: pi_image_region width/height/depth : 16/1/1
324-
//CHECK: ---> piMemImageCreate(
325-
//CHECK: image_desc w/h/d : 16 / 1 / 1 -- arrSz/row/slice : 0 / 0 / 0 -- num_mip_lvls/num_smpls/image_type : 0 / 0 / 4340
326-
//CHECK: ---> piEnqueueMemImageRead(
327-
//CHECK: pi_image_region width/height/depth : 16/1/1
328-
//CHECK: ---> piEnqueueMemImageWrite(
329-
//CHECK: pi_image_region width/height/depth : 16/1/1
326+
// The order of the following calls may vary since some of them are made by a
327+
// host task (in a separate thread).
328+
//CHECK-DAG: ---> piMemImageCreate(
329+
//CHECK-DAG: image_desc w/h/d : 16 / 1 / 1 -- arrSz/row/slice : 0 / 0 / 0 -- num_mip_lvls/num_smpls/image_type : 0 / 0 / 4340
330+
//CHECK-DAG: ---> piEnqueueMemImageRead(
331+
//CHECK-DAG: pi_image_region width/height/depth : 16/1/1
332+
//CHECK-DAG: ---> piEnqueueMemImageWrite(
333+
//CHECK-DAG: pi_image_region width/height/depth : 16/1/1
334+
//CHECK-DAG: ---> piEnqueueMemImageWrite(
335+
//CHECK-DAG: pi_image_region width/height/depth : 16/1/1
330336
//CHECK: about to destruct 1D
331337
//CHECK: ---> piEnqueueMemImageRead(
332338
//CHECK: pi_image_region width/height/depth : 16/1/1
@@ -339,16 +345,18 @@ int main() {
339345
//CHECK: image_desc w/h/d : 16 / 5 / 1 -- arrSz/row/slice : 0 / 0 / 0 -- num_mip_lvls/num_smpls/image_type : 0 / 0 / 4337
340346
//CHECK: ---> piEnqueueMemImageRead(
341347
//CHECK: pi_image_region width/height/depth : 16/5/1
342-
//CHECK: ---> piEnqueueMemImageWrite(
343-
//CHECK: pi_image_region width/height/depth : 16/5/1
344-
// CHECK-NEXT: <unknown> : 256
345-
//CHECK: ---> piMemImageCreate(
346-
//CHECK: image_desc w/h/d : 16 / 5 / 1 -- arrSz/row/slice : 0 / 0 / 0 -- num_mip_lvls/num_smpls/image_type : 0 / 0 / 4337
347-
//CHECK: ---> piEnqueueMemImageRead(
348-
//CHECK: pi_image_region width/height/depth : 16/5/1
349-
//CHECK: ---> piEnqueueMemImageWrite(
350-
//CHECK: pi_image_region width/height/depth : 16/5/1
351-
// CHECK-NEXT: <unknown> : 256
348+
// The order of the following calls may vary since some of them are made by a
349+
// host task (in a separate thread).
350+
//CHECK-DAG: ---> piMemImageCreate(
351+
//CHECK-DAG: image_desc w/h/d : 16 / 5 / 1 -- arrSz/row/slice : 0 / 0 / 0 -- num_mip_lvls/num_smpls/image_type : 0 / 0 / 4337
352+
//CHECK-DAG: ---> piEnqueueMemImageRead(
353+
//CHECK-DAG: pi_image_region width/height/depth : 16/5/1
354+
//CHECK-DAG: ---> piEnqueueMemImageWrite(
355+
//CHECK-DAG: pi_image_region width/height/depth : 16/5/1
356+
//CHECK-DAG: <unknown> : 256
357+
//CHECK-DAG: ---> piEnqueueMemImageWrite(
358+
//CHECK-DAG: pi_image_region width/height/depth : 16/5/1
359+
//CHECK-DAG: <unknown> : 256
352360
//CHECK: about to destruct 2D
353361
//CHECK: ---> piEnqueueMemImageRead(
354362
//CHECK: pi_image_region width/height/depth : 16/5/1
@@ -361,21 +369,24 @@ int main() {
361369
//CHECK: image_desc w/h/d : 16 / 5 / 3 -- arrSz/row/slice : 0 / 0 / 0 -- num_mip_lvls/num_smpls/image_type : 0 / 0 / 4338
362370
//CHECK: ---> piEnqueueMemImageRead(
363371
//CHECK: pi_image_region width/height/depth : 16/5/3
364-
//CHECK: ---> piEnqueueMemImageWrite(
365-
//CHECK: pi_image_region width/height/depth : 16/5/3
366-
// CHECK-NEXT: <unknown> : 256
367-
// CHECK-NEXT: <unknown> : 1280
368-
//CHECK: ---> piMemImageCreate(
369-
//CHECK: image_desc w/h/d : 16 / 5 / 3 -- arrSz/row/slice : 0 / 0 / 0 -- num_mip_lvls/num_smpls/image_type : 0 / 0 / 4338
370-
//CHECK: ---> piEnqueueMemImageRead(
371-
//CHECK: pi_image_region width/height/depth : 16/5/3
372-
//CHECK: ---> piEnqueueMemImageWrite(
373-
//CHECK: pi_image_region width/height/depth : 16/5/3
374-
// CHECK-NEXT: <unknown> : 256
375-
// CHECK-NEXT: <unknown> : 1280
372+
// The order of the following calls may vary since some of them are made by a
373+
// host task (in a separate thread).
374+
//CHECK-DAG: ---> piMemImageCreate(
375+
//CHECK-DAG: image_desc w/h/d : 16 / 5 / 3 -- arrSz/row/slice : 0 / 0 / 0 -- num_mip_lvls/num_smpls/image_type : 0 / 0 / 4338
376+
//CHECK-DAG: ---> piEnqueueMemImageRead(
377+
//CHECK-DAG: pi_image_region width/height/depth : 16/5/3
378+
//CHECK-DAG: ---> piEnqueueMemImageWrite(
379+
//CHECK-DAG: pi_image_region width/height/depth : 16/5/3
380+
//CHECK-DAG: <unknown> : 256
381+
//CHECK-DAG: <unknown> : 1280
382+
//CHECK-DAG: ---> piEnqueueMemImageWrite(
383+
//CHECK-DAG: pi_image_region width/height/depth : 16/5/3
384+
//CHECK-DAG: <unknown> : 256
385+
//CHECK-DAG: <unknown> : 1280
376386
//CHECK: about to destruct 3D
377387
//CHECK: ---> piEnqueueMemImageRead(
378388
//CHECK: pi_image_region width/height/depth : 16/5/3
379389
// CHECK-NEXT: <unknown> : 256
380390
// CHECK-NEXT: <unknown> : 1280
381391
//CHECK: end copyH2D-image
392+
// clang-format on

SYCL/Tracing/pi_tracing_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
int main() {
4747
cl::sycl::queue Queue;
4848
cl::sycl::buffer<int, 1> Buf(10);
49-
Queue.submit([&](cl::sycl::handler &cgh) {
49+
cl::sycl::event E = Queue.submit([&](cl::sycl::handler &cgh) {
5050
auto Acc = Buf.template get_access<cl::sycl::access::mode::read_write>(cgh);
5151

5252
cgh.parallel_for<class CheckTraces>(
5353
10, [=](cl::sycl::id<1> ID) { Acc[ID] = 5; });
5454
});
55-
Queue.wait();
55+
E.wait();
5656
return 0;
5757
}

0 commit comments

Comments
 (0)