You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cuda.core: treat the NULL stream as a default-stream token - #3243
Stream_handle_is_default_token now also matches handle 0, so a Stream over the NULL stream resolves its context and device on every call, as LEGACY_DEFAULT_STREAM and PER_THREAD_DEFAULT_STREAM do since #2485. The synchronous and virtual memory resources, which check the same predicate before recording a deallocation stream, now handle a handle-0 stream like the other two tokens as well. The test switches into a green context so it runs on a single GPU, and there is a 1.3.0 release note.
Stream_is_default_token matched only CU_STREAM_LEGACY and
CU_STREAM_PER_THREAD, so a Stream over handle 0, such as
Stream.from_handle(0), still cached the first context and device it
resolved. The driver resolves handle 0 against the current context like
the other two, so after a context switch .context, .device, .resources
and record() kept naming the old context.
ClosesNVIDIA#3242
Signed-off-by: Vyron Vasileiadis <hi@fedonman.com>
Streams wrapping the NULL handle now resolve their context, device, resources, and recorded events using the current context, consistent with other default streams.
Tests
Added coverage verifying that a NULL-handle stream follows context changes.
Handle 0 is now recognized as a default-stream token. NULL-handle streams resolve context-dependent properties and record operations against the current context. A green-context test checks context and event resolution, and the release notes describe the behavior.
Changes: NULL-stream context resolution
Layer / File(s)
Summary
Default-token resolution and validation cuda_core/cuda/core/_stream.pyx, cuda_core/tests/test_green_context.py, cuda_core/docs/source/release/1.3.0-notes.rst
The default-token check now includes handle 0. The test checks context resolution before, during, and after a green-context scope, and checks the recorded event's context. The release notes describe current-context resolution for NULL-stream operations.
Assessment against linked issues
Objective
Addressed
Explanation
NULL-handle streams resolve context-dependent properties and recorded events against the current context [#3242]
suggestion: Add NULL-stream coverage for device, resources, and foreign wrappers.
The added test covers context and record() for Stream.from_handle(0) only. The existing default-stream test covers LEGACY_DEFAULT_STREAM and PER_THREAD_DEFAULT_STREAM, but not handle 0. Add device and resources assertions for the NULL stream, and create a foreign object whose __cuda_stream__ returns (0, 0). A handle-0 regression in either path can pass the current tests.
Reviewing files that changed from the base of the PR and between 590a8bf and 2a33c03.
Files selected for processing: 3
cuda_core/cuda/core/_stream.pyx
cuda_core/docs/source/release/1.3.0-notes.rst
cuda_core/tests/test_green_context.py
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.
Stream_handle_is_default_token now also matches handle 0, so a Stream over the NULL stream resolves its context and device on every call, as LEGACY_DEFAULT_STREAM and PER_THREAD_DEFAULT_STREAM do since #2485.
FYI just a note, this is true for the "re-resolve, don't cache" property this PR cares about. It is not true semantically under a green ctx: PTDS with a green ctx current is a hard CUDA_ERROR_INVALID_HANDLE ("CUDA Green Contexts cannot be used with stream-per-thread mode"), while handle 0 and CU_STREAM_LEGACY resolve to the green ctx's own null stream, which is a distinct stream object from the primary ctx's null stream (and only exists if the green ctx was created with CU_GREEN_CTX_DEFAULT_STREAM). Its default sync semantics are also different — PTDS-like non-blocking rather than the legacy sync-with-all, blocking behavior of the primary ctx's NULL stream.
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
cuda.coreEverything related to the cuda.core module
2 participants
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.
Stream_handle_is_default_tokennow also matches handle 0, so aStreamover the NULL stream resolves its context and device on every call, asLEGACY_DEFAULT_STREAMandPER_THREAD_DEFAULT_STREAMdo since #2485. The synchronous and virtual memory resources, which check the same predicate before recording a deallocation stream, now handle a handle-0 stream like the other two tokens as well. The test switches into a green context so it runs on a single GPU, and there is a 1.3.0 release note.Closes #3242