Repository navigation
cuda.core: treat the NULL stream as a default-stream token #3243
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,13 +37,14 @@ cdef inline bint Stream_handle_is_default_token(cydriver.CUstream s) noexcept no | |
|
|
||
| These tokens carry no context of their own; they refer to whatever context | ||
| is current, so nothing resolved from one may be cached on the object. | ||
| The NULL stream (handle 0) is such a token too. | ||
| """ | ||
| cdef uintptr_t h = <uintptr_t>s | ||
| return h == <uintptr_t>cydriver.CU_STREAM_LEGACY or h == <uintptr_t>cydriver.CU_STREAM_PER_THREAD | ||
| return h == 0 or h == <uintptr_t>cydriver.CU_STREAM_LEGACY or h == <uintptr_t>cydriver.CU_STREAM_PER_THREAD | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With handle 0 now accepted into Concretely, If handle 0 is meant to behave like CU_STREAM_LEGACY everywhere, |
||
|
|
||
|
|
||
| cdef inline bint Stream_is_default_token(Stream self) noexcept nogil: | ||
| """Return True when this stream is CU_STREAM_LEGACY or CU_STREAM_PER_THREAD.""" | ||
| """Return True when this stream is the NULL stream, CU_STREAM_LEGACY or CU_STREAM_PER_THREAD.""" | ||
| return Stream_handle_is_default_token(as_cu(self._h_stream)) | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: NVIDIA/cuda-python
Length of output: 4926
important: Keep the explicit sync for handle-0 streams in
VirtualMemoryResource.deallocate.On a host-located resource,
deallocate(ptr, size, stream=Stream.from_handle(0))now skipsstream.sync(). The predicate change in_stream.pxdmakes handle0a default-stream token. The guard at_virtual_memory_resource.pyx:915-916then exempts it. Before this PR, the same call synced the stream.cuMemUnmaptakes no stream argument, so it does not wait for work queued on the NULL stream. Queued work that accesses the range can run after the unmap. The docstring promisesstream.sync()when a stream is given. The exemption is written for unbound teardown tokens, not for a stream the caller passes explicitly.Keep the sync when the caller supplies the NULL stream. Confirm how
Bufferteardown passes its token before changing the guard. A check on the handle value alone may not separate the two cases.