Skip to content

Commit 70ff96b

Browse files
committed
DOC: Add admonition to docstrings for cuda.core handle properties
1 parent 0dfae43 commit 70ff96b

File tree

6 files changed

+39
-5
lines changed

6 files changed

+39
-5
lines changed

cuda_core/cuda/core/experimental/_event.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,11 @@ def is_done(self) -> bool:
164164

165165
@property
166166
def handle(self) -> cuda.bindings.driver.CUevent:
167-
"""Return the underlying CUevent object."""
167+
"""Return the underlying CUevent object.
168+
169+
.. caution::
170+
171+
This handle is a python object. To get the memory address of the C struct, call
172+
``int(Event.handle)`` not ``Event.handle.getPtr()``.
173+
"""
168174
return self._mnff.handle

cuda_core/cuda/core/experimental/_linker.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,11 @@ def handle(self) -> LinkerHandleT:
503503
.. note::
504504
505505
The type of the returned object depends on the backend.
506+
507+
.. caution::
508+
509+
This handle is a python object. To get the memory address of the C struct, call
510+
``int(Linker.handle)`` not ``Linker.handle.getPtr()``.
506511
"""
507512
return self._mnff.handle
508513

cuda_core/cuda/core/experimental/_memory.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,14 @@ def close(self, stream=None):
8181
self._mnff.close(stream)
8282

8383
@property
84-
def handle(self):
85-
"""Return the buffer handle object."""
84+
def handle(self) -> driver.CUdeviceptr:
85+
"""Return the buffer handle object.
86+
87+
.. caution::
88+
89+
This handle is a python object. To get the memory address of the C struct, call
90+
``int(Buffer.handle)`` not ``Buffer.handle.getPtr()``.
91+
"""
8692
return self._mnff.ptr
8793

8894
@property

cuda_core/cuda/core/experimental/_module.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,5 +354,11 @@ def code(self) -> CodeTypeT:
354354
@property
355355
@precondition(_lazy_load_module)
356356
def handle(self):
357-
"""Return the underlying handle object."""
357+
"""Return the underlying handle object.
358+
359+
.. caution::
360+
361+
This handle is a python object. To get the memory address of the C struct, call
362+
``int(ObjectCode.handle)`` not ``ObjectCode.handle.getPtr()``.
363+
"""
358364
return self._handle

cuda_core/cuda/core/experimental/_program.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,5 +524,10 @@ def handle(self) -> ProgramHandleT:
524524
.. note::
525525
526526
The type of the returned object depends on the backend.
527+
528+
.. caution::
529+
530+
This handle is a python object. To get the memory address of the C struct, call
531+
``int(Program.handle)`` not ``Program.handle.getPtr()``.
527532
"""
528533
return self._mnff.handle

cuda_core/cuda/core/experimental/_stream.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,13 @@ def __cuda_stream__(self) -> Tuple[int, int]:
189189

190190
@property
191191
def handle(self) -> cuda.bindings.driver.CUstream:
192-
"""Return the underlying ``CUstream`` object."""
192+
"""Return the underlying ``CUstream`` object.
193+
194+
.. caution::
195+
196+
This handle is a python object. To get the memory address of the C struct, call
197+
``int(Stream.handle)`` not ``Stream.handle.getPtr()``.
198+
"""
193199
return self._mnff.handle
194200

195201
@property

0 commit comments

Comments
 (0)