-
Notifications
You must be signed in to change notification settings - Fork 252
Move stream objects from cuda_stream cython to stream cython
#2256
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
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
55ffa82
move/deprecate
brandon-b-miller 88af3f4
move code around, pass tests
brandon-b-miller 12a45d3
address reviews
brandon-b-miller ce2a938
put module in namespace directly to workaround cython
brandon-b-miller 5c7b71a
warning update
brandon-b-miller 7600ebe
Merge branch 'main' into fix-1782
bdice 6346a4c
Apply copyright checks to pyi files
bdice 7368d65
Fix deprecation message in cuda_stream shim and clean up _OwningStrea…
bdice ecebb9a
Expose cuda_stream flags constructor through Cython binding and Strea…
bdice e43195c
Add test for DeprecationWarning on import of rmm.pylibrmm.cuda_stream
bdice f4f5ea5
Add test for DeprecationWarning on import of rmm.pylibrmm.cuda_stream
bdice 656fdaa
Merge branch 'fix-1782' of https://github.com/brandon-b-miller/rmm in…
bdice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,4 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION. | ||
| # SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| cimport cython | ||
| from cuda.bindings.cyruntime cimport cudaStream_t | ||
| from libcpp cimport bool | ||
| from libcpp.memory cimport unique_ptr | ||
|
|
||
| from rmm.librmm.cuda_stream cimport cuda_stream | ||
|
|
||
|
|
||
| @cython.final | ||
| cdef class CudaStream: | ||
| cdef unique_ptr[cuda_stream] c_obj | ||
| cdef cudaStream_t value(self) except * nogil | ||
| cdef bool is_valid(self) except * nogil | ||
| from rmm.pylibrmm.stream cimport _OwningStream as CudaStream |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,28 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION. | ||
| # SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| cimport cython | ||
| from enum import IntEnum | ||
| from cuda.bindings.cyruntime cimport cudaStream_t | ||
| from libcpp cimport bool | ||
|
|
||
| from rmm.librmm.cuda_stream cimport cuda_stream, cuda_stream_flags | ||
|
|
||
|
|
||
| class CudaStreamFlags(IntEnum): | ||
| """ | ||
| Enumeration of CUDA stream creation flags. | ||
|
|
||
| Attributes | ||
| ---------- | ||
| SYNC_DEFAULT : int | ||
| Created stream synchronizes with the default stream. | ||
| NON_BLOCKING : int | ||
| Created stream does not synchronize with the default stream. | ||
| """ | ||
| SYNC_DEFAULT = <int>(cuda_stream_flags.sync_default) | ||
| NON_BLOCKING = <int>(cuda_stream_flags.non_blocking) | ||
|
|
||
|
|
||
| @cython.final | ||
| cdef class CudaStream: | ||
| """ | ||
| Wrapper around a CUDA stream with RAII semantics. | ||
| When a CudaStream instance is GC'd, the underlying | ||
| CUDA stream is destroyed. | ||
| """ | ||
| def __cinit__(self): | ||
| with nogil: | ||
| self.c_obj.reset(new cuda_stream()) | ||
|
|
||
| def __dealloc__(self): | ||
| with nogil: | ||
| self.c_obj.reset() | ||
|
|
||
| cdef cudaStream_t value(self) except * nogil: | ||
| return self.c_obj.get()[0].value() | ||
|
|
||
| cdef bool is_valid(self) except * nogil: | ||
| return self.c_obj.get()[0].is_valid() | ||
| # backwards compat file reexporting CudaStream and CudaStreamFlags | ||
|
|
||
| import warnings | ||
|
|
||
| from rmm.pylibrmm.stream cimport _OwningStream as CudaStream | ||
|
|
||
| import sys | ||
|
|
||
| from rmm.pylibrmm.stream import CudaStreamFlags, _OwningStream | ||
|
|
||
| sys.modules[__name__].CudaStream = _OwningStream | ||
| del _OwningStream | ||
|
|
||
| warnings.warn( | ||
| "rmm.pylibrmm.cuda_stream is deprecated; " | ||
| "use rmm.pylibrmm.stream.CudaStreamFlags for stream flags, " | ||
| "and rmm.pylibrmm.stream.Stream for stream objects.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "CudaStream", | ||
| "CudaStreamFlags", | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.