Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 1 addition & 3 deletions cuda_core/cuda/core/experimental/_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _init(obj=None, *, options: Optional[StreamOptions] = None):
if obj is not None:
if not hasattr(obj, "__cuda_stream__"):
raise ValueError
Comment thread
leofang marked this conversation as resolved.
Outdated
info = obj.__cuda_stream__
info = obj.__cuda_stream__()
Comment thread
leofang marked this conversation as resolved.
Outdated
assert info[0] == 0
self._mnff.handle = cuda.CUstream(info[1])
# TODO: check if obj is created under the current context/device
Expand Down Expand Up @@ -132,7 +132,6 @@ def close(self):
"""
self._mnff.close()

@property
def __cuda_stream__(self) -> Tuple[int, int]:
"""Return an instance of a __cuda_stream__ protocol."""
return (0, self.handle)
Expand Down Expand Up @@ -279,7 +278,6 @@ def from_handle(handle: int) -> Stream:
"""

class _stream_holder:
@property
def __cuda_stream__(self):
return (0, handle)

Expand Down
3 changes: 1 addition & 2 deletions cuda_core/docs/source/interoperability.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ exposing their own stream types.

To address this issue, we propose the ``__cuda_stream__`` protocol (currently version
0) as follows: For any Python objects that are meant to be interpreted as a stream, they
should add a ``__cuda_stream__`` attribute that returns a 2-tuple: The version number
should add a ``__cuda_stream__`` method that returns a 2-tuple: The version number
(``0``) and the address of ``cudaStream_t`` (both as Python `int`):

.. code-block:: python

class MyStream:

@property
def __cuda_stream__(self):
return (0, self.ptr)

Expand Down
7 changes: 7 additions & 0 deletions cuda_core/docs/source/release/0.2.0-notes.rst
Comment thread
leofang marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
``cuda.core`` v0.2.0 Release notes
==================================

Highlights
----------
Comment thread
leofang marked this conversation as resolved.
Outdated

- Change ``__cuda_stream__`` from attribute to method
1 change: 0 additions & 1 deletion cuda_core/examples/simple_multi_gpu_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class StreamAdaptor:
def __init__(self, obj):
self.obj = obj

@property
def __cuda_stream__(self):
# Note: CuPy streams have a .ptr attribute
return (0, self.obj.ptr)
Expand Down