pub unsafe extern "C" fn cuStreamGetCtx(
hStream: CUstream,
pctx: *mut CUcontext,
) -> CUresultExpand description
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 by cuCtxFromGreenCtx on the green context associated with the stream at creation time.
The stream handle hStream can 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_LEGACY and CU_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,cudaError_enum::CUDA_ERROR_INVALID_CONTEXTis returned.
Note that this function may also return error codes from previous, asynchronous launches.
§Parameters
hStream: Handle to the stream to be queried.pctx: Returned context associated with the stream.
§Return value
CUresult::CUDA_SUCCESSCUresult::CUDA_ERROR_DEINITIALIZEDCUresult::CUDA_ERROR_NOT_INITIALIZEDCUresult::CUDA_ERROR_INVALID_CONTEXTCUresult::CUDA_ERROR_INVALID_HANDLECUresult::CUDA_ERROR_NOT_SUPPORTED
See also: cuStreamDestroy, cuStreamCreateWithPriority, cuStreamGetPriority, cuStreamGetFlags, cuStreamGetDevice, cuStreamWaitEvent, cuStreamQuery, cuStreamSynchronize, cuStreamAddCallback, cudaStreamCreate, cudaStreamCreateWithFlags.