From c51f9bdd4daeb601b90e42dc9e6276fc6b8cf305 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Wed, 12 May 2021 19:59:41 -0500 Subject: [PATCH] Changed repr for Memory objects Added docstrings Added public properties: sycl_context sycl_device ``` In [2]: import dpctl.memory as dpm In [3]: dpm.MemoryUSMShared(1024) Out[3]: ``` --- dpctl/memory/_memory.pyx | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/dpctl/memory/_memory.pyx b/dpctl/memory/_memory.pyx index 3838651f08..6541a315f2 100644 --- a/dpctl/memory/_memory.pyx +++ b/dpctl/memory/_memory.pyx @@ -232,33 +232,62 @@ cdef class _Memory: buffer.suboffsets = NULL # for pointer arrays only property nbytes: + """ Extent of this USM buffer in bytes. """ def __get__(self): return self.nbytes property size: + """ Extent of this USM buffer in bytes. """ def __get__(self): return self.nbytes property _pointer: + """ + USM pointer at the start of this buffer + represented in Python integer. + """ def __get__(self): return (self.memory_ptr) property _context: + """ :class:`dpctl.SyclContext` the USM pointer is bound to. """ def __get__(self): return self.queue.get_sycl_context() property _queue: + """ + :class:`dpctl.SyclQueue` with :class:`dpctl.SyclContext` the + USM pointer is bound to and :class:`dpctl.SyclDevice` it was + allocated on. + """ def __get__(self): return self.queue property reference_obj: + """ + Reference to the Python object owning this USM buffer. + """ def __get__(self): return self.refobj + property sycl_context: + """ :class:`dpctl.SyclContext` the USM pointer is bound to. """ + def __get__(self): + return self.queue.get_sycl_context() + + property sycl_device: + """ :class:`dpctl.SyclDevice` the USM pointer is bound to. """ + def __get__(self): + return self.queue.get_sycl_device() + def __repr__(self): return ( - "" - .format(self.nbytes, hex((self.memory_ptr))) + "" + .format( + self.get_usm_type(), + self.nbytes, + hex((self.memory_ptr)) + ) ) def __len__(self):