Skip to content

Commit 2d2426e

Browse files
Adjusted test for reconstruction of USM host allocation from SUAI (#846)
The dpctl.MemoryUSM* Python object representing USM allocation are reconstructed from an object exposing __sycl_usm_array_interface__ use USM-pointer queries. When SUAI provides sycl::context object, the device is inferred using `get_pointer_device`. For host allocations this may not need to return the device in the queue used to make the allocation. It will return the first device in the context to which the allocation is bound instead (per SYCL 2020 spec).
1 parent e132320 commit 2d2426e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

dpctl/tests/test_sycl_usm.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,13 +473,24 @@ def check_view(v):
473473
"""
474474
assert type(v) is View
475475
buf = v.buffer_
476+
buf_usm_type = buf.get_usm_type()
476477
m = as_usm_memory(v)
477-
assert m.get_usm_type() == buf.get_usm_type()
478+
assert m.get_usm_type() == buf_usm_type
478479
assert m._pointer == buf._pointer
479-
assert m.sycl_device == buf.sycl_device
480+
if buf_usm_type == "host":
481+
buf_ctx = buf.sycl_context
482+
assert m.sycl_context == buf_ctx
483+
assert m.sycl_device == buf_ctx.get_devices()[0]
484+
else:
485+
assert m.sycl_context == buf.sycl_context
486+
assert m.sycl_device == buf.sycl_device
480487

481488

482489
def test_with_constructor(memory_ctor):
490+
"""
491+
Tests that memory objects reconstructed from __sycl_usm_array_interface__
492+
are consistent with the original memory buffer.
493+
"""
483494
try:
484495
buf = memory_ctor(64)
485496
except Exception:

0 commit comments

Comments
 (0)