Skip to content

Added some tests to involve capsule #564

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 1 commit into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions dpctl/tests/test_sycl_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ def test_context_multi_device():
shmem_1 = dpmem.MemoryUSMShared(256, queue=q1)
shmem_2 = dpmem.MemoryUSMDevice(256, queue=q2)
shmem_2.copy_from_device(shmem_1)
# create context for single sub-device
ctx1 = dpctl.SyclContext(d1)
q1 = dpctl.SyclQueue(ctx1, d1)
shmem_1 = dpmem.MemoryUSMShared(256, queue=q1)
cap = ctx1._get_capsule()
del ctx1
ctx2 = dpctl.SyclContext(cap)
q2 = dpctl.SyclQueue(ctx2, d1)
shmem_2 = dpmem.MemoryUSMDevice(256, queue=q2)
shmem_2.copy_from_device(shmem_1)


def test_hashing_of_context():
Expand All @@ -169,3 +179,8 @@ def test_hashing_of_context():
"""
ctx_dict = {dpctl.SyclContext(): "default_context"}
assert ctx_dict


def test_context_repr():
ctx = dpctl.SyclContext()
assert type(ctx.__repr__()) is str
7 changes: 7 additions & 0 deletions dpctl/tests/test_sycl_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,10 @@ def test_sycl_timer():
timer(queue=q_no_profiling)
with pytest.raises(TypeError):
timer(queue=None)


def test_event_capsule():
ev = dpctl.SyclEvent()
cap = ev._get_capsule()
ev2 = dpctl.SyclEvent(cap)
assert type(ev2) == type(ev)
22 changes: 22 additions & 0 deletions dpctl/tests/test_sycl_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,25 @@ def test_queue_submit_barrier(valid_filter):
ev3.wait()
ev1.wait()
ev2.wait()


def test_queue__repr__():
q1 = dpctl.SyclQueue()
r1 = q1.__repr__()
q2 = dpctl.SyclQueue(property="in_order")
r2 = q2.__repr__()
q3 = dpctl.SyclQueue(property="enable_profiling")
r3 = q3.__repr__()
q4 = dpctl.SyclQueue(property=["in_order", "enable_profiling"])
r4 = q4.__repr__()
assert type(r1) is str
assert type(r2) is str
assert type(r3) is str
assert type(r4) is str


def test_queue_capsule():
q = dpctl.SyclQueue()
cap = q._get_capsule()
q2 = dpctl.SyclQueue(cap)
assert q == q2