Skip to content

Commit 364f847

Browse files
add test_sycl_usm test to use copy_from_device
1 parent 107e78b commit 364f847

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

dpctl/tests/test_sycl_usm.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,24 @@ def test_memory_construction_from_other_memory_objects():
475475
m3 = MemoryUSMShared(m_de, copy=True)
476476
assert bytes(m1) == bytes(m_sh)
477477
assert bytes(m2) == bytes(m3)
478+
479+
480+
def test_memory_copy_between_contexts():
481+
try:
482+
q = dpctl.SyclQueue("cpu")
483+
except dpctl.SyclQueueCreationError:
484+
pytest.skip("CPU queue could not be created")
485+
d = q.sycl_device
486+
n = d.max_compute_units
487+
n_half = n // 2
488+
d0, d1 = d.create_sub_devices(partition=[n_half, n - n_half])
489+
q0 = dpctl.SyclQueue(d0)
490+
q1 = dpctl.SyclQueue(d1)
491+
m0 = MemoryUSMDevice(256, queue=q0)
492+
m1 = MemoryUSMDevice(256, queue=q1)
493+
host_buf = b"abcd" * 64
494+
m0.copy_from_host(host_buf)
495+
m1.copy_from_device(m0)
496+
copy_buf = bytearray(256)
497+
m1.copy_to_host(copy_buf)
498+
assert host_buf == copy_buf

0 commit comments

Comments
 (0)