Skip to main content

cudaExecutionCtxDestroy

Function cudaExecutionCtxDestroy 

Source
pub unsafe extern "C" fn cudaExecutionCtxDestroy(
    ctx: cudaExecutionContext_t,
) -> cudaError_t
Expand description

Destroy a execution context.

Destroys the specified execution context ctx. It is the responsibility of the caller to ensure that no API call issues using ctx while cudaExecutionCtxDestroy is executing or subsequently.

If ctx is a green context, any resources provisioned for it (that were initially available via the resource descriptor) are released as well.

The API does not destroy streams created via cudaExecutionCtxStreamCreate. Users are expected to destroy these streams explicitly using cudaStreamDestroy to avoid resource leaks. Once the execution context is destroyed, any subsequent API calls involving these streams will return cudaError_t::CUDA_ERROR_STREAM_DETACHED with the exception of the following APIs:

Additionally, the API will invalidate all active captures on these streams.

Passing in a ctx that was not explicitly created via CUDA Runtime APIs is not allowed and will result in undefined behavior.

Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaError_t::CUDA_ERROR_NOT_PERMITTED may, but is not guaranteed to, be returned as a diagnostic in such case.

Note: The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit context-based programming without relying on thread-local state. If no context is specified, the API will return cudaError_t::CUDA_ERROR_INVALID_VALUE.

§Parameters

  • ctx: Execution context to destroy (required parameter, see note below)

§Return value

See also: cudaGreenCtxCreate.