cuda.bindings._v2.driver.ctx_from_green_ctx#
- cuda.bindings._v2.driver.ctx_from_green_ctx(intptr_t h_ctx) intptr_t#
Returns a
CUcontexthandle for a green context.This API returns in
p_contextaCUcontexthandle that represents the specified green contexth_ctx. The returned handle can be passed to CUDA APIs that accept aCUcontextand will be treated as if it were a primary context, while still honoring the resources and configuration associated withh_ctxas applicable. Applications that wish to use a green context with CUDA APIs that require aCUcontextmust use this API to obtain a handle to aCUcontextrepresenting the green context. Otherwise, passing a green context to such APIs will fail withCUDA_ERROR_INVALID_CONTEXT. TheCUcontextreturned bycuCtxFromGreenCtxmay be passed to CUDA Driver APIs that accept aCUcontext.For APIs whose semantics are independent of green context resources, the operation is performed identically to how it would perform with a primary context.
For APIs whose behavior depends on green context resources (for example, kernel launch), the operation is performed using the resources and configuration of the specified green context
h_ctx.
This call does not create a new independent context and does not change the underlying context lifetime. The validity of the returned
p_contextis tied toh_ctx, and no additional destruction or release is required beyond correctly managingh_ctxwith the green context APIs. Destroyingp_contextviacuCtxDestroyis undefined behavior.- Parameters:
h_ctx (intptr_t) – Green context to convert.
- Returns:
Returned
CUcontextwith green context resources.- Return type:
intptr_t
See also
cuCtxFromGreenCtx