Function cuStreamGetCtx

Source
pub unsafe extern "C" fn cuStreamGetCtx(
    hStream: CUstream,
    pctx: *mut CUcontext,
) -> CUresult
Expand description

\brief Query the context associated with a stream

Returns the CUDA context that the stream is associated with.

Note there is a later version of this API, ::cuStreamGetCtx_v2. It will supplant this version in CUDA 13.0. It is recommended to use ::cuStreamGetCtx_v2 till then as this version will return ::CUDA_ERROR_NOT_SUPPORTED for streams created via the API ::cuGreenCtxStreamCreate.

The stream handle \p hStream can refer to any of the following:

  • a stream created via any of the CUDA driver APIs such as ::cuStreamCreate and ::cuStreamCreateWithPriority, or their runtime API equivalents such as ::cudaStreamCreate, ::cudaStreamCreateWithFlags and ::cudaStreamCreateWithPriority. 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_LEGACY and ::CU_STREAM_PER_THREAD. The runtime API equivalents of these are also accepted, which are NULL, ::cudaStreamLegacy and ::cudaStreamPerThread respectively. 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_CONTEXT is returned.

\param hStream - Handle to the stream to be queried \param pctx - Returned context associated with the stream

\return ::CUDA_SUCCESS, ::CUDA_ERROR_DEINITIALIZED, ::CUDA_ERROR_NOT_INITIALIZED, ::CUDA_ERROR_INVALID_CONTEXT, ::CUDA_ERROR_INVALID_HANDLE, ::CUDA_ERROR_NOT_SUPPORTED \notefnerr

\sa ::cuStreamDestroy, ::cuStreamCreateWithPriority, ::cuStreamGetPriority, ::cuStreamGetFlags, ::cuStreamWaitEvent, ::cuStreamQuery, ::cuStreamSynchronize, ::cuStreamAddCallback, ::cudaStreamCreate, ::cuStreamGetCtx_v2, ::cudaStreamCreateWithFlags