cuda.bindings._v2.driver.stream_get_ctx_v2#
- cuda.bindings._v2.driver.stream_get_ctx_v2(intptr_t h_stream) tuple#
Query the contexts associated with a stream.
Returns the contexts that the stream is associated with. If the stream is associated with a green context, the API returns the green context in
p_green_ctxand the primary context of the associated device inp_ctx. If the stream is associated with a regular context, the API returns the regular context inp_ctxand NULL inp_green_ctx. The stream handleh_streamcan refer to any of the following:.a stream created via any of the CUDA driver APIs such as
cuStreamCreate,cuStreamCreateWithPriorityandcuGreenCtxStreamCreate, or their runtime API equivalents such ascudaStreamCreate,cudaStreamCreateWithFlagsandcudaStreamCreateWithPriority. 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. If any of the special handles are specified, the API will operate on the context current to the calling thread. If a green context (that was converted viactx_from_green_ctx()before setting it current) is current to the calling thread, the API will return the green context inp_green_ctxand the primary context of the associated device inp_ctx. If a regular context is current, the API returns the regular context inp_ctxand NULL inp_green_ctx. Note that specifyingCU_STREAM_PER_THREADorcudaStreamPerThreadwill returnCUDA_ERROR_INVALID_HANDLEif a green context is 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:
intptr_t: Returned regular context associated with the stream.
- intptr_t: Returned green context if the stream is associated with
a green context or NULL if not.
- Return type:
A 2-tuple containing
See also
cuStreamGetCtx_v2