diff --git a/dpctl/tests/test_sycl_context.py b/dpctl/tests/test_sycl_context.py index 756c92cbd7..545c8f2907 100644 --- a/dpctl/tests/test_sycl_context.py +++ b/dpctl/tests/test_sycl_context.py @@ -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(): @@ -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 diff --git a/dpctl/tests/test_sycl_event.py b/dpctl/tests/test_sycl_event.py index 4515895d8c..60d477cacb 100644 --- a/dpctl/tests/test_sycl_event.py +++ b/dpctl/tests/test_sycl_event.py @@ -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) diff --git a/dpctl/tests/test_sycl_queue.py b/dpctl/tests/test_sycl_queue.py index e7444d50f0..655edff06a 100644 --- a/dpctl/tests/test_sycl_queue.py +++ b/dpctl/tests/test_sycl_queue.py @@ -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