Function cuGreenCtxCreate

Source
pub unsafe extern "C" fn cuGreenCtxCreate(
    phCtx: *mut CUgreenCtx,
    desc: CUdevResourceDesc,
    dev: CUdevice,
    flags: c_uint,
) -> CUresult
Expand description

\brief Creates a green context with a specified set of resources.

This API creates a green context with the resources specified in the descriptor \p desc and returns it in the handle represented by \p phCtx. This API will retain the primary context on device \p dev, which will is released when the green context is destroyed. It is advised to have the primary context active before calling this API to avoid the heavy cost of triggering primary context initialization and deinitialization multiple times.

The API does not set the green context current. In order to set it current, you need to explicitly set it current by first converting the green context to a CUcontext using ::cuCtxFromGreenCtx and subsequently calling ::cuCtxSetCurrent / ::cuCtxPushCurrent. It should be noted that a green context can be current to only one thread at a time. There is no internal synchronization to make API calls accessing the same green context from multiple threads work.

Note: The API is not supported on 32-bit platforms.

\param phCtx - Pointer for the output handle to the green context \param desc - Descriptor generated via ::cuDevResourceGenerateDesc which contains the set of resources to be used \param dev - Device on which to create the green context. \param flags - One of the supported green context creation flags. \p CU_GREEN_CTX_DEFAULT_STREAM is required.

The supported flags are:

  • \p CU_GREEN_CTX_DEFAULT_STREAM : Creates a default stream to use inside the green context. Required.

\return ::CUDA_SUCCESS, ::CUDA_ERROR_DEINITIALIZED, ::CUDA_ERROR_NOT_INITIALIZED, ::CUDA_ERROR_INVALID_DEVICE, ::CUDA_ERROR_INVALID_VALUE, ::CUDA_ERROR_NOT_SUPPORTED, ::CUDA_ERROR_OUT_OF_MEMORY

\sa ::cuGreenCtxDestroy, ::cuCtxFromGreenCtx, ::cuCtxSetCurrent, ::cuCtxPushCurrent, ::cuDevResourceGenerateDesc, ::cuDevicePrimaryCtxRetain, ::cuCtxCreate, ::cuCtxCreate_v3