Skip to content

Commit 5f531ad

Browse files
Changed repr for Memory objects (#442)
Added docstrings Added public properties: sycl_context sycl_device ``` In [2]: import dpctl.memory as dpm In [3]: dpm.MemoryUSMShared(1024) Out[3]: <SYCL(TM) USM-shared allocated memory block of 1024 bytes at 0x557aea12c000> ```
1 parent e68c16e commit 5f531ad

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

dpctl/memory/_memory.pyx

+31-2
Original file line numberDiff line numberDiff line change
@@ -232,33 +232,62 @@ cdef class _Memory:
232232
buffer.suboffsets = NULL # for pointer arrays only
233233

234234
property nbytes:
235+
""" Extent of this USM buffer in bytes. """
235236
def __get__(self):
236237
return self.nbytes
237238

238239
property size:
240+
""" Extent of this USM buffer in bytes. """
239241
def __get__(self):
240242
return self.nbytes
241243

242244
property _pointer:
245+
"""
246+
USM pointer at the start of this buffer
247+
represented in Python integer.
248+
"""
243249
def __get__(self):
244250
return <size_t>(self.memory_ptr)
245251

246252
property _context:
253+
""" :class:`dpctl.SyclContext` the USM pointer is bound to. """
247254
def __get__(self):
248255
return self.queue.get_sycl_context()
249256

250257
property _queue:
258+
"""
259+
:class:`dpctl.SyclQueue` with :class:`dpctl.SyclContext` the
260+
USM pointer is bound to and :class:`dpctl.SyclDevice` it was
261+
allocated on.
262+
"""
251263
def __get__(self):
252264
return self.queue
253265

254266
property reference_obj:
267+
"""
268+
Reference to the Python object owning this USM buffer.
269+
"""
255270
def __get__(self):
256271
return self.refobj
257272

273+
property sycl_context:
274+
""" :class:`dpctl.SyclContext` the USM pointer is bound to. """
275+
def __get__(self):
276+
return self.queue.get_sycl_context()
277+
278+
property sycl_device:
279+
""" :class:`dpctl.SyclDevice` the USM pointer is bound to. """
280+
def __get__(self):
281+
return self.queue.get_sycl_device()
282+
258283
def __repr__(self):
259284
return (
260-
"<Intel(R) USM allocated memory block of {} bytes at {}>"
261-
.format(self.nbytes, hex(<object>(<size_t>self.memory_ptr)))
285+
"<SYCL(TM) USM-{} allocated memory block of {} bytes at {}>"
286+
.format(
287+
self.get_usm_type(),
288+
self.nbytes,
289+
hex(<object>(<size_t>self.memory_ptr))
290+
)
262291
)
263292

264293
def __len__(self):

0 commit comments

Comments
 (0)