6.9. 上下文管理 [已弃用]

本节介绍低级别CUDA驱动程序应用程序编程接口中已弃用的上下文管理函数。

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.

Functions

CUresult cuCtxAttach ( CUcontext* pctx, unsigned int  flags )
增加上下文的引用计数。
参数
pctx
- Returned context handle of the current context
flags
- Context attach flags (must be 0)
已弃用

请注意,此函数已弃用,不应再使用。

描述

增加上下文的引用计数,并在*pctx中返回一个上下文句柄,该句柄必须在应用程序完成上下文处理后传递给cuCtxDetach()。如果线程当前没有上下文,cuCtxAttach()将执行失败。

目前,flags参数必须设为0。

Note:

请注意,此函数也可能返回之前异步启动的错误代码。

另请参阅:

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

CUresult cuCtxDetach ( CUcontext ctx )
减少上下文的引用计数。
参数
ctx
- Context to destroy
已弃用

请注意,此函数已弃用,不应继续使用。

描述

减少上下文ctx的使用计数,如果使用计数降为0则销毁该上下文。该上下文必须是由cuCtxCreate()cuCtxAttach()返回的句柄,且必须是调用线程的当前上下文。

Note:

请注意,此函数也可能返回之前异步启动的错误代码。

另请参阅:

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

CUresult cuCtxGetSharedMemConfig ( CUsharedconfig* pConfig )
返回当前上下文的共享内存配置。
参数
pConfig
- returned shared memory configuration
已弃用

描述
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.

返回的银行配置可以是以下之一:

Note:

请注意,此函数也可能返回之前异步启动的错误代码。

另请参阅:

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

CUresult cuCtxSetSharedMemConfig ( CUsharedconfig config )
为当前上下文设置共享内存配置。
参数
config
- requested shared memory configuration
已弃用

描述
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.

在两次启动之间更改共享内存配置可能会在这两次启动之间插入一个设备端的同步点。

更改共享内存的存储体大小不会增加共享内存的使用量或影响内核的占用率,但可能会对性能产生重大影响。较大的存储体大小可以带来更高的共享内存潜在带宽,但会改变哪些类型的共享内存访问会导致存储体冲突。

此函数在具有固定共享内存库大小的设备上将不执行任何操作。

支持的银行配置包括:

Note:

请注意,此函数也可能返回之前异步启动的错误代码。

另请参阅:

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