Skip to content

Commit 22694b5

Browse files
Changes to test_async_submit
Few changes to reduce sporadic test failures. 1. Choose initial global work-size to be a multiple of max_work_group_size to ensure that enough work is being generated in the test 2. Retry submission if asyncronicity is not yet detected and double the work if that does not help
1 parent de1b1a4 commit 22694b5

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

dpctl/tests/test_sycl_kernel_submit.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,21 @@ def test_async_submit():
167167
assert isinstance(kern2Kernel, dpctl_prog.SyclKernel)
168168

169169
status_complete = dpctl.event_status_type.complete
170+
170171
# choose input size based on capability of the device
171172
f = q.sycl_device.max_work_group_size
172173
n = f * 1024
173-
X = dpt.empty((3, n), dtype="u4", usm_type="device", sycl_queue=q)
174+
n_alloc = 4 * n
175+
176+
X = dpt.empty((3, n_alloc), dtype="u4", usm_type="device", sycl_queue=q)
174177
first_row = dpctl_mem.as_usm_memory(X[0])
175178
second_row = dpctl_mem.as_usm_memory(X[1])
176179
third_row = dpctl_mem.as_usm_memory(X[2])
177180

178181
p1, p2 = 17, 27
179182

180183
async_detected = False
181-
for _ in range(5):
184+
for attempt in range(5):
182185
e1 = q.submit(
183186
kern1Kernel,
184187
[
@@ -211,19 +214,22 @@ def test_async_submit():
211214
e3_st = e3.execution_status
212215
e2_st = e2.execution_status
213216
e1_st = e1.execution_status
214-
if not all(
215-
[
216-
e == status_complete
217-
for e in (
218-
e1_st,
219-
e2_st,
220-
e3_st,
221-
)
222-
]
223-
):
217+
are_complete = [
218+
e == status_complete
219+
for e in (
220+
e1_st,
221+
e2_st,
222+
e3_st,
223+
)
224+
]
225+
e3.wait()
226+
if not all(are_complete):
224227
async_detected = True
225-
e3.wait()
226228
break
229+
else:
230+
n = n * (1 if attempt % 2 == 0 else 2)
231+
if n > n_alloc:
232+
break
227233

228234
assert async_detected, "No evidence of async submission detected, unlucky?"
229235
Xnp = dpt.asnumpy(X)
@@ -233,4 +239,4 @@ def test_async_submit():
233239
Xref[1, i] = (i * i * i) % p2
234240
Xref[2, i] = min(Xref[0, i], Xref[1, i])
235241

236-
assert np.array_equal(Xnp, Xref)
242+
assert np.array_equal(Xnp[:, :n], Xref[:, :n])

0 commit comments

Comments
 (0)