Function cuCtxDestroy_v2

Source
pub unsafe extern "C" fn cuCtxDestroy_v2(ctx: CUcontext) -> CUresult
Expand description

\brief Destroy a CUDA context

Destroys the CUDA context specified by \p ctx. The context \p ctx will be destroyed regardless of how many threads it is current to. It is the responsibility of the calling function to ensure that no API call issues using \p ctx while ::cuCtxDestroy() is executing.

Destroys and cleans up all resources associated with the context. It is the caller’s responsibility to ensure that the context or its resources are not accessed or passed in subsequent API calls and doing so will result in undefined behavior. These resources include CUDA types ::CUmodule, ::CUfunction, ::CUstream, ::CUevent, ::CUarray, ::CUmipmappedArray, ::CUtexObject, ::CUsurfObject, ::CUtexref, ::CUsurfref, ::CUgraphicsResource, ::CUlinkState, ::CUexternalMemory and ::CUexternalSemaphore. These resources also include memory allocations by ::cuMemAlloc(), ::cuMemAllocHost(), ::cuMemAllocManaged() and ::cuMemAllocPitch().

If \p ctx is current to the calling thread then \p ctx will also be popped from the current thread’s context stack (as though ::cuCtxPopCurrent() were called). If \p ctx is current to other threads, then \p ctx will remain current to those threads, and attempting to access \p ctx from those threads will result in the error ::CUDA_ERROR_CONTEXT_IS_DESTROYED.

\note ::cuCtxDestroy() will not destroy memory allocations by ::cuMemCreate(), ::cuMemAllocAsync() and ::cuMemAllocFromPoolAsync(). These memory allocations are not associated with any CUDA context and need to be destroyed explicitly.

\param ctx - Context to destroy

\return ::CUDA_SUCCESS, ::CUDA_ERROR_DEINITIALIZED, ::CUDA_ERROR_NOT_INITIALIZED, ::CUDA_ERROR_INVALID_CONTEXT, ::CUDA_ERROR_INVALID_VALUE \notefnerr

\sa ::cuCtxCreate, ::cuCtxGetApiVersion, ::cuCtxGetCacheConfig, ::cuCtxGetDevice, ::cuCtxGetFlags, ::cuCtxGetLimit, ::cuCtxPopCurrent, ::cuCtxPushCurrent, ::cuCtxSetCacheConfig, ::cuCtxSetLimit, ::cuCtxSynchronize