Context Management

Context Management#

HIP Runtime API Reference: Context Management
Context Management
Collaboration diagram for Context Management:

Modules

 Context Management [Deprecated]
 

Functions

hipError_t hipDevicePrimaryCtxGetState (hipDevice_t dev, unsigned int *flags, int *active)
 Get the state of the primary context.
 
hipError_t hipDevicePrimaryCtxRelease (hipDevice_t dev)
 Release the primary context on the GPU.
 
hipError_t hipDevicePrimaryCtxRetain (hipCtx_t *pctx, hipDevice_t dev)
 Retain the primary context on the GPU.
 
hipError_t hipDevicePrimaryCtxReset (hipDevice_t dev)
 Resets the primary context on the GPU.
 
hipError_t hipDevicePrimaryCtxSetFlags (hipDevice_t dev, unsigned int flags)
 Set flags for the primary context.
 

Detailed Description



This section describes the context management functions of HIP runtime API.

Function Documentation

◆ hipDevicePrimaryCtxGetState()

hipError_t hipDevicePrimaryCtxGetState ( hipDevice_t  dev,
unsigned int *  flags,
int *  active 
)

Get the state of the primary context.

Parameters
[in]devDevice to get primary context flags for
[out]flagsPointer to store flags
[out]activePointer to store context state; 0 = inactive, 1 = active
Returns
hipSuccess
See also
hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice

◆ hipDevicePrimaryCtxRelease()

hipError_t hipDevicePrimaryCtxRelease ( hipDevice_t  dev)

Release the primary context on the GPU.

Parameters
[in]devDevice which primary context is released
Returns
hipSuccess
See also
hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice
Warning
This function return hipSuccess though doesn't release the primaryCtx by design on HIP/HCC path.

◆ hipDevicePrimaryCtxReset()

hipError_t hipDevicePrimaryCtxReset ( hipDevice_t  dev)

Resets the primary context on the GPU.

Parameters
[in]devDevice which primary context is reset
Returns
hipSuccess
See also
hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice

◆ hipDevicePrimaryCtxRetain()

hipError_t hipDevicePrimaryCtxRetain ( hipCtx_t pctx,
hipDevice_t  dev 
)

Retain the primary context on the GPU.

hipError_t hipDevicePrimaryCtxRetain(hipCtx_t* pctx, hipDevice_t dev);

Parameters
[out]pctxReturned context handle of the new context
[in]devDevice which primary context is released
Returns
hipSuccess
See also
hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice

◆ hipDevicePrimaryCtxSetFlags()

hipError_t hipDevicePrimaryCtxSetFlags ( hipDevice_t  dev,
unsigned int  flags 
)

Set flags for the primary context.

Parameters
[in]devDevice for which the primary context flags are set
[in]flagsNew flags for the device
Returns
hipSuccess, hipErrorContextAlreadyInUse
See also
hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice