Skip to content

Memory properties #647

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 3 commits into from
Nov 3, 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
9 changes: 9 additions & 0 deletions dpctl/memory/_memory.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,15 @@ cdef class _Memory:
def __get__(self):
return self.queue.get_sycl_device()

property sycl_queue:
"""
:class:`dpctl.SyclQueue` with :class:`dpctl.SyclContext` the
USM allocation is bound to and :class:`dpctl.SyclDevice` it was
allocated on.
"""
def __get__(self):
return self.queue

def __repr__(self):
return (
"<SYCL(TM) USM-{} allocation of {} bytes at {}>"
Expand Down
4 changes: 3 additions & 1 deletion dpctl/tests/test_sycl_usm.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def test_memory_create(memory_ctor):
assert len(mobj) == nbytes
assert mobj.size == nbytes
assert mobj._context == queue.sycl_context
assert mobj._queue == queue
assert mobj.sycl_queue == queue
assert type(repr(mobj)) is str
assert type(bytes(mobj)) is bytes
assert sys.getsizeof(mobj) > nbytes
Expand Down Expand Up @@ -495,7 +497,7 @@ def test_with_constructor(memory_ctor):
shape=(64,),
strides=(1,),
offset=0,
syclobj=buf._queue._get_capsule(),
syclobj=buf.sycl_queue._get_capsule(),
)
check_view(v)
# Use context capsule
Expand Down