cuda.bindings._v2.driver.stream_get_ctx#
- cuda.bindings._v2.driver.stream_get_ctx(intptr_t h_stream) intptr_t#
Query the context associated with a stream.
Returns the CUDA context that the stream is associated with. If the stream was created via the API
cuGreenCtxStreamCreate, the returned context is equivalent to the one returned byctx_from_green_ctx()on the green context associated with the stream at creation time. The stream handleh_streamcan refer to any of the following:.a stream created via any of the CUDA driver APIs such as
cuStreamCreateandcuStreamCreateWithPriority, or their runtime API equivalents such ascudaStreamCreate,cudaStreamCreateWithFlagsandcudaStreamCreateWithPriority. The returned context is the context that was active in the calling thread when the stream was created. Passing an invalid handle will result in undefined behavior.any of the special streams such as the NULL stream,
CU_STREAM_LEGACYandCU_STREAM_PER_THREAD. The runtime API equivalents of these are also accepted, which are NULL,cudaStreamLegacyandcudaStreamPerThreadrespectively. Specifying any of the special handles will return the context current to the calling thread. If no context is current to the calling thread,CUDA_ERROR_INVALID_CONTEXTis returned.
- Parameters:
h_stream (intptr_t) – Handle to the stream to be queried.
- Returns:
Returned context associated with the stream.
- Return type:
intptr_t
See also
cuStreamGetCtx