@@ -107,13 +107,57 @@ cdef class Stream:
107107 return s
108108
109109 @classmethod
110- def _legacy_default (cls ):
111- """ Return the legacy default stream (supports subclassing)."""
110+ def legacy_default (cls ):
111+ """ Return the legacy default stream.
112+
113+ The legacy default stream is an implicit stream which synchronizes
114+ with all other streams in the same CUDA context except for non-blocking
115+ streams. When any operation is launched on the legacy default stream,
116+ it waits for all previously launched operations in blocking streams to
117+ complete, and all subsequent operations in blocking streams wait for
118+ the legacy default stream operation to complete.
119+
120+ Returns
121+ -------
122+ Stream
123+ The legacy default stream instance for the current context.
124+
125+ See Also
126+ --------
127+ per_thread_default : Per-thread default stream alternative.
128+
129+ Examples
130+ --------
131+ >>> stream = Stream.legacy_default()
132+ >>> stream.sync() # Synchronize all operations
133+ """
112134 return Stream._from_handle(cls , get_legacy_stream())
113135
114136 @classmethod
115- def _per_thread_default (cls ):
116- """ Return the per-thread default stream (supports subclassing)."""
137+ def per_thread_default (cls ):
138+ """ Return the per-thread default stream.
139+
140+ The per-thread default stream is local to both the calling thread and
141+ the CUDA context. Unlike the legacy default stream, it does not
142+ synchronize with other streams and behaves like an explicitly created
143+ non-blocking stream. This allows for better concurrency in multi-threaded
144+ applications.
145+
146+ Returns
147+ -------
148+ Stream
149+ The per-thread default stream instance for the current thread
150+ and context.
151+
152+ See Also
153+ --------
154+ legacy_default : Legacy default stream alternative.
155+
156+ Examples
157+ --------
158+ >>> stream = Stream.per_thread_default()
159+ >>> stream.sync() # Synchronize only this thread's operations
160+ """
117161 return Stream._from_handle(cls , get_per_thread_stream())
118162
119163 @classmethod
@@ -378,8 +422,8 @@ cdef class Stream:
378422
379423
380424# c-only python objects , not public
381- cdef Stream C_LEGACY_DEFAULT_STREAM = Stream._legacy_default ()
382- cdef Stream C_PER_THREAD_DEFAULT_STREAM = Stream._per_thread_default ()
425+ cdef Stream C_LEGACY_DEFAULT_STREAM = Stream.legacy_default ()
426+ cdef Stream C_PER_THREAD_DEFAULT_STREAM = Stream.per_thread_default ()
383427
384428# standard python objects , public
385429LEGACY_DEFAULT_STREAM = C_LEGACY_DEFAULT_STREAM
0 commit comments