Skip to content

Test async changes #1298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions dpctl/tests/test_sycl_kernel_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,21 @@ def test_async_submit():
assert isinstance(kern2Kernel, dpctl_prog.SyclKernel)

status_complete = dpctl.event_status_type.complete
n = 256 * 1024
X = dpt.empty((3, n), dtype="u4", usm_type="device", sycl_queue=q)

# choose input size based on capability of the device
f = q.sycl_device.max_work_group_size
n = f * 1024
n_alloc = 4 * n

X = dpt.empty((3, n_alloc), dtype="u4", usm_type="device", sycl_queue=q)
first_row = dpctl_mem.as_usm_memory(X[0])
second_row = dpctl_mem.as_usm_memory(X[1])
third_row = dpctl_mem.as_usm_memory(X[2])

p1, p2 = 17, 27

async_detected = False
for _ in range(5):
for attempt in range(5):
e1 = q.submit(
kern1Kernel,
[
Expand Down Expand Up @@ -209,19 +214,22 @@ def test_async_submit():
e3_st = e3.execution_status
e2_st = e2.execution_status
e1_st = e1.execution_status
if not all(
[
e == status_complete
for e in (
e1_st,
e2_st,
e3_st,
)
]
):
are_complete = [
e == status_complete
for e in (
e1_st,
e2_st,
e3_st,
)
]
e3.wait()
if not all(are_complete):
async_detected = True
e3.wait()
break
else:
n = n * (1 if attempt % 2 == 0 else 2)
if n > n_alloc:
break

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

assert np.array_equal(Xnp, Xref)
assert np.array_equal(Xnp[:, :n], Xref[:, :n])