Skip to content
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

[WIP] Support enabling PTDS via CUDA_PTDS environment variable #633

Open
wants to merge 7 commits into
base: branch-21.06
Choose a base branch
from
7 changes: 6 additions & 1 deletion python/rmm/_cuda/stream.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from libc.stdint cimport uintptr_t
from libcpp cimport bool

Expand Down Expand Up @@ -117,7 +119,10 @@ cdef class Stream:
self._cuda_stream, self._owner = stream._cuda_stream, stream._owner


DEFAULT_STREAM = Stream._from_cudaStream_t(cuda_stream_default.value())
if int(os.environ.get("RMM_PER_THREAD_DEFAULT_STREAM", "0")) != 0:
DEFAULT_STREAM = Stream._from_cudaStream_t(cuda_stream_per_thread.value())
else:
DEFAULT_STREAM = Stream._from_cudaStream_t(cuda_stream_default.value())
Comment on lines +122 to +125
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to allow this to be changed during runtime of an application or only at import time?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume at import time as this is what I think cupy does now

Copy link
Member

@leofang leofang Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well CuPy reads the env var (same is done here) so technically there it could be changed at runtime by overwriting os.environ['CUPY_CUDA_PER_THREAD_DEFAULT_STREAM']. However such operation is really a bad practice that is hard to be fool-proofed.

LEGACY_DEFAULT_STREAM = Stream._from_cudaStream_t(cuda_stream_legacy.value())
PER_THREAD_DEFAULT_STREAM = Stream._from_cudaStream_t(
cuda_stream_per_thread.value()
Expand Down