6.3. Context Management [DEPRECATED]

This section describes the deprecated context management functions of the low-level CUDA driver application programming interface.

Functions

CUresult cuCtxAttach(CUcontext *pctx, unsigned int flags)

Increment a context's usage-count.

CUresult cuCtxDetach(CUcontext ctx)

Decrement a context's usage-count.

CUresult cuCtxGetSharedMemConfig(CUsharedconfig *pConfig)

Returns the current shared memory configuration for the current context.

CUresult cuCtxSetSharedMemConfig(CUsharedconfig config)

Sets the shared memory configuration for the current context.

6.3.1. Functions

CUresult cuCtxAttach(CUcontext *pctx, unsigned int flags)

Increment a context’s usage-count.

Deprecated:

Note that this function is deprecated and should not be used.

Increments the usage count of the context and passes back a context handle in *pctx that must be passed to cuCtxDetach() when the application is done with the context. cuCtxAttach() fails if there is no context current to the thread.

Currently, the flags parameter must be 0.

Note

Note that this function may also return error codes from previous, asynchronous launches.

Parameters
  • pctx – - Returned context handle of the current context

  • flags – - Context attach flags (must be 0)

Returns

CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE

CUresult cuCtxDetach(CUcontext ctx)

Decrement a context’s usage-count.

Deprecated:

Note that this function is deprecated and should not be used.

Decrements the usage count of the context ctx, and destroys the context if the usage count goes to 0. The context must be a handle that was passed back by cuCtxCreate() or cuCtxAttach(), and must be current to the calling thread.

See also

cuCtxCreate, cuCtxDestroy, cuCtxGetApiVersion, cuCtxGetCacheConfig, cuCtxGetDevice, cuCtxGetFlags, cuCtxGetLimit, cuCtxPopCurrent, cuCtxPushCurrent, cuCtxSetCacheConfig, cuCtxSetLimit, cuCtxSynchronize

Note

Note that this function may also return error codes from previous, asynchronous launches.

Parameters

ctx – - Context to destroy

Returns

CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT

CUresult cuCtxGetSharedMemConfig(CUsharedconfig *pConfig)

Returns the current shared memory configuration for the current context.

Deprecated:

This function will return in pConfig the current size of shared memory banks in the current context. On devices with configurable shared memory banks, cuCtxSetSharedMemConfig can be used to change this setting, so that all subsequent kernel launches will by default use the new bank size. When cuCtxGetSharedMemConfig is called on devices without configurable shared memory, it will return the fixed bank size of the hardware.

The returned bank configurations can be either:

See also

cuCtxCreate, cuCtxDestroy, cuCtxGetApiVersion, cuCtxGetCacheConfig, cuCtxGetDevice, cuCtxGetFlags, cuCtxGetLimit, cuCtxPopCurrent, cuCtxPushCurrent, cuCtxSetLimit, cuCtxSynchronize, cuCtxGetSharedMemConfig, cuFuncSetCacheConfig, ::cudaDeviceGetSharedMemConfig

Note

Note that this function may also return error codes from previous, asynchronous launches.

Parameters

pConfig – - returned shared memory configuration

Returns

CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE

CUresult cuCtxSetSharedMemConfig(CUsharedconfig config)

Sets the shared memory configuration for the current context.

Deprecated:

On devices with configurable shared memory banks, this function will set the context’s shared memory bank size which is used for subsequent kernel launches.

Changed the shared memory configuration between launches may insert a device side synchronization point between those launches.

Changing the shared memory bank size will not increase shared memory usage or affect occupancy of kernels, but may have major effects on performance. Larger bank sizes will allow for greater potential bandwidth to shared memory, but will change what kinds of accesses to shared memory will result in bank conflicts.

This function will do nothing on devices with fixed shared memory bank size.

The supported bank configurations are:

See also

cuCtxCreate, cuCtxDestroy, cuCtxGetApiVersion, cuCtxGetCacheConfig, cuCtxGetDevice, cuCtxGetFlags, cuCtxGetLimit, cuCtxPopCurrent, cuCtxPushCurrent, cuCtxSetLimit, cuCtxSynchronize, cuCtxGetSharedMemConfig, cuFuncSetCacheConfig, ::cudaDeviceSetSharedMemConfig

Note

Note that this function may also return error codes from previous, asynchronous launches.

Parameters

config – - requested shared memory configuration

Returns

CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE