6.30. 图管理

本节介绍CUDA运行时应用程序编程接口的图管理功能。

Functions

__host__cudaError_t cudaDeviceGetGraphMemAttribute ( int  device, cudaGraphMemAttributeType attr, void* value )
Query asynchronous allocation attributes related to graphs.
__host__cudaError_t cudaDeviceGraphMemTrim ( int  device )
Free unused memory that was cached on the specified device for use with graphs back to the OS.
__host__cudaError_t cudaDeviceSetGraphMemAttribute ( int  device, cudaGraphMemAttributeType attr, void* value )
Set asynchronous allocation attributes related to graphs.
__device__cudaGraphExec_t cudaGetCurrentGraphExec ( void )
Get the currently running device graph id.
__host__cudaError_t cudaGraphAddChildGraphNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaGraph_t childGraph )
Creates a child graph node and adds it to a graph.
__host__cudaError_t cudaGraphAddDependencies ( cudaGraph_t graph, const cudaGraphNode_t* from, const cudaGraphNode_t* to, size_t numDependencies )
Adds dependency edges to a graph.
__host__cudaError_t cudaGraphAddDependencies_v2 ( cudaGraph_t graph, const cudaGraphNode_t* from, const cudaGraphNode_t* to, const cudaGraphEdgeData* edgeData, size_t numDependencies )
Adds dependency edges to a graph. (12.3+).
__host__cudaError_t cudaGraphAddEmptyNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies )
Creates an empty node and adds it to a graph.
__host__cudaError_t cudaGraphAddEventRecordNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaEvent_t event )
Creates an event record node and adds it to a graph.
__host__cudaError_t cudaGraphAddEventWaitNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaEvent_t event )
Creates an event wait node and adds it to a graph.
__host__cudaError_t cudaGraphAddExternalSemaphoresSignalNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaExternalSemaphoreSignalNodeParams* nodeParams )
Creates an external semaphore signal node and adds it to a graph.
__host__cudaError_t cudaGraphAddExternalSemaphoresWaitNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaExternalSemaphoreWaitNodeParams* nodeParams )
Creates an external semaphore wait node and adds it to a graph.
__host__cudaError_t cudaGraphAddHostNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaHostNodeParams* pNodeParams )
Creates a host execution node and adds it to a graph.
__host__cudaError_t cudaGraphAddKernelNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaKernelNodeParams* pNodeParams )
Creates a kernel execution node and adds it to a graph.
__host__cudaError_t cudaGraphAddMemAllocNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaMemAllocNodeParams* nodeParams )
Creates an allocation node and adds it to a graph.
__host__cudaError_t cudaGraphAddMemFreeNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, void* dptr )
Creates a memory free node and adds it to a graph.
__host__cudaError_t cudaGraphAddMemcpyNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaMemcpy3DParms* pCopyParams )
Creates a memcpy node and adds it to a graph.
__host__cudaError_t cudaGraphAddMemcpyNode1D ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, void* dst, const void* src, size_t count, cudaMemcpyKind kind )
Creates a 1D memcpy node and adds it to a graph.
__host__cudaError_t cudaGraphAddMemcpyNodeFromSymbol ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, void* dst, const void* symbol, size_t count, size_t offset, cudaMemcpyKind kind )
Creates a memcpy node to copy from a symbol on the device and adds it to a graph.
__host__cudaError_t cudaGraphAddMemcpyNodeToSymbol ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const void* symbol, const void* src, size_t count, size_t offset, cudaMemcpyKind kind )
Creates a memcpy node to copy to a symbol on the device and adds it to a graph.
__host__cudaError_t cudaGraphAddMemsetNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaMemsetParams* pMemsetParams )
Creates a memset node and adds it to a graph.
__host__cudaError_t cudaGraphAddNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaGraphNodeParams* nodeParams )
Adds a node of arbitrary type to a graph.
__host__cudaError_t cudaGraphAddNode_v2 ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, const cudaGraphEdgeData* dependencyData, size_t numDependencies, cudaGraphNodeParams* nodeParams )
Adds a node of arbitrary type to a graph (12.3+).
__host__cudaError_t cudaGraphChildGraphNodeGetGraph ( cudaGraphNode_t node, cudaGraph_t* pGraph )
Gets a handle to the embedded graph of a child graph node.
__host__cudaError_t cudaGraphClone ( cudaGraph_t* pGraphClone, cudaGraph_t originalGraph )
Clones a graph.
__host__cudaError_t cudaGraphConditionalHandleCreate ( cudaGraphConditionalHandle* pHandle_out, cudaGraph_t graph, unsigned int  defaultLaunchValue = 0, unsigned int  flags = 0 )
Create a conditional handle.
__host__cudaError_t cudaGraphCreate ( cudaGraph_t* pGraph, unsigned int  flags )
Creates a graph.
__host__cudaError_t cudaGraphDebugDotPrint ( cudaGraph_t graph, const char* path, unsigned int  flags )
Write a DOT file describing graph structure.
__host__cudaError_t cudaGraphDestroy ( cudaGraph_t graph )
Destroys a graph.
__host__cudaError_t cudaGraphDestroyNode ( cudaGraphNode_t node )
Remove a node from the graph.
__host__cudaError_t cudaGraphEventRecordNodeGetEvent ( cudaGraphNode_t node, cudaEvent_t* event_out )
Returns the event associated with an event record node.
__host__cudaError_t cudaGraphEventRecordNodeSetEvent ( cudaGraphNode_t node, cudaEvent_t event )
Sets an event record node's event.
__host__cudaError_t cudaGraphEventWaitNodeGetEvent ( cudaGraphNode_t node, cudaEvent_t* event_out )
Returns the event associated with an event wait node.
__host__cudaError_t cudaGraphEventWaitNodeSetEvent ( cudaGraphNode_t node, cudaEvent_t event )
Sets an event wait node's event.
__host__cudaError_t cudaGraphExecChildGraphNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, cudaGraph_t childGraph )
Updates node parameters in the child graph node in the given graphExec.
__host__cudaError_t cudaGraphExecDestroy ( cudaGraphExec_t graphExec )
Destroys an executable graph.
__host__cudaError_t cudaGraphExecEventRecordNodeSetEvent ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, cudaEvent_t event )
Sets the event for an event record node in the given graphExec.
__host__cudaError_t cudaGraphExecEventWaitNodeSetEvent ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, cudaEvent_t event )
Sets the event for an event wait node in the given graphExec.
__host__cudaError_t cudaGraphExecExternalSemaphoresSignalNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, const cudaExternalSemaphoreSignalNodeParams* nodeParams )
Sets the parameters for an external semaphore signal node in the given graphExec.
__host__cudaError_t cudaGraphExecExternalSemaphoresWaitNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, const cudaExternalSemaphoreWaitNodeParams* nodeParams )
Sets the parameters for an external semaphore wait node in the given graphExec.
__host__cudaError_t cudaGraphExecGetFlags ( cudaGraphExec_t graphExec, unsigned long long* flags )
Query the instantiation flags of an executable graph.
__host__cudaError_t cudaGraphExecHostNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaHostNodeParams* pNodeParams )
Sets the parameters for a host node in the given graphExec.
__host__cudaError_t cudaGraphExecKernelNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaKernelNodeParams* pNodeParams )
Sets the parameters for a kernel node in the given graphExec.
__host__cudaError_t cudaGraphExecMemcpyNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaMemcpy3DParms* pNodeParams )
Sets the parameters for a memcpy node in the given graphExec.
__host__cudaError_t cudaGraphExecMemcpyNodeSetParams1D ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, void* dst, const void* src, size_t count, cudaMemcpyKind kind )
Sets the parameters for a memcpy node in the given graphExec to perform a 1-dimensional copy.
__host__cudaError_t cudaGraphExecMemcpyNodeSetParamsFromSymbol ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, void* dst, const void* symbol, size_t count, size_t offset, cudaMemcpyKind kind )
Sets the parameters for a memcpy node in the given graphExec to copy from a symbol on the device.
__host__cudaError_t cudaGraphExecMemcpyNodeSetParamsToSymbol ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const void* symbol, const void* src, size_t count, size_t offset, cudaMemcpyKind kind )
Sets the parameters for a memcpy node in the given graphExec to copy to a symbol on the device.
__host__cudaError_t cudaGraphExecMemsetNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaMemsetParams* pNodeParams )
Sets the parameters for a memset node in the given graphExec.
__host__cudaError_t cudaGraphExecNodeSetParams ( cudaGraphExec_t graphExec, cudaGraphNode_t node, cudaGraphNodeParams* nodeParams )
Update's a graph node's parameters in an instantiated graph.
__host__cudaError_t cudaGraphExecUpdate ( cudaGraphExec_t hGraphExec, cudaGraph_t hGraph, cudaGraphExecUpdateResultInfo* resultInfo )
Check whether an executable graph can be updated with a graph and perform the update if possible.
__host__cudaError_t cudaGraphExternalSemaphoresSignalNodeGetParams ( cudaGraphNode_t hNode, cudaExternalSemaphoreSignalNodeParams* params_out )
Returns an external semaphore signal node's parameters.
__host__cudaError_t cudaGraphExternalSemaphoresSignalNodeSetParams ( cudaGraphNode_t hNode, const cudaExternalSemaphoreSignalNodeParams* nodeParams )
Sets an external semaphore signal node's parameters.
__host__cudaError_t cudaGraphExternalSemaphoresWaitNodeGetParams ( cudaGraphNode_t hNode, cudaExternalSemaphoreWaitNodeParams* params_out )
Returns an external semaphore wait node's parameters.
__host__cudaError_t cudaGraphExternalSemaphoresWaitNodeSetParams ( cudaGraphNode_t hNode, const cudaExternalSemaphoreWaitNodeParams* nodeParams )
Sets an external semaphore wait node's parameters.
__host__cudaError_t cudaGraphGetEdges ( cudaGraph_t graph, cudaGraphNode_t* from, cudaGraphNode_t* to, size_t* numEdges )
Returns a graph's dependency edges.
__host__cudaError_t cudaGraphGetEdges_v2 ( cudaGraph_t graph, cudaGraphNode_t* from, cudaGraphNode_t* to, cudaGraphEdgeData* edgeData, size_t* numEdges )
Returns a graph's dependency edges (12.3+).
__host__cudaError_t cudaGraphGetNodes ( cudaGraph_t graph, cudaGraphNode_t* nodes, size_t* numNodes )
Returns a graph's nodes.
__host__cudaError_t cudaGraphGetRootNodes ( cudaGraph_t graph, cudaGraphNode_t* pRootNodes, size_t* pNumRootNodes )
Returns a graph's root nodes.
__host__cudaError_t cudaGraphHostNodeGetParams ( cudaGraphNode_t node, cudaHostNodeParams* pNodeParams )
Returns a host node's parameters.
__host__cudaError_t cudaGraphHostNodeSetParams ( cudaGraphNode_t node, const cudaHostNodeParams* pNodeParams )
Sets a host node's parameters.
__host__cudaError_t cudaGraphInstantiate ( cudaGraphExec_t* pGraphExec, cudaGraph_t graph, unsigned long long flags = 0 )
Creates an executable graph from a graph.
__host__cudaError_t cudaGraphInstantiateWithFlags ( cudaGraphExec_t* pGraphExec, cudaGraph_t graph, unsigned long long flags = 0 )
Creates an executable graph from a graph.
__host__cudaError_t cudaGraphInstantiateWithParams ( cudaGraphExec_t* pGraphExec, cudaGraph_t graph, cudaGraphInstantiateParams* instantiateParams )
Creates an executable graph from a graph.
__host__cudaError_t cudaGraphKernelNodeCopyAttributes ( cudaGraphNode_t hSrc, cudaGraphNode_t hDst )
Copies attributes from source node to destination node.
__host__cudaError_t cudaGraphKernelNodeGetAttribute ( cudaGraphNode_t hNode, cudaKernelNodeAttrID attr, cudaKernelNodeAttrValue* value_out )
Queries node attribute.
__host__cudaError_t cudaGraphKernelNodeGetParams ( cudaGraphNode_t node, cudaKernelNodeParams* pNodeParams )
Returns a kernel node's parameters.
__host__cudaError_t cudaGraphKernelNodeSetAttribute ( cudaGraphNode_t hNode, cudaKernelNodeAttrID attr, const cudaKernelNodeAttrValue* value )
Sets node attribute.
__device__cudaError_t cudaGraphKernelNodeSetEnabled ( cudaGraphDeviceNode_t node, bool  enable )
Enables or disables the given kernel node.
__device__cudaError_t cudaGraphKernelNodeSetGridDim ( cudaGraphDeviceNode_t node, dim3 gridDim )
Updates the grid dimensions of the given kernel node.
template < typename T >__device__cudaError_t cudaGraphKernelNodeSetParam ( cudaGraphDeviceNode_t node, size_t offset, const T& value )
Updates the kernel parameters of the given kernel node.
__device__cudaError_t cudaGraphKernelNodeSetParam ( cudaGraphDeviceNode_t node, size_t offset, const void* value, size_t size )
Updates the kernel parameters of the given kernel node.
__host__cudaError_t cudaGraphKernelNodeSetParams ( cudaGraphNode_t node, const cudaKernelNodeParams* pNodeParams )
Sets a kernel node's parameters.
__device__cudaError_t cudaGraphKernelNodeUpdatesApply ( const cudaGraphKernelNodeUpdate* updates, size_t updateCount )
Batch applies multiple kernel node updates.
__host____device__cudaError_t cudaGraphLaunch ( cudaGraphExec_t graphExec, cudaStream_t stream )
Launches an executable graph in a stream.
__host__cudaError_t cudaGraphMemAllocNodeGetParams ( cudaGraphNode_t node, cudaMemAllocNodeParams* params_out )
Returns a memory alloc node's parameters.
__host__cudaError_t cudaGraphMemFreeNodeGetParams ( cudaGraphNode_t node, void* dptr_out )
Returns a memory free node's parameters.
__host__cudaError_t cudaGraphMemcpyNodeGetParams ( cudaGraphNode_t node, cudaMemcpy3DParms* pNodeParams )
Returns a memcpy node's parameters.
__host__cudaError_t cudaGraphMemcpyNodeSetParams ( cudaGraphNode_t node, const cudaMemcpy3DParms* pNodeParams )
Sets a memcpy node's parameters.
__host__cudaError_t cudaGraphMemcpyNodeSetParams1D ( cudaGraphNode_t node, void* dst, const void* src, size_t count, cudaMemcpyKind kind )
Sets a memcpy node's parameters to perform a 1-dimensional copy.
__host__cudaError_t cudaGraphMemcpyNodeSetParamsFromSymbol ( cudaGraphNode_t node, void* dst, const void* symbol, size_t count, size_t offset, cudaMemcpyKind kind )
Sets a memcpy node's parameters to copy from a symbol on the device.
__host__cudaError_t cudaGraphMemcpyNodeSetParamsToSymbol ( cudaGraphNode_t node, const void* symbol, const void* src, size_t count, size_t offset, cudaMemcpyKind kind )
Sets a memcpy node's parameters to copy to a symbol on the device.
__host__cudaError_t cudaGraphMemsetNodeGetParams ( cudaGraphNode_t node, cudaMemsetParams* pNodeParams )
Returns a memset node's parameters.
__host__cudaError_t cudaGraphMemsetNodeSetParams ( cudaGraphNode_t node, const cudaMemsetParams* pNodeParams )
Sets a memset node's parameters.
__host__cudaError_t cudaGraphNodeFindInClone ( cudaGraphNode_t* pNode, cudaGraphNode_t originalNode, cudaGraph_t clonedGraph )
Finds a cloned version of a node.
__host__cudaError_t cudaGraphNodeGetDependencies ( cudaGraphNode_t node, cudaGraphNode_t* pDependencies, size_t* pNumDependencies )
Returns a node's dependencies.
__host__cudaError_t cudaGraphNodeGetDependencies_v2 ( cudaGraphNode_t node, cudaGraphNode_t* pDependencies, cudaGraphEdgeData* edgeData, size_t* pNumDependencies )
Returns a node's dependencies (12.3+).
__host__cudaError_t cudaGraphNodeGetDependentNodes ( cudaGraphNode_t node, cudaGraphNode_t* pDependentNodes, size_t* pNumDependentNodes )
Returns a node's dependent nodes.
__host__cudaError_t cudaGraphNodeGetDependentNodes_v2 ( cudaGraphNode_t node, cudaGraphNode_t* pDependentNodes, cudaGraphEdgeData* edgeData, size_t* pNumDependentNodes )
Returns a node's dependent nodes (12.3+).
__host__cudaError_t cudaGraphNodeGetEnabled ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, unsigned int* isEnabled )
Query whether a node in the given graphExec is enabled.
__host__cudaError_t cudaGraphNodeGetType ( cudaGraphNode_t node, cudaGraphNodeType ** pType )
Returns a node's type.
__host__cudaError_t cudaGraphNodeSetEnabled ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, unsigned int  isEnabled )
Enables or disables the specified node in the given graphExec.
__host__cudaError_t cudaGraphNodeSetParams ( cudaGraphNode_t node, cudaGraphNodeParams* nodeParams )
Update's a graph node's parameters.
__host__cudaError_t cudaGraphReleaseUserObject ( cudaGraph_t graph, cudaUserObject_t object, unsigned int  count = 1 )
Release a user object reference from a graph.
__host__cudaError_t cudaGraphRemoveDependencies ( cudaGraph_t graph, const cudaGraphNode_t* from, const cudaGraphNode_t* to, size_t numDependencies )
Removes dependency edges from a graph.
__host__cudaError_t cudaGraphRemoveDependencies_v2 ( cudaGraph_t graph, const cudaGraphNode_t* from, const cudaGraphNode_t* to, const cudaGraphEdgeData* edgeData, size_t numDependencies )
Removes dependency edges from a graph. (12.3+).
__host__cudaError_t cudaGraphRetainUserObject ( cudaGraph_t graph, cudaUserObject_t object, unsigned int  count = 1, unsigned int  flags = 0 )
Retain a reference to a user object from a graph.
__device__ ​ void cudaGraphSetConditional ( cudaGraphConditionalHandle handle, unsigned int  value )
Sets the condition value associated with a conditional node.
__host__cudaError_t cudaGraphUpload ( cudaGraphExec_t graphExec, cudaStream_t stream )
Uploads an executable graph in a stream.
__host__cudaError_t cudaUserObjectCreate ( cudaUserObject_t* object_out, void* ptr, cudaHostFn_t destroy, unsigned int  initialRefcount, unsigned int  flags )
Create a user object.
__host__cudaError_t cudaUserObjectRelease ( cudaUserObject_t object, unsigned int  count = 1 )
Release a reference to a user object.
__host__cudaError_t cudaUserObjectRetain ( cudaUserObject_t object, unsigned int  count = 1 )
Retain a reference to a user object.

Functions

__host__cudaError_t cudaDeviceGetGraphMemAttribute ( int  device, cudaGraphMemAttributeType attr, void* value )
查询与图相关的异步分配属性。
参数
device
- Specifies the scope of the query
attr
- attribute to get
value
- retrieved value
描述

有效属性包括:

Note:

另请参阅:

cudaDeviceSetGraphMemAttribute, cudaGraphAddMemAllocNode, cudaGraphAddMemFreeNode, cudaDeviceGraphMemTrim, cudaMallocAsync, cudaFreeAsync

__host__cudaError_t cudaDeviceGraphMemTrim ( int  device )
释放指定设备上缓存的未使用内存,将其归还给操作系统以供图形处理使用。
参数
device
- The device for which cached memory should be freed.
描述

当前未在执行或计划执行的图形所不使用的块会被释放回操作系统。

Note:

另请参阅:

cudaGraphAddMemAllocNode, cudaGraphAddMemFreeNode, cudaDeviceGetGraphMemAttribute, cudaDeviceSetGraphMemAttribute, cudaMallocAsync, cudaFreeAsync

__host__cudaError_t cudaDeviceSetGraphMemAttribute ( int  device, cudaGraphMemAttributeType attr, void* value )
设置与图形相关的异步分配属性。
参数
device
- Specifies the scope of the query
attr
- attribute to get
value
- pointer to value to set
描述

有效属性包括:

Note:

另请参阅:

cudaDeviceGetGraphMemAttribute, cudaGraphAddMemAllocNode, cudaGraphAddMemFreeNode, cudaDeviceGraphMemTrim, cudaMallocAsync, cudaFreeAsync

__device__cudaGraphExec_t cudaGetCurrentGraphExec ( void ) [inline]
获取当前运行的设备图ID。
返回

返回当前设备图的ID,如果调用发生在设备图外部则返回0。

描述

获取当前运行的设备图ID。

另请参阅:

cudaGraphLaunch

__host__cudaError_t cudaGraphAddChildGraphNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaGraph_t childGraph )
创建一个子图节点并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
childGraph
- The graph to clone into this node
描述

创建一个新节点用于执行嵌入式图,并通过pDependencies指定的numDependencies个依赖项将其添加到graph中。当numDependencies为0时,该节点将被放置在图的根位置。pDependencies中不能包含重复条目。新节点的句柄将通过pGraphNode返回。

如果hGraph包含分配或释放节点,此调用将返回错误。

该节点执行一个嵌入的子图。在此调用中会克隆子图。

Note:

另请参阅:

cudaGraphAddNode, cudaGraphChildGraphNodeGetGraph, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddHostNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode, cudaGraphClone

__host__cudaError_t cudaGraphAddDependencies ( cudaGraph_t graph, const cudaGraphNode_t* from, const cudaGraphNode_t* to, size_t numDependencies )
向图中添加依赖边。
参数
graph
- Graph to which dependencies are added
from
- Array of nodes that provide the dependencies
to
- Array of dependent nodes
numDependencies
- Number of dependencies to be added
描述

要添加的依赖项数量由numDependencies定义。pFrompTo中对应索引的元素定义一个依赖关系。pFrompTo中的每个节点都必须属于graph

如果numDependencies为0,则pFrompTo中的元素将被忽略。指定已存在的依赖项将返回错误。

Note:

另请参阅:

cudaGraphRemoveDependencies, cudaGraphGetEdges, cudaGraphNodeGetDependencies, cudaGraphNodeGetDependentNodes

__host__cudaError_t cudaGraphAddDependencies_v2 ( cudaGraph_t graph, const cudaGraphNode_t* from, const cudaGraphNode_t* to, const cudaGraphEdgeData* edgeData, size_t numDependencies )
向图中添加依赖边。(12.3+版本)
参数
graph
- Graph to which dependencies are added
from
- Array of nodes that provide the dependencies
to
- Array of dependent nodes
edgeData
- Optional array of edge data. If NULL, default (zeroed) edge data is assumed.
numDependencies
- Number of dependencies to be added
描述

要添加的依赖项数量由numDependencies定义。pFrompTo中对应索引位置的元素定义一个依赖项。pFrompTo中的每个节点都必须属于graph

如果numDependencies为0,则pFrompTo中的元素将被忽略。指定已存在的依赖项将返回错误。

Note:

另请参阅:

cudaGraphRemoveDependencies, cudaGraphGetEdges, cudaGraphNodeGetDependencies, cudaGraphNodeGetDependentNodes

__host__cudaError_t cudaGraphAddEmptyNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies )
创建一个空节点并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
描述

创建一个不执行任何操作的新节点,并通过pDependencies指定的numDependencies个依赖项将其添加到graph中。numDependencies可以为0,此时该节点将被放置在图的根位置。pDependencies不能包含任何重复条目。新节点的句柄将在pGraphNode中返回。

空节点在执行期间不执行任何操作,但可用于传递顺序。例如,一个包含两组各n个节点且中间有屏障的分阶段执行图,可以使用一个空节点和2*n条依赖边来表示,而不是不使用空节点而需要n^2条依赖边。

Note:

另请参阅:

cudaGraphAddNode, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddKernelNode, cudaGraphAddHostNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddEventRecordNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaEvent_t event )
创建一个事件记录节点并将其添加到图中。
参数
pGraphNode
graph
pDependencies
numDependencies
- Number of dependencies
event
- Event for the node
描述

创建一个新的事件记录节点,并将其添加到hGraph中,通过dependencies指定numDependencies个依赖项,并通过event指定事件。当numDependencies为0时,该节点将被放置在图的根位置。dependencies中不能有任何重复条目。新节点的句柄将通过phGraphNode返回。

每次启动图形时都会记录event以捕获节点依赖项的执行情况。

这些节点不能在循环或条件语句中使用。

Note:

另请参阅:

cudaGraphAddNode, cudaGraphAddEventWaitNode, cudaEventRecordWithFlags, cudaStreamWaitEvent, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddEventWaitNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaEvent_t event )
创建一个事件等待节点并将其添加到图中。
参数
pGraphNode
graph
pDependencies
numDependencies
- Number of dependencies
event
- Event for the node
描述

创建一个新的事件等待节点,并将其添加到hGraph中,通过dependencies指定numDependencies个依赖项,并在event中指定事件。numDependencies可以为0,此时该节点将被放置在图的根位置。dependencies中不能有任何重复条目。新节点的句柄将在phGraphNode中返回。

图节点将等待event中捕获的所有工作完成。关于事件捕获内容的详细信息,请参阅cuEventRecord()。在适用情况下,设备将高效执行同步操作。 event可以来自与启动流不同的上下文或设备。

这些节点不能在循环或条件语句中使用。

Note:

另请参阅:

cudaGraphAddNode, cudaGraphAddEventRecordNode, cudaEventRecordWithFlags, cudaStreamWaitEvent, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddExternalSemaphoresSignalNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaExternalSemaphoreSignalNodeParams* nodeParams )
创建一个外部信号量信号节点并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
nodeParams
- Parameters for the node
描述

创建一个新的外部信号量信号节点,并通过dependencies指定的numDependencies个依赖项以及nodeParams中指定的参数将其添加到graph中。numDependencies可以为0,此时该节点将被放置在图的根位置。dependencies中不能有任何重复条目。新节点的句柄将在pGraphNode中返回。

在节点启动时对一组外部分配的信号量对象执行信号操作。该操作将在节点的所有依赖项完成后进行。

Note:

另请参阅:

cudaGraphAddNode, cudaGraphExternalSemaphoresSignalNodeGetParams, cudaGraphExternalSemaphoresSignalNodeSetParams, cudaGraphExecExternalSemaphoresSignalNodeSetParams, cudaGraphAddExternalSemaphoresWaitNode, cudaImportExternalSemaphore, cudaSignalExternalSemaphoresAsync, cudaWaitExternalSemaphoresAsync, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddEventRecordNode, cudaGraphAddEventWaitNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddExternalSemaphoresWaitNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaExternalSemaphoreWaitNodeParams* nodeParams )
创建一个外部信号量等待节点并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
nodeParams
- Parameters for the node
描述

创建一个新的外部信号量等待节点,并通过dependencies指定的numDependencies个依赖项以及nodeParams中指定的参数将其添加到graph中。numDependencies可以为0,在这种情况下该节点将被放置在图的根位置。dependencies中不能有任何重复条目。新节点的句柄将在pGraphNode中返回。

在节点启动时对一组外部分配的信号量对象执行等待操作。在等待操作完成之前,不会启动该节点的依赖项。

Note:

另请参阅:

cudaGraphAddNode, cudaGraphExternalSemaphoresWaitNodeGetParams, cudaGraphExternalSemaphoresWaitNodeSetParams, cudaGraphExecExternalSemaphoresWaitNodeSetParams, cudaGraphAddExternalSemaphoresSignalNode, cudaImportExternalSemaphore, cudaSignalExternalSemaphoresAsync, cudaWaitExternalSemaphoresAsync, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddEventRecordNode, cudaGraphAddEventWaitNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddHostNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaHostNodeParams* pNodeParams )
创建一个主机执行节点并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
pNodeParams
- Parameters for the host node
描述

创建一个新的CPU执行节点,并通过pDependencies指定的numDependencies个依赖项以及pNodeParams中指定的参数将其添加到graph中。numDependencies可以为0,此时该节点将被放置在图的根位置。pDependencies中不能有任何重复条目。新节点的句柄将在pGraphNode中返回。

当图启动时,该节点将调用指定的CPU函数。在MPS环境下,使用Volta之前的GPU不支持主机节点。

Note:

另请参阅:

cudaGraphAddNode, cudaLaunchHostFunc, cudaGraphHostNodeGetParams, cudaGraphHostNodeSetParams, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddKernelNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaKernelNodeParams* pNodeParams )
创建一个内核执行节点并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
pNodeParams
- Parameters for the GPU execution node
描述

创建一个新的内核执行节点,并通过pDependencies指定的numDependencies个依赖项以及pNodeParams中指定的参数将其添加到graph中。numDependencies可以为0,此时该节点将被放置在图的根位置。pDependencies中不能有任何重复条目。新节点的句柄将在pGraphNode中返回。

cudaKernelNodeParams 结构体定义为:

‎  struct cudaKernelNodeParams
        {
            void* func;
            dim3 gridDim;
            dim3 blockDim;
            unsigned int sharedMemBytes;
            void **kernelParams;
            void **extra;
        };

当图形启动时,节点将在(gridDim.x x gridDim.y x gridDim.z)的块网格上调用内核func。每个块包含(blockDim.x x blockDim.y x blockDim.z)个线程。

sharedMem 设置每个线程块可用的动态共享内存量。

可以通过以下两种方式之一指定func的内核参数:

1) 内核参数可以通过kernelParams指定。如果内核有N个参数,那么kernelParams需要是一个包含N个指针的数组。每个指针,从kernelParams[0]到kernelParams[N-1],指向内存中实际参数将被复制的区域。内核参数的数量及其偏移量和大小不需要特别指定,因为这些信息可以直接从内核映像中获取。

2) 内核参数也可以由应用程序打包到单个缓冲区中,通过extra传递。这要求应用程序了解每个内核参数在缓冲区中的大小和对齐/填充方式。 extra参数的存在允许此函数接收其他不太常用的参数。extra指定了一个额外设置名称及其对应值的列表。每个额外设置名称后面必须紧跟对应的值。该列表必须以NULL或CU_LAUNCH_PARAM_END终止。

如果同时使用kernelParamsextra指定内核参数(即kernelParamsextra都不为NULL),将返回错误cudaErrorInvalidValue

kernelParamsextra 数组以及它们所指向的参数值,在此调用过程中会被复制。

Note:

使用图形启动的内核不得使用纹理和表面引用。通过任何纹理或表面引用进行读写是未定义行为。此限制不适用于纹理和表面对象。

Note:

另请参阅:

cudaGraphAddNode, cudaLaunchKernel, cudaGraphKernelNodeGetParams, cudaGraphKernelNodeSetParams, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddHostNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddMemAllocNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaMemAllocNodeParams* nodeParams )
创建一个分配节点并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
nodeParams
- Parameters for the node
描述

创建一个新的分配节点,并通过pDependencies指定的numDependencies个依赖项以及nodeParams中指定的参数将其添加到graph中。numDependencies可以为0,此时该节点将被放置在图的根位置。pDependencies中不能有任何重复条目。新节点的句柄将在pGraphNode中返回。

cudaGraphAddMemAllocNode创建分配节点时,它会在nodeParams.dptr中返回分配的地址。该分配的地址在实例化和启动过程中保持固定。

如果在同一个图中通过使用cudaGraphAddMemFreeNode创建释放节点来释放分配的内存,则该分配的内存可以被排序在分配节点之后但在释放节点之前的节点访问。这些分配的内存不能在所属图之外释放,并且它们在所属图中只能被释放一次。

如果分配未在同一图中释放,则不仅图中排序在分配节点之后的节点可以访问它,在图形执行之后但在分配释放之前排序的流操作也可以访问它。

未在同一图中释放的分配可以通过以下方式释放:

  • 将分配传递给cudaMemFreeAsync或cudaMemFree;

  • 启动一个带有空闲节点的图以进行该分配;或者

  • 在实例化时指定cudaGraphInstantiateFlagAutoFreeOnLaunch,这会使每次启动的行为就像为每个未释放的分配调用了cudaMemFreeAsync一样。

无法同时在所属图和其他图中释放分配。如果在同一图中释放分配,则无法将释放节点添加到其他图中。如果在其他图中释放分配,则无法再将释放节点添加到所属图中。

以下限制适用于包含分配和/或内存释放节点的图:

  • 图的节点和边不能被删除。

  • 该图无法在子节点中使用。

  • 在任何时间点,只能存在一个图的实例。

  • 该图无法被克隆。

Note:
  • 图形对象不是线程安全的。更多信息

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

另请参阅:

cudaGraphAddNode, cudaGraphAddMemFreeNode, cudaGraphMemAllocNodeGetParams, cudaDeviceGraphMemTrim, cudaDeviceGetGraphMemAttribute, cudaDeviceSetGraphMemAttribute, cudaMallocAsync, cudaFreeAsync, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddEventRecordNode, cudaGraphAddEventWaitNode, cudaGraphAddExternalSemaphoresSignalNode, cudaGraphAddExternalSemaphoresWaitNode, cudaGraphAddKernelNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddMemFreeNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, void* dptr )
创建一个内存空闲节点并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
dptr
- Address of memory to free
描述

创建一个新的内存释放节点,并将其添加到graph中,该节点具有通过pDependencies指定的numDependencies个依赖项,以及dptr中指定的地址。numDependencies可以为0,此时该节点将被放置在图的根位置。pDependencies不能包含任何重复条目。新节点的句柄将通过pGraphNode返回。

cudaGraphAddMemFreeNode 如果用户尝试释放以下内容将返回 cudaErrorInvalidValue:

  • 在同一图中分配两次。

  • 一个未被分配节点返回的地址。

  • 无效地址。

以下限制适用于包含分配和/或内存释放节点的图:

  • 图的节点和边不能被删除。

  • 该图无法在子节点中使用。

  • 在任何时间点,只能存在一个图的实例。

  • 该图无法被克隆。

Note:
  • 图形对象不是线程安全的。更多信息

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

另请参阅:

cudaGraphAddNode, cudaGraphAddMemAllocNode, cudaGraphMemFreeNodeGetParams, cudaDeviceGraphMemTrim, cudaDeviceGetGraphMemAttribute, cudaDeviceSetGraphMemAttribute, cudaMallocAsync, cudaFreeAsync, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddEventRecordNode, cudaGraphAddEventWaitNode, cudaGraphAddExternalSemaphoresSignalNode, cudaGraphAddExternalSemaphoresWaitNode, cudaGraphAddKernelNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddMemcpyNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaMemcpy3DParms* pCopyParams )
创建一个memcpy节点并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
pCopyParams
- Parameters for the memory copy
描述

创建一个新的内存拷贝节点,并通过pDependencies指定的numDependencies个依赖项将其添加到graph中。numDependencies可以为0,此时该节点将被放置在图的根位置。pDependencies中不能有任何重复条目。新节点的句柄将在pGraphNode中返回。

当图启动时,节点将执行由pCopyParams描述的memcpy操作。有关该结构及其限制的说明,请参阅cudaMemcpy3D()

如果系统中至少有一个设备的属性cudaDevAttrConcurrentManagedAccess值为零,则Memcpy节点在托管内存方面存在一些额外限制。

Note:

另请参阅:

cudaGraphAddNode, cudaMemcpy3D, cudaGraphAddMemcpyNodeToSymbol, cudaGraphAddMemcpyNodeFromSymbol, cudaGraphAddMemcpyNode1D, cudaGraphMemcpyNodeGetParams, cudaGraphMemcpyNodeSetParams, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddHostNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddMemcpyNode1D ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, void* dst, const void* src, size_t count, cudaMemcpyKind kind )
创建一个一维内存拷贝节点并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
dst
- Destination memory address
src
- Source memory address
count
- Size in bytes to copy
kind
- Type of transfer
描述

创建一个新的1D内存拷贝节点,并通过pDependencies指定的numDependencies个依赖项将其添加到graph中。numDependencies可以为0,此时该节点将被放置在图的根位置。pDependencies中不能有任何重复条目。新节点的句柄将在pGraphNode中返回。

当图启动时,该节点会将src指向的内存区域中的count字节复制到dst指向的内存区域,其中kind指定了复制方向,必须是cudaMemcpyHostToHostcudaMemcpyHostToDevicecudaMemcpyDeviceToHostcudaMemcpyDeviceToDevicecudaMemcpyDefault之一。建议传递cudaMemcpyDefault,此时传输类型将从指针值推断得出。但cudaMemcpyDefault仅在支持统一虚拟寻址的系统上允许使用。如果使用与复制方向不匹配的dst和src指针启动memcpy节点,将导致未定义行为。

如果系统中至少有一个设备的属性cudaDevAttrConcurrentManagedAccess值为零,则Memcpy节点对托管内存有一些额外限制。

Note:

另请参阅:

cudaMemcpy, cudaGraphAddMemcpyNode, cudaGraphMemcpyNodeGetParams, cudaGraphMemcpyNodeSetParams, cudaGraphMemcpyNodeSetParams1D, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddHostNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddMemcpyNodeFromSymbol ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, void* dst, const void* symbol, size_t count, size_t offset, cudaMemcpyKind kind )
创建一个memcpy节点以从设备上的符号复制数据,并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
dst
- Destination memory address
symbol
- Device symbol address
count
- Size in bytes to copy
offset
- Offset from start of symbol in bytes
kind
- Type of transfer
描述

创建一个新的memcpy节点,用于从symbol复制数据,并通过pDependencies指定的numDependencies个依赖项将其添加到graph中。numDependencies可以为0,此时该节点将被放置在图的根位置。pDependencies中不能有任何重复条目。新节点的句柄将在pGraphNode中返回。

当图启动时,该节点将从符号symbol起始位置偏移offset字节所指向的内存区域复制count字节数据到dst指向的内存区域。内存区域之间不得重叠。symbol是驻留在全局或常量内存空间中的变量。kind可以是cudaMemcpyDeviceToHostcudaMemcpyDeviceToDevicecudaMemcpyDefault。建议传递cudaMemcpyDefault,此时传输类型会根据指针值自动推断。但cudaMemcpyDefault仅在支持统一虚拟寻址的系统上可用。

如果系统中至少有一个设备的属性cudaDevAttrConcurrentManagedAccess值为零,那么Memcpy节点在托管内存方面会有一些额外限制。

Note:

另请参阅:

cudaMemcpyFromSymbol, cudaGraphAddMemcpyNode, cudaGraphAddMemcpyNodeToSymbol, cudaGraphMemcpyNodeGetParams, cudaGraphMemcpyNodeSetParams, cudaGraphMemcpyNodeSetParamsFromSymbol, cudaGraphMemcpyNodeSetParamsToSymbol, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddHostNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddMemcpyNodeToSymbol ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const void* symbol, const void* src, size_t count, size_t offset, cudaMemcpyKind kind )
创建一个memcpy节点以复制到设备上的符号,并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
symbol
- Device symbol address
src
- Source memory address
count
- Size in bytes to copy
offset
- Offset from start of symbol in bytes
kind
- Type of transfer
描述

创建一个新的memcpy节点以复制到symbol,并通过pDependencies指定的numDependencies个依赖项将其添加到graph中。numDependencies可以为0,此时该节点将被放置在图的根位置。pDependencies不能包含任何重复条目。新节点的句柄将在pGraphNode中返回。

当图形启动时,该节点将从src指向的内存区域复制count字节到符号symbol起始位置偏移offset字节指向的内存区域。内存区域不得重叠。symbol是驻留在全局或常量内存空间中的变量。kind可以是cudaMemcpyHostToDevicecudaMemcpyDeviceToDevicecudaMemcpyDefault。建议传递cudaMemcpyDefault,此时传输类型将从指针值推断得出。但cudaMemcpyDefault仅在支持统一虚拟寻址的系统上允许使用。

如果系统中至少有一个设备的属性cudaDevAttrConcurrentManagedAccess值为零,则内存拷贝节点对托管内存有一些额外限制。

Note:

另请参阅:

cudaMemcpyToSymbol, cudaGraphAddMemcpyNode, cudaGraphAddMemcpyNodeFromSymbol, cudaGraphMemcpyNodeGetParams, cudaGraphMemcpyNodeSetParams, cudaGraphMemcpyNodeSetParamsToSymbol, cudaGraphMemcpyNodeSetParamsFromSymbol, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddHostNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphAddMemsetNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaMemsetParams* pMemsetParams )
创建一个memset节点并将其添加到图中。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
pMemsetParams
- Parameters for the memory set
描述

创建一个新的memset节点,并通过pDependencies指定的numDependencies个依赖项将其添加到graph中。numDependencies可以为0,此时该节点将被放置在图的根位置。pDependencies不能包含任何重复条目。新节点的句柄将在pGraphNode中返回。

元素大小必须为1、2或4字节。当图启动时,节点将执行由pMemsetParams描述的memset操作。

Note:

另请参阅:

cudaGraphAddNode, cudaMemset2D, cudaGraphMemsetNodeGetParams, cudaGraphMemsetNodeSetParams, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddHostNode, cudaGraphAddMemcpyNode

__host__cudaError_t cudaGraphAddNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaGraphNodeParams* nodeParams )
向图中添加任意类型的节点。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
numDependencies
- Number of dependencies
nodeParams
- Specification of the node
描述

graph中创建一个由nodeParams描述的新节点,该节点通过pDependencies指定了numDependencies个依赖项。numDependencies可以为0。如果numDependencies为0,则pDependencies可以为空。pDependencies中不能有任何重复条目。

nodeParams是一个带标签的联合体。节点类型应在type字段中指定,类型特定的参数则放在对应的联合体成员中。所有未使用的字节——即reserved0以及已使用联合体成员之后的所有字节——必须设置为零。建议使用大括号初始化或memset来确保所有字节都被初始化。

请注意,对于某些节点类型,nodeParams可能包含在调用过程中会被修改的"输出参数",例如nodeParams->alloc.dptr

新节点的句柄将在phGraphNode中返回。

Note:

另请参阅:

cudaGraphCreate, cudaGraphNodeSetParams, cudaGraphExecNodeSetParams

__host__cudaError_t cudaGraphAddNode_v2 ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, const cudaGraphEdgeData* dependencyData, size_t numDependencies, cudaGraphNodeParams* nodeParams )
向图中添加任意类型的节点(12.3+版本)。
参数
pGraphNode
- Returns newly created node
graph
- Graph to which to add the node
pDependencies
- Dependencies of the node
dependencyData
- Optional edge data for the dependencies. If NULL, the data is assumed to be default (zeroed) for all dependencies.
numDependencies
- Number of dependencies
nodeParams
- Specification of the node
描述

graph中创建一个由nodeParams描述的新节点,并通过pDependencies指定numDependencies个依赖项。numDependencies可以为0。如果numDependencies为0,则pDependencies可以为空。pDependencies不能包含任何重复条目。

nodeParams是一个带标签的联合体。节点类型应在type字段中指定,类型特定的参数则放在对应的联合体成员中。所有未使用的字节——即reserved0以及已使用联合体成员之后的所有字节——必须设置为零。建议使用大括号初始化或memset来确保所有字节都被初始化。

请注意,对于某些节点类型,nodeParams可能包含"输出参数",这些参数会在调用过程中被修改,例如nodeParams->alloc.dptr

新节点的句柄将在phGraphNode中返回。

Note:

另请参阅:

cudaGraphCreate, cudaGraphNodeSetParams, cudaGraphExecNodeSetParams

__host__cudaError_t cudaGraphChildGraphNodeGetGraph ( cudaGraphNode_t node, cudaGraph_t* pGraph )
获取子图节点中嵌入图的句柄。
参数
node
- Node to get the embedded graph for
pGraph
- Location to store a handle to the graph
描述

获取子图节点中嵌入图的句柄。此调用不会克隆图。对图的任何修改都会反映在该节点中,且该节点保留图的所有权。

无法向返回的图中添加分配和释放节点。尝试这样做将返回错误。

Note:

另请参阅:

cudaGraphAddChildGraphNode, cudaGraphNodeFindInClone

__host__cudaError_t cudaGraphClone ( cudaGraph_t* pGraphClone, cudaGraph_t originalGraph )
克隆一个图形。
参数
pGraphClone
- Returns newly created cloned graph
originalGraph
- Graph to clone
描述

此函数创建originalGraph的副本,并在pGraphClone中返回。所有参数都会被复制到克隆图中。调用此函数后,原始图可以被修改而不会影响克隆图。

原始图中的子图节点会被递归复制到克隆图中。

Note:

另请参阅:

cudaGraphCreate, cudaGraphNodeFindInClone

__host__cudaError_t cudaGraphConditionalHandleCreate ( cudaGraphConditionalHandle* pHandle_out, cudaGraph_t graph, unsigned int  defaultLaunchValue = 0, unsigned int  flags = 0 )
创建一个条件句柄。
参数
pHandle_out
- Pointer used to return the handle to the caller.
graph
defaultLaunchValue
- Optional initial value for the conditional variable. Applied at the beginning of each graph execution if cudaGraphCondAssignDefault is set in flags.
flags
- Currently must be cudaGraphCondAssignDefault or 0.
描述

创建一个与hGraph关联的条件句柄。

条件句柄必须与此图或其子图中的条件节点相关联。

未与条件节点关联的句柄可能导致图实例化失败。

Note:
  • 图形对象不是线程安全的。更多信息

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

另请参阅:

cuGraphAddNode,

__host__cudaError_t cudaGraphCreate ( cudaGraph_t* pGraph, unsigned int  flags )
创建一个图形。
参数
pGraph
- Returns newly created graph
flags
- Graph creation flags, must be 0
描述

创建一个空图,通过pGraph返回。

Note:

另请参阅:

cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddHostNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode, cudaGraphInstantiate, cudaGraphDestroy, cudaGraphGetNodes, cudaGraphGetRootNodes, cudaGraphGetEdges, cudaGraphClone

__host__cudaError_t cudaGraphDebugDotPrint ( cudaGraph_t graph, const char* path, unsigned int  flags )
编写一个描述图结构的DOT文件。
参数
graph
- The graph to create a DOT file from
path
- The path to write the DOT file to
flags
- Flags from cudaGraphDebugDotFlags for specifying which additional node information to write
描述

使用提供的graph,将图的DOT格式描述写入path。默认情况下,这包括图的拓扑结构、节点类型、节点ID、内核名称和内存拷贝方向。可以通过指定flags来写入关于每个节点类型的更详细信息,例如参数值、内核属性、节点和函数句柄。

__host__cudaError_t cudaGraphDestroy ( cudaGraph_t graph )
销毁一个图形。
参数
graph
- Graph to destroy
描述

销毁由graph指定的图结构及其所有节点。

Note:

另请参阅:

cudaGraphCreate

__host__cudaError_t cudaGraphDestroyNode ( cudaGraphNode_t node )
从图中移除一个节点。
参数
node
- Node to remove
描述

node从其所属图中移除。此操作还会切断其他节点对node的所有依赖关系,反之亦然。

无法从包含分配或释放节点的图中移除依赖项。任何尝试这样做的操作都将返回错误。

Note:

另请参阅:

cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddHostNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphEventRecordNodeGetEvent ( cudaGraphNode_t node, cudaEvent_t* event_out )
返回与事件记录节点关联的事件。
参数
node
event_out
- Pointer to return the event
描述

返回事件记录节点hNodeevent_out中的事件。

Note:

另请参阅:

cudaGraphAddEventRecordNode, cudaGraphEventRecordNodeSetEvent, cudaGraphEventWaitNodeGetEvent, cudaEventRecordWithFlags, cudaStreamWaitEvent

__host__cudaError_t cudaGraphEventRecordNodeSetEvent ( cudaGraphNode_t node, cudaEvent_t event )
设置事件记录节点的事件。
参数
node
event
- Event to use
描述

将事件记录节点 hNode 的事件设置为 event

Note:

另请参阅:

cudaGraphNodeSetParams, cudaGraphAddEventRecordNode, cudaGraphEventRecordNodeGetEvent, cudaGraphEventWaitNodeSetEvent, cudaEventRecordWithFlags, cudaStreamWaitEvent

__host__cudaError_t cudaGraphEventWaitNodeGetEvent ( cudaGraphNode_t node, cudaEvent_t* event_out )
返回与事件等待节点关联的事件。
参数
node
event_out
- Pointer to return the event
描述

返回事件等待节点hNodeevent_out中的事件。

Note:

另请参阅:

cudaGraphAddEventWaitNode, cudaGraphEventWaitNodeSetEvent, cudaGraphEventRecordNodeGetEvent, cudaEventRecordWithFlags, cudaStreamWaitEvent

__host__cudaError_t cudaGraphEventWaitNodeSetEvent ( cudaGraphNode_t node, cudaEvent_t event )
设置事件等待节点的事件。
参数
node
event
- Event to use
描述

将事件等待节点 hNode 的事件设置为 event

Note:

另请参阅:

cudaGraphNodeSetParams, cudaGraphAddEventWaitNode, cudaGraphEventWaitNodeGetEvent, cudaGraphEventRecordNodeSetEvent, cudaEventRecordWithFlags, cudaStreamWaitEvent

__host__cudaError_t cudaGraphExecChildGraphNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, cudaGraph_t childGraph )
更新给定graphExec中子图节点的节点参数。
参数
hGraphExec
- The executable graph in which to set the specified node
node
- Host node from the graph which was used to instantiate graphExec
childGraph
- The graph supplying the updated parameters
描述

更新hGraphExec中由node表示的工作,就像node的图中包含的节点在实例化时具有childGraph节点中包含的参数一样。node必须保留在用于实例化hGraphExec的图中。更改到node和从node更改的边将被忽略。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用的影响。node也不会被此调用修改。

childGraph的拓扑结构以及节点插入顺序必须与node中包含的图相匹配。有关可更新实例化图中内容的限制列表,请参阅cudaGraphExecUpdate()。该更新是递归的,因此顶级子图中包含的子图节点也将被更新。

Note:

另请参阅:

cudaGraphExecNodeSetParams, cudaGraphAddChildGraphNode, cudaGraphChildGraphNodeGetGraph, cudaGraphExecKernelNodeSetParams, cudaGraphExecMemcpyNodeSetParams, cudaGraphExecMemsetNodeSetParams, cudaGraphExecHostNodeSetParams, cudaGraphExecEventRecordNodeSetEvent, cudaGraphExecEventWaitNodeSetEvent, cudaGraphExecExternalSemaphoresSignalNodeSetParams, cudaGraphExecExternalSemaphoresWaitNodeSetParams, cudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecDestroy ( cudaGraphExec_t graphExec )
销毁一个可执行图。
参数
graphExec
- Executable graph to destroy
描述

销毁由graphExec指定的可执行图。

Note:

另请参阅:

cudaGraphInstantiate, cudaGraphUpload, cudaGraphLaunch

__host__cudaError_t cudaGraphExecEventRecordNodeSetEvent ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, cudaEvent_t event )
为给定graphExec中的事件记录节点设置事件。
参数
hGraphExec
- The executable graph in which to set the specified node
hNode
- Event record node from the graph from which graphExec was instantiated
event
- Updated event to use
描述

设置可执行图hGraphExec中事件记录节点的事件。该节点由不可执行图中对应的节点hNode标识,可执行图是从该不可执行图实例化而来的。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用影响。hNode也不会被此调用修改。

Note:

另请参阅:

cudaGraphExecNodeSetParams, cudaGraphAddEventRecordNode, cudaGraphEventRecordNodeGetEvent, cudaGraphEventWaitNodeSetEvent, cudaEventRecordWithFlags, cudaStreamWaitEvent, cudaGraphExecKernelNodeSetParams, cudaGraphExecMemcpyNodeSetParams, cudaGraphExecMemsetNodeSetParams, cudaGraphExecHostNodeSetParams, cudaGraphExecChildGraphNodeSetParams, cudaGraphExecEventWaitNodeSetEvent, cudaGraphExecExternalSemaphoresSignalNodeSetParams, cudaGraphExecExternalSemaphoresWaitNodeSetParams, cudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecEventWaitNodeSetEvent ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, cudaEvent_t event )
为给定graphExec中的事件等待节点设置事件。
参数
hGraphExec
- The executable graph in which to set the specified node
hNode
- Event wait node from the graph from which graphExec was instantiated
event
- Updated event to use
描述

设置可执行图hGraphExec中事件等待节点的事件。该节点由不可执行图中对应的节点hNode标识,可执行图是从该不可执行图实例化而来的。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用影响。hNode也不会被此调用修改。

Note:

另请参阅:

cudaGraphExecNodeSetParams, cudaGraphAddEventWaitNode, cudaGraphEventWaitNodeGetEvent, cudaGraphEventRecordNodeSetEvent, cudaEventRecordWithFlags, cudaStreamWaitEvent, cudaGraphExecKernelNodeSetParams, cudaGraphExecMemcpyNodeSetParams, cudaGraphExecMemsetNodeSetParams, cudaGraphExecHostNodeSetParams, cudaGraphExecChildGraphNodeSetParams, cudaGraphExecEventRecordNodeSetEvent, cudaGraphExecExternalSemaphoresSignalNodeSetParams, cudaGraphExecExternalSemaphoresWaitNodeSetParams, cudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecExternalSemaphoresSignalNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, const cudaExternalSemaphoreSignalNodeParams* nodeParams )
为给定graphExec中的外部信号量信号节点设置参数。
参数
hGraphExec
- The executable graph in which to set the specified node
hNode
- semaphore signal node from the graph from which graphExec was instantiated
nodeParams
- Updated Parameters to set
描述

设置可执行图hGraphExec中外部信号量信号节点的参数。该节点由不可执行图中对应的节点hNode标识,可执行图正是从该不可执行图实例化而来。

hNode 必须未被从原始图中移除。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用影响。hNode也不会被此调用修改。

不支持更改 nodeParams->numExtSems

Note:

另请参阅:

cudaGraphExecNodeSetParams, cudaGraphAddExternalSemaphoresSignalNode, cudaImportExternalSemaphore, cudaSignalExternalSemaphoresAsync, cudaWaitExternalSemaphoresAsync, cudaGraphExecKernelNodeSetParams, cudaGraphExecMemcpyNodeSetParams, cudaGraphExecMemsetNodeSetParams, cudaGraphExecHostNodeSetParams, cudaGraphExecChildGraphNodeSetParams, cudaGraphExecEventRecordNodeSetEvent, cudaGraphExecEventWaitNodeSetEvent, cudaGraphExecExternalSemaphoresWaitNodeSetParams, cudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecExternalSemaphoresWaitNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, const cudaExternalSemaphoreWaitNodeParams* nodeParams )
为给定graphExec中的外部信号量等待节点设置参数。
参数
hGraphExec
- The executable graph in which to set the specified node
hNode
- semaphore wait node from the graph from which graphExec was instantiated
nodeParams
- Updated Parameters to set
描述

设置可执行图hGraphExec中外部信号量等待节点的参数。该节点由不可执行图中对应的节点hNode标识,可执行图是从该不可执行图实例化而来的。

hNode 必须未被从原图中移除。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用影响。hNode也不会被此调用修改。

不支持更改 nodeParams->numExtSems

Note:

另请参阅:

cudaGraphExecNodeSetParams, cudaGraphAddExternalSemaphoresWaitNode, cudaImportExternalSemaphore, cudaSignalExternalSemaphoresAsync, cudaWaitExternalSemaphoresAsync, cudaGraphExecKernelNodeSetParams, cudaGraphExecMemcpyNodeSetParams, cudaGraphExecMemsetNodeSetParams, cudaGraphExecHostNodeSetParams, cudaGraphExecChildGraphNodeSetParams, cudaGraphExecEventRecordNodeSetEvent, cudaGraphExecEventWaitNodeSetEvent, cudaGraphExecExternalSemaphoresSignalNodeSetParams, cudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecGetFlags ( cudaGraphExec_t graphExec, unsigned long long* flags )
查询可执行图的实例化标志。
参数
graphExec
- The executable graph to query
flags
- Returns the instantiation flags
描述

返回传递给给定可执行图实例化的标志。cudaGraphInstantiateFlagUpload不会由此API返回,因为它不会影响最终生成的可执行图。

Note:

另请参阅:

cudaGraphInstantiate, cudaGraphInstantiateWithFlags, cudaGraphInstantiateWithParams

__host__cudaError_t cudaGraphExecHostNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaHostNodeParams* pNodeParams )
为给定graphExec中的主机节点设置参数。
参数
hGraphExec
- The executable graph in which to set the specified node
node
- Host node from the graph which was used to instantiate graphExec
pNodeParams
- Updated Parameters to set
描述

更新hGraphExec中由node表示的工作,就像node在实例化时包含pNodeParams一样。node必须保留在用于实例化hGraphExec的图中。对node的输入输出边的更改将被忽略。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用影响。node也不会被此调用修改。

Note:

另请参阅:

cudaGraphExecNodeSetParams, cudaGraphAddHostNode, cudaGraphHostNodeSetParams, cudaGraphExecKernelNodeSetParams, cudaGraphExecMemcpyNodeSetParams, cudaGraphExecMemsetNodeSetParams, cudaGraphExecChildGraphNodeSetParams, cudaGraphExecEventRecordNodeSetEvent, cudaGraphExecEventWaitNodeSetEvent, cudaGraphExecExternalSemaphoresSignalNodeSetParams, cudaGraphExecExternalSemaphoresWaitNodeSetParams, cudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecKernelNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaKernelNodeParams* pNodeParams )
为给定graphExec中的内核节点设置参数。
参数
hGraphExec
- The executable graph in which to set the specified node
node
- kernel node from the graph from which graphExec was instantiated
pNodeParams
- Updated Parameters to set
描述

设置可执行图hGraphExec中内核节点的参数。该节点由不可执行图中对应的节点node标识,可执行图是从该不可执行图实例化而来的。

node 不能从原图中移除。所有 nodeParams 字段都可以更改,但对 func 的更新有以下限制:

  • 函数的所属设备无法更改。

  • 原本未使用CUDA动态并行功能的节点无法更新为使用CDP的功能

  • 原本不进行设备端更新调用的节点,无法更新为执行设备端更新调用的函数。

  • 如果hGraphExec不是为设备启动实例化的,那么一个原本不使用设备端cudaGraphLaunch()的节点,除非该节点与实例化时包含此类调用的节点位于同一设备上,否则无法更新为使用设备端cudaGraphLaunch()的函数。如果在实例化时不存在此类调用,则完全无法执行这些更新。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用影响。node也不会被此调用修改。

如果node是一个设备可更新的内核节点,那么下一次hGraphExec的上传/启动将覆盖之前所有的设备端更新。此外,在设备正在更新时对设备可更新的内核节点应用主机更新将导致未定义行为。

Note:

另请参阅:

cudaGraphExecNodeSetParams, cudaGraphAddKernelNode, cudaGraphKernelNodeSetParams, cudaGraphExecMemcpyNodeSetParams, cudaGraphExecMemsetNodeSetParams, cudaGraphExecHostNodeSetParams, cudaGraphExecChildGraphNodeSetParams, cudaGraphExecEventRecordNodeSetEvent, cudaGraphExecEventWaitNodeSetEvent, cudaGraphExecExternalSemaphoresSignalNodeSetParams, cudaGraphExecExternalSemaphoresWaitNodeSetParams, cudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecMemcpyNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaMemcpy3DParms* pNodeParams )
为给定graphExec中的memcpy节点设置参数。
参数
hGraphExec
- The executable graph in which to set the specified node
node
- Memcpy node from the graph which was used to instantiate graphExec
pNodeParams
- Updated Parameters to set
描述

更新hGraphExec中由node表示的工作,就像node在实例化时包含pNodeParams一样。node必须保留在用于实例化hGraphExec的图中。忽略对node的进出边所做的更改。

pNodeParams中的源内存和目标内存必须与原始源内存和目标内存分配自相同的上下文。实例化时的内存操作数和pNodeParams中的内存操作数都必须是一维的。不支持零长度操作。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用的影响。node也不会被此调用修改。

如果内存操作数的映射发生更改,或者原始或新的内存操作数是多维的,则返回cudaErrorInvalidValue

Note:

另请参阅:

cudaGraphExecNodeSetParams, cudaGraphAddMemcpyNode, cudaGraphMemcpyNodeSetParams, cudaGraphExecMemcpyNodeSetParamsToSymbol, cudaGraphExecMemcpyNodeSetParamsFromSymbol, cudaGraphExecMemcpyNodeSetParams1D, cudaGraphExecKernelNodeSetParams, cudaGraphExecMemsetNodeSetParams, cudaGraphExecHostNodeSetParams, cudaGraphExecChildGraphNodeSetParams, cudaGraphExecEventRecordNodeSetEvent, cudaGraphExecEventWaitNodeSetEvent, cudaGraphExecExternalSemaphoresSignalNodeSetParams, cudaGraphExecExternalSemaphoresWaitNodeSetParams, cudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecMemcpyNodeSetParams1D ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, void* dst, const void* src, size_t count, cudaMemcpyKind kind )
设置给定graphExec中memcpy节点的参数以执行一维复制。
参数
hGraphExec
- The executable graph in which to set the specified node
node
- Memcpy node from the graph which was used to instantiate graphExec
dst
- Destination memory address
src
- Source memory address
count
- Size in bytes to copy
kind
- Type of transfer
描述

更新hGraphExec中由node表示的工作,就像node在实例化时包含给定参数一样。node必须保留在用于实例化hGraphExec的图中。忽略与node之间更改的边。

srcdst 必须从与原始源内存和目标内存相同的上下文中分配。实例化时的内存操作数必须是一维的。不支持零长度操作。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用的影响。node也不会被此调用修改。

如果内存操作数的映射发生更改或原始内存操作数为多维,则返回 cudaErrorInvalidValue

Note:

另请参阅:

cudaGraphAddMemcpyNode, cudaGraphAddMemcpyNode1D, cudaGraphMemcpyNodeSetParams, cudaGraphMemcpyNodeSetParams1D, cudaGraphExecMemcpyNodeSetParams, cudaGraphExecKernelNodeSetParams, cudaGraphExecMemsetNodeSetParams, cudaGraphExecHostNodeSetParams, cudaGraphExecChildGraphNodeSetParams, cudaGraphExecEventRecordNodeSetEvent, cudaGraphExecEventWaitNodeSetEvent, cudaGraphExecExternalSemaphoresSignalNodeSetParams, cudaGraphExecExternalSemaphoresWaitNodeSetParams, cudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecMemcpyNodeSetParamsFromSymbol ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, void* dst, const void* symbol, size_t count, size_t offset, cudaMemcpyKind kind )
设置给定graphExec中memcpy节点的参数,以便从设备上的符号进行复制。
参数
hGraphExec
- The executable graph in which to set the specified node
node
- Memcpy node from the graph which was used to instantiate graphExec
dst
- Destination memory address
symbol
- Device symbol address
count
- Size in bytes to copy
offset
- Offset from start of symbol in bytes
kind
- Type of transfer
描述

更新hGraphExec中由node表示的工作,就像node在实例化时包含给定参数一样。node必须保留在用于实例化hGraphExec的图中。忽略与node之间更改的边。

symboldst 必须从与原始源内存和目标内存相同的上下文中分配。实例化时的内存操作数必须是一维的。不支持零长度操作。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用影响。node也不会被此调用修改。

如果内存操作数的映射发生更改或原始内存操作数为多维,则返回cudaErrorInvalidValue

Note:

另请参阅:

cudaGraphAddMemcpyNode, cudaGraphAddMemcpyNodeFromSymbol, cudaGraphMemcpyNodeSetParams, cudaGraphMemcpyNodeSetParamsFromSymbol, cudaGraphExecMemcpyNodeSetParams, cudaGraphExecMemcpyNodeSetParamsToSymbol, cudaGraphExecKernelNodeSetParams, cudaGraphExecMemsetNodeSetParams, cudaGraphExecHostNodeSetParams, cudaGraphExecChildGraphNodeSetParams, cudaGraphExecEventRecordNodeSetEvent, cudaGraphExecEventWaitNodeSetEvent, cudaGraphExecExternalSemaphoresSignalNodeSetParams, cudaGraphExecExternalSemaphoresWaitNodeSetParams, cudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecMemcpyNodeSetParamsToSymbol ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const void* symbol, const void* src, size_t count, size_t offset, cudaMemcpyKind kind )
设置给定graphExec中memcpy节点的参数,以复制到设备上的符号。
参数
hGraphExec
- The executable graph in which to set the specified node
node
- Memcpy node from the graph which was used to instantiate graphExec
symbol
- Device symbol address
src
- Source memory address
count
- Size in bytes to copy
offset
- Offset from start of symbol in bytes
kind
- Type of transfer
描述

更新hGraphExec中由node表示的工作,就像node在实例化时包含给定参数一样。node必须保留在用于实例化hGraphExec的图中。忽略对node的进出边所做的更改。

srcsymbol 必须从与原始源内存和目标内存相同的上下文中分配。实例化时的内存操作数必须是一维的。不支持零长度操作。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用影响。node也不会被此调用修改。

如果内存操作数的映射发生更改或原始内存操作数为多维,则返回 cudaErrorInvalidValue

Note:

另请参阅:

cudaGraphAddMemcpyNode, cudaGraphAddMemcpyNodeToSymbol, cudaGraphMemcpyNodeSetParams, cudaGraphMemcpyNodeSetParamsToSymbol, cudaGraphExecMemcpyNodeSetParams, cudaGraphExecMemcpyNodeSetParamsFromSymbol, cudaGraphExecKernelNodeSetParams, cudaGraphExecMemsetNodeSetParams, cudaGraphExecHostNodeSetParams, cudaGraphExecChildGraphNodeSetParams, cudaGraphExecEventRecordNodeSetEvent, cudaGraphExecEventWaitNodeSetEvent, cudaGraphExecExternalSemaphoresSignalNodeSetParams, cudaGraphExecExternalSemaphoresWaitNodeSetParams, cudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecMemsetNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaMemsetParams* pNodeParams )
为给定graphExec中的memset节点设置参数。
参数
hGraphExec
- The executable graph in which to set the specified node
node
- Memset node from the graph which was used to instantiate graphExec
pNodeParams
- Updated Parameters to set
描述

更新hGraphExec中由node表示的工作,就像node在实例化时包含pNodeParams一样。node必须保留在用于实例化hGraphExec的图中。忽略与node之间更改的边。

不支持零大小的操作。

pNodeParams中的新目标指针必须指向与原始目标指针相同类型的分配,并且具有与原始目标指针相同的上下文关联和设备映射。

值和指针地址都可以更新。更改memset的其他属性(宽度、高度、元素大小或间距)可能导致更新被拒绝。具体来说,对于2D memset操作,所有维度更改都会被拒绝。对于1D memset操作,高度更改会被明确拒绝,而其他更改如果能使工作映射到节点已分配的工作资源上,则可能被允许。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用影响。node也不会被此调用修改。

Note:

另请参阅:

cudaGraphExecNodeSetParams, cudaGraphAddMemsetNode, cudaGraphMemsetNodeSetParams, cudaGraphExecKernelNodeSetParams, cudaGraphExecMemcpyNodeSetParams, cudaGraphExecHostNodeSetParams, cudaGraphExecChildGraphNodeSetParams, cudaGraphExecEventRecordNodeSetEvent, cudaGraphExecEventWaitNodeSetEvent, cudaGraphExecExternalSemaphoresSignalNodeSetParams, cudaGraphExecExternalSemaphoresWaitNodeSetParams, cudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecNodeSetParams ( cudaGraphExec_t graphExec, cudaGraphNode_t node, cudaGraphNodeParams* nodeParams )
在实例化的图中即时更新图节点的参数。
参数
graphExec
- The executable graph in which to update the specified node
node
- Corresponding node from the graph from which graphExec was instantiated
nodeParams
- Updated Parameters to set
描述

设置可执行图graphExec中节点的参数。该节点由不可执行图中对应的节点node标识,可执行图正是从该不可执行图实例化而来。node必须未被从原始图中移除。

这些修改仅影响graphExec的未来启动。已加入队列或正在运行的graphExec启动不受此调用的影响。node也不会被此调用修改。

可执行图中允许的参数更改如下:

节点类型

允许的变更

内核

参见 cudaGraphExecKernelNodeSetParams

memcpy

如果在同一上下文中分配,则用于一维拷贝的地址;参见cudaGraphExecMemcpyNodeSetParams

memset

如果在同一上下文中分配,则用于一维内存设置的地址;参见cudaGraphExecMemsetNodeSetParams

主机

无限制

子图

拓扑结构必须匹配且限制条件递归适用;详见cudaGraphExecUpdate

事件等待

无限制

事件记录

无限制

外部信号量信号

信号量操作数量不可更改

外部信号量等待

信号量操作数量不可更改

内存分配

API不支持

内存释放

API不支持

Note:

另请参阅:

cudaGraphAddNode, cudaGraphNodeSetParamscudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecUpdate ( cudaGraphExec_t hGraphExec, cudaGraph_t hGraph, cudaGraphExecUpdateResultInfo* resultInfo )
检查是否可以使用一个图来更新可执行图,并在可能的情况下执行更新。
参数
hGraphExec
The instantiated graph to be updated
hGraph
The graph containing the updated parameters
resultInfo
the error info structure
描述

使用由hGraph指定的拓扑结构相同的图中的节点参数,更新由hGraphExec指定的实例化图中的节点参数。

限制:

  • Kernel nodes:
    • 该函数的所属上下文无法更改。

    • 原本未使用CUDA动态并行功能的节点无法更新为使用CDP的功能。

    • 原本不进行设备端更新调用的节点,无法更新为执行设备端更新调用的函数。

    • 协作节点无法更新为非协作节点,反之亦然。

    • 如果图实例化时使用了cudaGraphInstantiateFlagUseNodePriority标志,则优先级属性不可更改。在将优先级值限制到设备支持的范围之前,会检查最初请求的优先级值是否相等。

    • 如果hGraphExec不是为设备启动实例化的,那么除非该节点与实例化时包含此类调用的节点位于同一设备上,否则原本不使用设备端cudaGraphLaunch()的函数节点无法更新为使用设备端cudaGraphLaunch()的函数。如果在实例化时不存在此类调用,则完全无法执行这些更新。

    • hGraphhGraphExec 都不能包含可设备更新的内核节点。

  • Memset and memcpy nodes:
    • 操作数分配/映射到的CUDA设备不能更改。

    • 源/目标内存必须从与原始源/目标内存相同的上下文中分配。

    • 对于二维内存设置(memsets),仅允许更新地址和分配的值。

    • 对于一维内存设置(memsets),也允许更新维度,但如果最终操作无法映射到节点已分配的工作资源上,则可能会失败。

  • Additional memcpy node restrictions:
    • 不支持更改源或目标内存类型(即 CU_MEMORYTYPE_DEVICE、CU_MEMORYTYPE_ARRAY 等)。

  • Conditional nodes:
    • 不支持更改节点参数。

    • 在条件体图中更改节点参数需遵循上述规则。

    • 条件处理标志和默认值会作为图更新的一部分进行更新。

注意:API在未来的版本中可能会增加更多限制。应始终检查返回码。

在以下情况下,cudaGraphExecUpdate会将resultInfo的result成员设置为cudaGraphExecUpdateErrorTopologyChanged:

  • hGraphExechGraph 中直接包含的节点数量不一致,此时会将 resultInfo->errorNode 设为 NULL。

  • hGraph 的退出节点比 hGraph 多,在这种情况下 resultInfo->errorNode 会被设置为 hGraph 中的一个退出节点。

  • hGraph中的某个节点与其在hGraphExec中配对的节点具有不同数量的依赖项时,会将resultInfo->errorNode设置为来自hGraph的该节点。

  • hGraph中的某个节点具有与hGraphExec中配对节点对应依赖项不匹配的依赖项。resultInfo->errorNode将被设置为来自hGraph的节点。resultInfo->errorFromNode将被设置为不匹配的依赖项。依赖项是基于边顺序进行配对的,当节点已经基于图中检查的其他边配对时,依赖项就不匹配。

cudaGraphExecUpdate 将 resultInfothe result 成员设置为:

  • 如果传入无效值,则返回cudaGraphExecUpdateError。

  • 如果图拓扑结构发生变化,则返回cudaGraphExecUpdateErrorTopologyChanged错误

  • 如果节点类型发生更改,则返回cudaGraphExecUpdateErrorNodeTypeChanged,此时hErrorNode_out会被设置为来自hGraph的节点。

  • 如果内核节点的函数发生更改,则返回cudaGraphExecUpdateErrorFunctionChanged(CUDA驱动版本低于11.2)

  • 如果内核的func字段以不支持的方式发生更改(参见上文注释),则返回cudaGraphExecUpdateErrorUnsupportedFunctionChange错误, 此时hErrorNode_out会被设置为来自hGraph的节点

  • 如果节点的任何参数以不支持的方式发生更改,则返回cudaGraphExecUpdateErrorParametersChanged,此时hErrorNode_out会被设置为来自hGraph的节点

  • 如果节点的任何属性以不支持的方式发生更改,则返回cudaGraphExecUpdateErrorAttributesChanged,此时hErrorNode_out会被设置为来自hGraph的节点

  • 如果节点的某些方面不受支持,例如节点类型或配置,则返回cudaGraphExecUpdateErrorNotSupported错误,此时hErrorNode_out会被设置为来自hGraph的该节点

如果更新失败的原因不在上述列表中,resultInfo的result成员将被设置为cudaGraphExecUpdateError。如果更新成功,result成员将被设置为cudaGraphExecUpdateSuccess。

当更新成功执行时,cudaGraphExecUpdate返回cudaSuccess。如果由于更新包含违反实例化图更新特定约束的更改而未执行图更新,则返回cudaErrorGraphExecUpdateFailure。

Note:

另请参阅:

cudaGraphInstantiate

__host__cudaError_t cudaGraphExternalSemaphoresSignalNodeGetParams ( cudaGraphNode_t hNode, cudaExternalSemaphoreSignalNodeParams* params_out )
返回外部信号量信号节点的参数。
参数
hNode
- Node to get the parameters for
params_out
- Pointer to return the parameters
描述

返回外部信号量节点hNode的参数到params_out中。params_out返回的extSemArrayparamsArray归该节点所有。此内存保持有效直到节点被销毁或其参数被修改,且不应直接修改。使用cudaGraphExternalSemaphoresSignalNodeSetParams来更新该节点的参数。

Note:

另请参阅:

cudaLaunchKernel, cudaGraphAddExternalSemaphoresSignalNode, cudaGraphExternalSemaphoresSignalNodeSetParams, cudaGraphAddExternalSemaphoresWaitNode, cudaSignalExternalSemaphoresAsync, cudaWaitExternalSemaphoresAsync

__host__cudaError_t cudaGraphExternalSemaphoresSignalNodeSetParams ( cudaGraphNode_t hNode, const cudaExternalSemaphoreSignalNodeParams* nodeParams )
设置外部信号量信号节点的参数。
参数
hNode
- Node to set the parameters for
nodeParams
- Parameters to copy
描述

将外部信号量节点hNode的参数设置为nodeParams

Note:

另请参阅:

cudaGraphNodeSetParams, cudaGraphAddExternalSemaphoresSignalNode, cudaGraphExternalSemaphoresSignalNodeSetParams, cudaGraphAddExternalSemaphoresWaitNode, cudaSignalExternalSemaphoresAsync, cudaWaitExternalSemaphoresAsync

__host__cudaError_t cudaGraphExternalSemaphoresWaitNodeGetParams ( cudaGraphNode_t hNode, cudaExternalSemaphoreWaitNodeParams* params_out )
返回外部信号量等待节点的参数。
参数
hNode
- Node to get the parameters for
params_out
- Pointer to return the parameters
描述

返回外部信号量等待节点hNode的参数到params_out中。params_out返回的extSemArrayparamsArray归该节点所有。此内存保持有效直到节点被销毁或其参数被修改,不应直接修改。使用cudaGraphExternalSemaphoresSignalNodeSetParams来更新此节点的参数。

Note:

另请参阅:

cudaLaunchKernel, cudaGraphAddExternalSemaphoresWaitNode, cudaGraphExternalSemaphoresWaitNodeSetParams, cudaGraphAddExternalSemaphoresWaitNode, cudaSignalExternalSemaphoresAsync, cudaWaitExternalSemaphoresAsync

__host__cudaError_t cudaGraphExternalSemaphoresWaitNodeSetParams ( cudaGraphNode_t hNode, const cudaExternalSemaphoreWaitNodeParams* nodeParams )
设置外部信号量等待节点的参数。
参数
hNode
- Node to set the parameters for
nodeParams
- Parameters to copy
描述

将外部信号量等待节点hNode的参数设置为nodeParams

Note:

另请参阅:

cudaGraphNodeSetParams, cudaGraphAddExternalSemaphoresWaitNode, cudaGraphExternalSemaphoresWaitNodeSetParams, cudaGraphAddExternalSemaphoresWaitNode, cudaSignalExternalSemaphoresAsync, cudaWaitExternalSemaphoresAsync

__host__cudaError_t cudaGraphGetEdges ( cudaGraph_t graph, cudaGraphNode_t* from, cudaGraphNode_t* to, size_t* numEdges )
返回图的依赖边。
参数
graph
- Graph to get the edges from
from
- Location to return edge endpoints
to
- Location to return edge endpoints
numEdges
- See description
描述

返回graph's依赖边的列表。边通过fromto中对应的索引返回;也就是说,to[i]中的节点依赖于from[i]中的节点。fromto可能都为NULL,在这种情况下,此函数仅返回numEdges中的边数。否则,将填充numEdges个条目。如果numEdges高于实际边数,则fromto中的剩余条目将被设置为NULL,实际返回的边数将被写入numEdges

Note:

另请参阅:

cudaGraphGetNodes, cudaGraphGetRootNodes, cudaGraphAddDependencies, cudaGraphRemoveDependencies, cudaGraphNodeGetDependencies, cudaGraphNodeGetDependentNodes

__host__cudaError_t cudaGraphGetEdges_v2 ( cudaGraph_t graph, cudaGraphNode_t* from, cudaGraphNode_t* to, cudaGraphEdgeData* edgeData, size_t* numEdges )
返回一个图的依赖边(12.3+版本)。
参数
graph
- Graph to get the edges from
from
- Location to return edge endpoints
to
- Location to return edge endpoints
edgeData
- Optional location to return edge data
numEdges
- See description
描述

返回graph的依赖边列表。边通过fromtoedgeData中对应的索引返回;也就是说,to[i]中的节点依赖于from[i]中的节点,数据为edgeData[i]。fromto可以同时为NULL,此时该函数仅返回numEdges中的边数。否则,将填充numEdges个条目。如果numEdges大于实际边数,fromto中剩余的条目将被设为NULL,实际返回的边数将写入numEdgesedgeData可以单独为NULL,此时所有边必须具有默认(清零)的边数据。尝试通过NULLedgeData进行有损查询将导致cudaErrorLossyQuery。如果edgeData非NULL,则fromto也必须非NULL。

Note:

另请参阅:

cudaGraphGetNodes, cudaGraphGetRootNodes, cudaGraphAddDependencies, cudaGraphRemoveDependencies, cudaGraphNodeGetDependencies, cudaGraphNodeGetDependentNodes

__host__cudaError_t cudaGraphGetNodes ( cudaGraph_t graph, cudaGraphNode_t* nodes, size_t* numNodes )
返回图的节点。
参数
graph
- Graph to query
nodes
- Pointer to return the nodes
numNodes
- See description
描述

返回graph的节点列表。如果nodes为NULL,则该函数将在numNodes中返回节点数量;否则将填充numNodes个条目。如果numNodes大于实际节点数,nodes中剩余条目将被设为NULL,实际获取的节点数将通过numNodes返回。

Note:

另请参阅:

cudaGraphCreate, cudaGraphGetRootNodes, cudaGraphGetEdges, cudaGraphNodeGetType, cudaGraphNodeGetDependencies, cudaGraphNodeGetDependentNodes

__host__cudaError_t cudaGraphGetRootNodes ( cudaGraph_t graph, cudaGraphNode_t* pRootNodes, size_t* pNumRootNodes )
返回图的根节点。
参数
graph
- Graph to query
pRootNodes
- Pointer to return the root nodes
pNumRootNodes
- See description
描述

返回graph的根节点列表。如果pRootNodes为NULL,则该函数将在pNumRootNodes中返回根节点数量;否则将填充pNumRootNodes个条目。如果pNumRootNodes大于实际根节点数量,pRootNodes中剩余条目将被设为NULL,实际获取的节点数量将在pNumRootNodes中返回。

Note:

另请参阅:

cudaGraphCreate, cudaGraphGetNodes, cudaGraphGetEdges, cudaGraphNodeGetType, cudaGraphNodeGetDependencies, cudaGraphNodeGetDependentNodes

__host__cudaError_t cudaGraphHostNodeGetParams ( cudaGraphNode_t node, cudaHostNodeParams* pNodeParams )
返回主机节点的参数。
参数
node
- Node to get the parameters for
pNodeParams
- Pointer to return the parameters
描述

返回主机节点nodepNodeParams中的参数。

Note:

另请参阅:

cudaLaunchHostFunc, cudaGraphAddHostNode, cudaGraphHostNodeSetParams

__host__cudaError_t cudaGraphHostNodeSetParams ( cudaGraphNode_t node, const cudaHostNodeParams* pNodeParams )
设置主机节点的参数。
参数
node
- Node to set the parameters for
pNodeParams
- Parameters to copy
描述

将主机节点 node 的参数设置为 nodeParams

Note:

另请参阅:

cudaGraphNodeSetParams, cudaLaunchHostFunc, cudaGraphAddHostNode, cudaGraphHostNodeGetParams

__host__cudaError_t cudaGraphInstantiate ( cudaGraphExec_t* pGraphExec, cudaGraph_t graph, unsigned long long flags = 0 )
从图形创建可执行图形。
参数
pGraphExec
- Returns instantiated graph
graph
- Graph to instantiate
flags
- Flags to control instantiation. See CUgraphInstantiate_flags.
描述

graph实例化为可执行图。该图会进行结构约束或节点内部约束的验证(如果之前未验证过)。如果实例化成功,实例化图的句柄将通过pGraphExec返回。

flags 参数控制实例化及后续图启动的行为。有效标志包括:

  • cudaGraphInstantiateFlagUseNodePriority,该标志使图形在执行时使用来自每个节点属性的优先级,而非启动流的优先级。请注意,优先级仅在内核节点上可用,并在流捕获期间从流优先级复制。

如果graph包含任何分配或释放节点,同一时间最多只能存在一个对应的可执行图。在通过cudaGraphExecDestroy销毁第一个可执行图之前,尝试实例化第二个可执行图将导致错误。如果graph包含任何设备可更新内核节点,同样适用此规则。

在设备上实例化以启动的图具有额外的限制,这些限制不适用于主机图:

  • 图的节点必须位于单个设备上。

  • 该图只能包含内核节点、内存拷贝节点、内存设置节点和子图节点。

  • 图形不能为空,必须包含至少一个内核(kernel)、内存拷贝(memcpy)或内存设置(memset)节点。具体操作限制如下所述。

  • Kernel nodes:
    • 禁止使用CUDA动态并行功能。

    • 只要未使用MPS,就允许协作启动。

  • Memcpy nodes:
    • 仅允许涉及设备内存和/或固定设备映射主机内存的复制操作。

    • 不允许涉及CUDA数组的复制操作。

    • 两个操作数必须可从当前设备访问,且当前设备必须与图中其他节点的设备匹配。

如果graph未实例化以在设备上启动,但包含从多个设备调用设备端cudaGraphLaunch()的内核,这将导致错误。

Note:

另请参阅:

cudaGraphInstantiateWithFlags, cudaGraphCreate, cudaGraphUpload, cudaGraphLaunch, cudaGraphExecDestroy

__host__cudaError_t cudaGraphInstantiateWithFlags ( cudaGraphExec_t* pGraphExec, cudaGraph_t graph, unsigned long long flags = 0 )
从图形创建可执行图形。
参数
pGraphExec
- Returns instantiated graph
graph
- Graph to instantiate
flags
- Flags to control instantiation. See CUgraphInstantiate_flags.
描述

graph实例化为可执行图。该图会针对之前未验证的任何结构约束或节点内约束进行验证。如果实例化成功,实例化图的句柄将在pGraphExec中返回。

flags 参数控制实例化及后续图启动的行为。有效标志包括:

  • cudaGraphInstantiateFlagUseNodePriority,该标志使图形在执行时使用来自每个节点属性的优先级,而非启动流的优先级。请注意,优先级仅在内核节点上可用,并在流捕获期间从流优先级复制。

如果graph包含任何分配或释放节点,同一时间最多只能存在一个该图的可执行实例。在通过cudaGraphExecDestroy销毁第一个可执行图之前,尝试实例化第二个可执行图将导致错误。如果graph包含任何设备可更新的内核节点,同样适用此规则。

如果graph包含从多个设备调用设备端cudaGraphLaunch()的内核,这将导致错误。

在设备上实例化以启动的图具有不适用于主机图的额外限制:

  • 图的节点必须位于单个设备上。

  • 该图只能包含内核节点、内存拷贝节点、内存设置节点和子图节点。

  • 图形不能为空,必须包含至少一个内核(kernel)、内存拷贝(memcpy)或内存设置(memset)节点。具体操作限制如下所述。

  • Kernel nodes:
    • 禁止使用CUDA动态并行功能。

    • 只要未使用MPS,就允许协作启动。

  • Memcpy nodes:
    • 仅允许涉及设备内存和/或固定设备映射主机内存的复制操作。

    • 不允许涉及CUDA数组的复制操作。

    • 两个操作数必须可从当前设备访问,且当前设备必须与图中其他节点的设备匹配。

Note:

另请参阅:

cudaGraphInstantiate, cudaGraphCreate, cudaGraphUpload, cudaGraphLaunch, cudaGraphExecDestroy

__host__cudaError_t cudaGraphInstantiateWithParams ( cudaGraphExec_t* pGraphExec, cudaGraph_t graph, cudaGraphInstantiateParams* instantiateParams )
从图形创建可执行图形。
参数
pGraphExec
- Returns instantiated graph
graph
- Graph to instantiate
instantiateParams
- Instantiation parameters
描述

根据instantiateParams结构将graph实例化为可执行图。该图会接受之前未验证的结构约束或节点内约束的验证。 如果实例化成功,实例化图的句柄将在pGraphExec中返回。

instantiateParams 控制实例化及后续图启动的行为,并在发生错误时返回更详细的信息。cudaGraphInstantiateParams 的定义如下:

‎    typedef struct {
              unsigned long long flags;
              cudaStream_t uploadStream;
              cudaGraphNode_t errNode_out;
              cudaGraphInstantiateResult result_out;
          } cudaGraphInstantiateParams;

flags 字段控制实例化及后续图启动的行为。有效标志包括:

  • cudaGraphInstantiateFlagUseNodePriority,该标志使图形在执行时使用来自每个节点属性的优先级,而非启动流的优先级。请注意,优先级仅在内核节点上可用,并且在流捕获期间会从流优先级复制。

如果graph包含任何分配或释放节点,同一时间最多只能存在一个对应的可执行图。在通过cudaGraphExecDestroy销毁第一个可执行图之前,尝试实例化第二个可执行图将导致错误。如果graph包含任何设备可更新内核节点,同样适用此规则。

如果graph包含从多个设备调用设备端cudaGraphLaunch()的内核,这将导致错误。

在设备上实例化以启动的图具有额外的限制,这些限制不适用于主机图:

  • 图的节点必须位于单个设备上。

  • 该图只能包含内核节点、内存拷贝节点、内存设置节点和子图节点。

  • 图不能为空,必须包含至少一个内核(kernel)、内存拷贝(memcpy)或内存设置(memset)节点。具体操作限制如下所述。

  • Kernel nodes:
    • 禁止使用CUDA动态并行功能。

    • 只要未使用MPS,就允许协作启动。

  • Memcpy nodes:
    • 仅允许涉及设备内存和/或固定设备映射主机内存的复制操作。

    • 不允许涉及CUDA数组的复制操作。

    • 两个操作数必须可从当前设备访问,且当前设备必须与图中其他节点的设备匹配。

如果发生错误,result_outerrNode_out 字段将包含有关错误性质的更多信息。可能的错误报告包括:

如果实例化成功,result_out将被设置为cudaGraphInstantiateSuccess,且hErrNode_out将被设为NULL。

Note:

另请参阅:

cudaGraphCreate, cudaGraphInstantiate, cudaGraphInstantiateWithFlags, cudaGraphExecDestroy

__host__cudaError_t cudaGraphKernelNodeCopyAttributes ( cudaGraphNode_t hSrc, cudaGraphNode_t hDst )
将属性从源节点复制到目标节点。
返回

cudaSuccess, cudaErrorInvalidContext

描述

将属性从源节点src复制到目标节点dst。两个节点必须具有相同的上下文。

Note:

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

另请参阅:

cudaAccessPolicyWindow

__host__cudaError_t cudaGraphKernelNodeGetAttribute ( cudaGraphNode_t hNode, cudaKernelNodeAttrID attr, cudaKernelNodeAttrValue* value_out )
查询节点属性。
参数
hNode
attr
value_out
描述

从节点 hNode 查询属性 attr 并将其存储在 value_out 的相应成员中。

Note:

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

另请参阅:

cudaAccessPolicyWindow

__host__cudaError_t cudaGraphKernelNodeGetParams ( cudaGraphNode_t node, cudaKernelNodeParams* pNodeParams )
返回内核节点的参数。
参数
node
- Node to get the parameters for
pNodeParams
- Pointer to return the parameters
描述

返回内核节点nodepNodeParams中的参数。pNodeParams返回的kernelParamsextra数组及其指向的参数值归该节点所有。此内存保持有效,直到节点被销毁或其参数被修改,不应直接修改。使用cudaGraphKernelNodeSetParams来更新此节点的参数。

参数将包含kernelParamsextra,具体取决于节点上最近设置的是哪一个。

Note:

另请参阅:

cudaLaunchKernel, cudaGraphAddKernelNode, cudaGraphKernelNodeSetParams

__host__cudaError_t cudaGraphKernelNodeSetAttribute ( cudaGraphNode_t hNode, cudaKernelNodeAttrID attr, const cudaKernelNodeAttrValue* value )
设置节点属性。
参数
hNode
attr
value
描述

value对应的属性设置到节点hNodeattr属性上。

Note:

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

另请参阅:

cudaAccessPolicyWindow

__device__cudaError_t cudaGraphKernelNodeSetEnabled ( cudaGraphDeviceNode_t node, bool  enable )
启用或禁用给定的内核节点。
参数
node
- The node to update
enable
- Whether to enable or disable the node
返回

cudaSucces, cudaErrorInvalidValue

描述

根据enable参数启用或禁用node节点。如果enable为true,节点将被启用;如果为false,节点将被禁用。被禁用的节点在执行时将表现为空操作(NOP)。 node必须支持设备端更新,且必须与调用内核位于同一设备上。

如果为节点的直接依赖项调用此函数,并且该依赖项配置为程序化依赖启动,则必须通过__threadfence()调用内存屏障,然后通过cudaTriggerProgrammaticLaunchCompletion()触发依赖项的启动,以确保在启动该依赖节点之前更新对其可见。

Note:

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

另请参阅:

cudaGraphKernelNodeSetParam, cudaGraphKernelNodeSetGridDim, cudaGraphKernelNodeUpdatesApply

__device__cudaError_t cudaGraphKernelNodeSetGridDim ( cudaGraphDeviceNode_t node, dim3 gridDim )
更新给定内核节点的网格维度。
参数
node
- The node to update
gridDim
- The grid dimensions to set
返回

cudaSucces, cudaErrorInvalidValue

描述

node的网格维度设置为gridDimnode必须是可设备更新的,并且必须与调用内核位于同一设备上。

如果为节点的直接依赖项调用此函数,并且该依赖项配置为编程式依赖启动,则必须通过__threadfence()调用内存屏障,然后通过cudaTriggerProgrammaticLaunchCompletion()触发依赖项启动,以确保在启动该依赖节点之前更新对其可见。

Note:

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

另请参阅:

cudaGraphKernelNodeSetParam, cudaGraphKernelNodeSetEnabled, cudaGraphKernelNodeUpdatesApply

模板 < 类型名 T >

__device__cudaError_t cudaGraphKernelNodeSetParam ( cudaGraphDeviceNode_t node, size_t offset, const T& value ) [inline]
更新给定内核节点的内核参数。
参数
node
- The node to update
offset
- The offset into the params at which to make the update
value
- Parameter value to write
返回

cudaSucces, cudaErrorInvalidValue

描述

nodeoffset处的内核参数更新为valuenode必须支持设备端更新,且必须与调用内核位于同一设备上。

如果为节点的直接依赖项调用此函数,并且该依赖项配置为编程式依赖启动,则必须通过__threadfence()调用内存屏障,然后通过cudaTriggerProgrammaticLaunchCompletion()触发依赖项的启动,以确保在启动该依赖节点之前更新对其可见。

Note:

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

另请参阅:

etblGraphKernelNodeSetEnabled, etblGraphKernelNodeSetGridDim, etblGraphKernelNodeUpdatesApply

__device__cudaError_t cudaGraphKernelNodeSetParam ( cudaGraphDeviceNode_t node, size_t offset, const void* value, size_t size )
更新给定内核节点的内核参数。
参数
node
- The node to update
offset
- The offset into the params at which to make the update
value
- Buffer containing the params to write
size
- Size in bytes to update
返回

cudaSucces, cudaErrorInvalidValue

描述

node内核参数中从offset开始的size字节更新为value的内容。node必须支持设备更新,并且必须与调用内核位于同一设备上。

如果为节点的直接依赖项调用此函数,并且该依赖项配置为编程式依赖启动,则必须通过__threadfence()调用内存屏障,然后通过cudaTriggerProgrammaticLaunchCompletion()触发依赖项的启动,以确保在启动该依赖节点之前更新对其可见。

Note:

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

另请参阅:

cudaGraphKernelNodeSetEnabled, cudaGraphKernelNodeSetGridDim, cudaGraphKernelNodeUpdatesApply

__host__cudaError_t cudaGraphKernelNodeSetParams ( cudaGraphNode_t node, const cudaKernelNodeParams* pNodeParams )
设置内核节点的参数。
参数
node
- Node to set the parameters for
pNodeParams
- Parameters to copy
描述

将内核节点 node 的参数设置为 pNodeParams

Note:

另请参阅:

cudaGraphNodeSetParams, cudaLaunchKernel, cudaGraphAddKernelNode, cudaGraphKernelNodeGetParams

__device__cudaError_t cudaGraphKernelNodeUpdatesApply ( const cudaGraphKernelNodeUpdate* updates, size_t updateCount )
批量应用多个内核节点更新。
参数
updates
- The updates to apply
updateCount
- The number of updates to apply
返回

cudaSucces, cudaErrorInvalidValue

描述

根据updates中提供的信息批量应用一个或多个内核节点更新。updateCount指定要应用的更新数量。updates中的每个条目必须指定要更新的节点、要应用的更新类型以及该类型更新的参数。详情请参阅cudaGraphKernelNodeUpdate文档。

如果为节点的直接依赖项调用此函数,并且该依赖项配置为编程式依赖启动,则必须通过__threadfence()调用内存屏障,然后通过cudaTriggerProgrammaticLaunchCompletion()触发依赖项的启动,以确保在启动该依赖节点之前更新对其可见。

Note:

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

另请参阅:

cudaGraphKernelNodeSetParam, cudaGraphKernelNodeSetEnabled, cudaGraphKernelNodeSetGridDim

__host____device__cudaError_t cudaGraphLaunch ( cudaGraphExec_t graphExec, cudaStream_t stream )
在流中启动可执行图。
参数
graphExec
- Executable graph to launch
stream
- Stream in which to launch the graph
描述

stream中执行graphExec。同一时间只能有一个graphExec实例在执行。每次启动都会排在stream中任何先前工作以及graphExec任何先前启动之后。要实现图的并发执行,必须将图多次实例化为多个可执行图。

如果由graphExec创建的任何分配仍未释放(来自之前的启动),并且graphExec未使用cudaGraphInstantiateFlagAutoFreeOnLaunch进行实例化,则启动将失败并返回cudaErrorInvalidValue

Note:

另请参阅:

cudaGraphInstantiate, cudaGraphUpload, cudaGraphExecDestroy

__host__cudaError_t cudaGraphMemAllocNodeGetParams ( cudaGraphNode_t node, cudaMemAllocNodeParams* params_out )
返回内存分配节点的参数。
参数
node
- Node to get the parameters for
params_out
- Pointer to return the parameters
描述

返回内存分配节点hNode的参数到params_out中。params_out返回的poolPropsaccessDescs归该节点所有。这些内存保持有效直到节点被销毁。返回的参数不得被修改。

Note:

另请参阅:

cudaGraphAddMemAllocNode, cudaGraphMemFreeNodeGetParams

__host__cudaError_t cudaGraphMemFreeNodeGetParams ( cudaGraphNode_t node, void* dptr_out )
返回一个内存空闲节点的参数。
参数
node
- Node to get the parameters for
dptr_out
- Pointer to return the device address
描述

返回内存空闲节点 hNodedptr_out 中的地址。

Note:

另请参阅:

cudaGraphAddMemFreeNode, cudaGraphMemFreeNodeGetParams

__host__cudaError_t cudaGraphMemcpyNodeGetParams ( cudaGraphNode_t node, cudaMemcpy3DParms* pNodeParams )
返回一个memcpy节点的参数。
参数
node
- Node to get the parameters for
pNodeParams
- Pointer to return the parameters
描述

返回node中memcpy节点的参数到pNodeParams

Note:

另请参阅:

cudaMemcpy3D, cudaGraphAddMemcpyNode, cudaGraphMemcpyNodeSetParams

__host__cudaError_t cudaGraphMemcpyNodeSetParams ( cudaGraphNode_t node, const cudaMemcpy3DParms* pNodeParams )
设置一个memcpy节点的参数。
参数
node
- Node to set the parameters for
pNodeParams
- Parameters to copy
描述

将memcpy节点node的参数设置为pNodeParams

Note:

另请参阅:

cudaGraphNodeSetParams, cudaMemcpy3D, cudaGraphMemcpyNodeSetParamsToSymbol, cudaGraphMemcpyNodeSetParamsFromSymbol, cudaGraphMemcpyNodeSetParams1D, cudaGraphAddMemcpyNode, cudaGraphMemcpyNodeGetParams

__host__cudaError_t cudaGraphMemcpyNodeSetParams1D ( cudaGraphNode_t node, void* dst, const void* src, size_t count, cudaMemcpyKind kind )
设置一个memcpy节点的参数以执行一维复制。
参数
node
- Node to set the parameters for
dst
- Destination memory address
src
- Source memory address
count
- Size in bytes to copy
kind
- Type of transfer
描述

将memcpy节点node的参数设置为由提供的参数描述的复制操作。

当图启动时,该节点会将src指向的内存区域中的count字节复制到dst指向的内存区域,其中kind指定了复制方向,必须是cudaMemcpyHostToHostcudaMemcpyHostToDevicecudaMemcpyDeviceToHostcudaMemcpyDeviceToDevicecudaMemcpyDefault之一。建议传递cudaMemcpyDefault,此时传输类型将从指针值推断得出。但cudaMemcpyDefault仅在支持统一虚拟寻址的系统上允许使用。如果使用与复制方向不匹配的dst和src指针启动memcpy节点,将导致未定义行为。

Note:

另请参阅:

cudaMemcpy, cudaGraphMemcpyNodeSetParams, cudaGraphAddMemcpyNode, cudaGraphMemcpyNodeGetParams

__host__cudaError_t cudaGraphMemcpyNodeSetParamsFromSymbol ( cudaGraphNode_t node, void* dst, const void* symbol, size_t count, size_t offset, cudaMemcpyKind kind )
设置一个memcpy节点的参数,以从设备上的符号进行复制。
参数
node
- Node to set the parameters for
dst
- Destination memory address
symbol
- Device symbol address
count
- Size in bytes to copy
offset
- Offset from start of symbol in bytes
kind
- Type of transfer
描述

将memcpy节点node的参数设置为由提供的参数描述的复制操作。

当图启动时,该节点将从符号symbol起始位置偏移offset字节所指向的内存区域复制count字节数据到dst指向的内存区域。内存区域之间不得重叠。symbol是驻留在全局或常量内存空间中的变量。kind可以是cudaMemcpyDeviceToHostcudaMemcpyDeviceToDevicecudaMemcpyDefault。建议传递cudaMemcpyDefault,此时传输类型会根据指针值自动推断。但cudaMemcpyDefault仅在支持统一虚拟寻址的系统上可用。

Note:

另请参阅:

cudaMemcpyFromSymbol, cudaGraphMemcpyNodeSetParams, cudaGraphMemcpyNodeSetParamsToSymbol, cudaGraphAddMemcpyNode, cudaGraphMemcpyNodeGetParams

__host__cudaError_t cudaGraphMemcpyNodeSetParamsToSymbol ( cudaGraphNode_t node, const void* symbol, const void* src, size_t count, size_t offset, cudaMemcpyKind kind )
设置内存复制节点的参数,以复制到设备上的符号。
参数
node
- Node to set the parameters for
symbol
- Device symbol address
src
- Source memory address
count
- Size in bytes to copy
offset
- Offset from start of symbol in bytes
kind
- Type of transfer
描述

将memcpy节点node的参数设置为由提供的参数描述的复制操作。

当图形启动时,该节点将从src指向的内存区域复制count字节到符号symbol起始位置偏移offset字节指向的内存区域。内存区域不得重叠。symbol是驻留在全局或常量内存空间中的变量。kind可以是cudaMemcpyHostToDevicecudaMemcpyDeviceToDevicecudaMemcpyDefault。建议传递cudaMemcpyDefault,此时传输类型将从指针值推断得出。但cudaMemcpyDefault仅在支持统一虚拟寻址的系统上允许使用。

Note:

另请参阅:

cudaMemcpyToSymbol, cudaGraphMemcpyNodeSetParams, cudaGraphMemcpyNodeSetParamsFromSymbol, cudaGraphAddMemcpyNode, cudaGraphMemcpyNodeGetParams

__host__cudaError_t cudaGraphMemsetNodeGetParams ( cudaGraphNode_t node, cudaMemsetParams* pNodeParams )
返回memset节点的参数。
参数
node
- Node to get the parameters for
pNodeParams
- Pointer to return the parameters
描述

返回node中memset节点的参数到pNodeParams

Note:

另请参阅:

cudaMemset2D, cudaGraphAddMemsetNode, cudaGraphMemsetNodeSetParams

__host__cudaError_t cudaGraphMemsetNodeSetParams ( cudaGraphNode_t node, const cudaMemsetParams* pNodeParams )
设置memset节点的参数。
参数
node
- Node to set the parameters for
pNodeParams
- Parameters to copy
描述

将memset节点node的参数设置为pNodeParams

Note:

另请参阅:

cudaGraphNodeSetParams, cudaMemset2D, cudaGraphAddMemsetNode, cudaGraphMemsetNodeGetParams

__host__cudaError_t cudaGraphNodeFindInClone ( cudaGraphNode_t* pNode, cudaGraphNode_t originalNode, cudaGraph_t clonedGraph )
查找节点的克隆版本。
参数
pNode
- Returns handle to the cloned node
originalNode
- Handle to the original node
clonedGraph
- Cloned graph to query
描述

该函数返回克隆图clonedGraph中与原图originalNode对应的节点。

clonedGraph 必须是通过 cudaGraphCloneoriginalGraph 克隆而来。originalNode 必须在调用 cudaGraphClone 时存在于 originalGraph 中,且对应的克隆节点在 clonedGraph 中未被移除。克隆节点将通过 pClonedNode 返回。

Note:

另请参阅:

cudaGraphClone

__host__cudaError_t cudaGraphNodeGetDependencies ( cudaGraphNode_t node, cudaGraphNode_t* pDependencies, size_t* pNumDependencies )
返回节点的依赖项。
参数
node
- Node to query
pDependencies
- Pointer to return the dependencies
pNumDependencies
- See description
描述

返回node的依赖项列表。如果pDependencies为NULL,则该函数将在pNumDependencies中返回依赖项的数量。否则,将填充pNumDependencies个条目。如果pNumDependencies大于实际依赖项数量,pDependencies中的剩余条目将被设置为NULL,实际获取的节点数量将在pNumDependencies中返回。

Note:

另请参阅:

cudaGraphNodeGetDependentNodes, cudaGraphGetNodes, cudaGraphGetRootNodes, cudaGraphGetEdges, cudaGraphAddDependencies, cudaGraphRemoveDependencies

__host__cudaError_t cudaGraphNodeGetDependencies_v2 ( cudaGraphNode_t node, cudaGraphNode_t* pDependencies, cudaGraphEdgeData* edgeData, size_t* pNumDependencies )
返回一个节点的依赖项(12.3+版本)。
参数
node
- Node to query
pDependencies
- Pointer to return the dependencies
edgeData
- Optional array to return edge data for each dependency
pNumDependencies
- See description
描述

返回node的依赖项列表。如果pDependencies为NULL,则该函数将在pNumDependencies中返回依赖项的数量。否则,将填充pNumDependencies个条目。如果pNumDependencies大于实际依赖项数量,pDependencies中的剩余条目将被设置为NULL,实际获取的节点数量将在pNumDependencies中返回。

请注意,如果某条边具有非零(非默认)边数据且edgeData为NULL,此API将返回cudaErrorLossyQuery。若edgeData非NULL,则pDependencies也必须非NULL。

Note:

另请参阅:

cudaGraphNodeGetDependentNodes, cudaGraphGetNodes, cudaGraphGetRootNodes, cudaGraphGetEdges, cudaGraphAddDependencies, cudaGraphRemoveDependencies

__host__cudaError_t cudaGraphNodeGetDependentNodes ( cudaGraphNode_t node, cudaGraphNode_t* pDependentNodes, size_t* pNumDependentNodes )
返回一个节点的依赖节点。
参数
node
- Node to query
pDependentNodes
- Pointer to return the dependent nodes
pNumDependentNodes
- See description
描述

返回节点的依赖节点列表。如果pDependentNodes为NULL,则该函数将在pNumDependentNodes中返回依赖节点的数量。否则,将填充pNumDependentNodes个条目。如果pNumDependentNodes大于实际依赖节点数量,pDependentNodes中的剩余条目将被设为NULL,实际获取的节点数量将在pNumDependentNodes中返回。

Note:

另请参阅:

cudaGraphNodeGetDependencies, cudaGraphGetNodes, cudaGraphGetRootNodes, cudaGraphGetEdges, cudaGraphAddDependencies, cudaGraphRemoveDependencies

__host__cudaError_t cudaGraphNodeGetDependentNodes_v2 ( cudaGraphNode_t node, cudaGraphNode_t* pDependentNodes, cudaGraphEdgeData* edgeData, size_t* pNumDependentNodes )
返回一个节点的依赖节点(12.3+版本)。
参数
node
- Node to query
pDependentNodes
- Pointer to return the dependent nodes
edgeData
- Optional pointer to return edge data for dependent nodes
pNumDependentNodes
- See description
描述

返回节点的依赖节点列表。如果pDependentNodes为NULL,则该函数将在pNumDependentNodes中返回依赖节点的数量。否则,将填充pNumDependentNodes个条目。如果pNumDependentNodes大于实际依赖节点数量,pDependentNodes中的剩余条目将被设置为NULL,实际获取的节点数量将在pNumDependentNodes中返回。

请注意,如果某条边具有非零(非默认)边数据且edgeData为NULL,此API将返回cudaErrorLossyQuery。若edgeData非NULL,则pDependentNodes也必须非NULL。

Note:

另请参阅:

cudaGraphNodeGetDependencies, cudaGraphGetNodes, cudaGraphGetRootNodes, cudaGraphGetEdges, cudaGraphAddDependencies, cudaGraphRemoveDependencies

__host__cudaError_t cudaGraphNodeGetEnabled ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, unsigned int* isEnabled )
查询给定graphExec中的某个节点是否已启用。
参数
hGraphExec
- The executable graph in which to set the specified node
hNode
- Node from the graph from which graphExec was instantiated
isEnabled
- Location to return the enabled status of the node
描述

如果hNode已启用,则将isEnabled设置为1;如果hNode已禁用,则设置为0。

该节点由非可执行图中对应的节点hNode标识,可执行图正是从该非可执行图实例化而来。

hNode 必须未被从原图中移除。

Note:

目前仅支持内核、memset和memcpy节点。

Note:

另请参阅:

cudaGraphNodeSetEnabled, cudaGraphExecUpdate, cudaGraphInstantiatecudaGraphLaunch

__host__cudaError_t cudaGraphNodeGetType ( cudaGraphNode_t node, cudaGraphNodeType ** pType )
返回节点的类型。
参数
node
- Node to query
pType
- Pointer to return the node type
描述

返回nodepType中的节点类型。

Note:

另请参阅:

cudaGraphGetNodes, cudaGraphGetRootNodes, cudaGraphChildGraphNodeGetGraph, cudaGraphKernelNodeGetParams, cudaGraphKernelNodeSetParams, cudaGraphHostNodeGetParams, cudaGraphHostNodeSetParams, cudaGraphMemcpyNodeGetParams, cudaGraphMemcpyNodeSetParams, cudaGraphMemsetNodeGetParams, cudaGraphMemsetNodeSetParams

__host__cudaError_t cudaGraphNodeSetEnabled ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, unsigned int  isEnabled )
启用或禁用给定graphExec中的指定节点。
参数
hGraphExec
- The executable graph in which to set the specified node
hNode
- Node from the graph from which graphExec was instantiated
isEnabled
- Node is enabled if != 0, otherwise the node is disabled
描述

hNode设置为启用或禁用状态。被禁用的节点在功能上等同于空节点,直到重新启用为止。禁用/启用操作不会影响节点现有的参数配置。

该节点由非可执行图中对应的节点hNode标识,可执行图正是从该非可执行图实例化而来。

hNode 必须未被从原图中移除。

这些修改仅影响未来启动的hGraphExec。已排队或正在运行的hGraphExec启动不受此调用影响。hNode也不会被此调用修改。

Note:

目前仅支持内核(kernel)、内存设置(memset)和内存复制(memcpy)节点。

Note:

另请参阅:

cudaGraphNodeGetEnabled, cudaGraphExecUpdate, cudaGraphInstantiatecudaGraphLaunch

__host__cudaError_t cudaGraphNodeSetParams ( cudaGraphNode_t node, cudaGraphNodeParams* nodeParams )
更新图节点的参数。
参数
node
- Node to set the parameters for
nodeParams
- Parameters to copy
描述

将图节点node的参数设置为nodeParamsnodeParams->type指定的节点类型必须与node的类型匹配。nodeParams必须完全初始化,并且所有未使用的字节(保留、填充)必须清零。

不支持修改节点类型 cudaGraphNodeTypeMemAlloc 和 cudaGraphNodeTypeMemFree 的参数。

Note:

另请参阅:

cudaGraphAddNode, cudaGraphExecNodeSetParams

__host__cudaError_t cudaGraphReleaseUserObject ( cudaGraph_t graph, cudaUserObject_t object, unsigned int  count = 1 )
从图中释放用户对象引用。
参数
graph
- The graph that will release the reference
object
- The user object to release a reference for
count
- The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX.
描述

释放图所拥有的用户对象引用。

有关用户对象的更多信息,请参阅CUDA C++编程指南中的CUDA用户对象部分。

另请参阅:

cudaUserObjectCreatecudaUserObjectRetain, cudaUserObjectRelease, cudaGraphRetainUserObject, cudaGraphCreate

__host__cudaError_t cudaGraphRemoveDependencies ( cudaGraph_t graph, const cudaGraphNode_t* from, const cudaGraphNode_t* to, size_t numDependencies )
从图中移除依赖边。
参数
graph
- Graph from which to remove dependencies
from
- Array of nodes that provide the dependencies
to
- Array of dependent nodes
numDependencies
- Number of dependencies to be removed
描述

要移除的pDependencies数量由numDependencies定义。pFrompTo中对应索引的元素定义了一个依赖关系。pFrompTo中的每个节点都必须属于graph

如果numDependencies为0,则pFrompTo中的元素将被忽略。指定不存在的依赖项将返回错误。

Note:

另请参阅:

cudaGraphAddDependencies, cudaGraphGetEdges, cudaGraphNodeGetDependencies, cudaGraphNodeGetDependentNodes

__host__cudaError_t cudaGraphRemoveDependencies_v2 ( cudaGraph_t graph, const cudaGraphNode_t* from, const cudaGraphNode_t* to, const cudaGraphEdgeData* edgeData, size_t numDependencies )
从图中移除依赖边。(12.3+版本)
参数
graph
- Graph from which to remove dependencies
from
- Array of nodes that provide the dependencies
to
- Array of dependent nodes
edgeData
- Optional array of edge data. If NULL, edge data is assumed to be default (zeroed).
numDependencies
- Number of dependencies to be removed
描述

要移除的pDependencies数量由numDependencies定义。pFrompTo中对应索引的元素定义了依赖关系。pFrompTo中的每个节点都必须属于graph

如果numDependencies为0,则pFrompTo中的元素将被忽略。指定图中不存在且数据与edgeData匹配的边会导致错误。edgeData可为空,相当于为每条边传递默认(清零)数据。

Note:

另请参阅:

cudaGraphAddDependencies, cudaGraphGetEdges, cudaGraphNodeGetDependencies, cudaGraphNodeGetDependentNodes

__host__cudaError_t cudaGraphRetainUserObject ( cudaGraph_t graph, cudaUserObject_t object, unsigned int  count = 1, unsigned int  flags = 0 )
保留对图中用户对象的引用。
参数
graph
- The graph to associate the reference with
object
- The user object to retain a reference for
count
- The number of references to add to the graph, typically 1. Must be nonzero and not larger than INT_MAX.
flags
- The optional flag cudaGraphUserObjectMove transfers references from the calling thread, rather than create new references. Pass 0 to create new references.
描述

创建或移动将由CUDA图拥有的用户对象引用。

有关用户对象的更多信息,请参阅CUDA C++编程指南中的CUDA用户对象部分。

另请参阅:

cudaUserObjectCreatecudaUserObjectRetain, cudaUserObjectRelease, cudaGraphReleaseUserObject, cudaGraphCreate

__device__ ​ void cudaGraphSetConditional ( cudaGraphConditionalHandle handle, unsigned int  value )
设置与条件节点关联的条件值。
描述

设置与条件节点关联的条件值。

注意:handle必须与调用此函数的内核处于相同的上下文中。

另请参阅:

cudaGraphConditionalHandleCreate

__host__cudaError_t cudaGraphUpload ( cudaGraphExec_t graphExec, cudaStream_t stream )
以流的形式上传可执行图。
描述

hGraphExec上传至hStream设备但不执行。相同hGraphExec的上传操作将被序列化。每次上传都将在hStream中所有先前工作以及hGraphExec所有先前启动之后按序执行。使用stream缓存的内存来支持graphExec拥有的分配。

Note:

另请参阅:

cudaGraphInstantiate, cudaGraphLaunch, cudaGraphExecDestroy

__host__cudaError_t cudaUserObjectCreate ( cudaUserObject_t* object_out, void* ptr, cudaHostFn_t destroy, unsigned int  initialRefcount, unsigned int  flags )
创建一个用户对象。
参数
object_out
- Location to return the user object handle
ptr
- The pointer to pass to the destroy function
destroy
- Callback to free the user object when it is no longer in use
initialRefcount
- The initial refcount to create the object with, typically 1. The initial references are owned by the calling thread.
flags
- Currently it is required to pass cudaUserObjectNoDestructorSync, which is the only defined flag. This indicates that the destroy callback cannot be waited on by any CUDA API. Users requiring synchronization of the callback should signal its completion manually.
描述

创建一个用户对象,带有指定的析构回调函数和初始引用计数。初始引用由调用者持有。

析构回调函数不能调用CUDA API接口,且应避免阻塞行为,因为它们是由一个共享的内部线程执行的。可以通知另一个线程来执行此类操作,前提是该线程不会阻塞通过CUDA调度的任务向前推进。

有关用户对象的更多信息,请参阅CUDA C++编程指南中的CUDA用户对象部分。

另请参阅:

cudaUserObjectRetain, cudaUserObjectRelease, cudaGraphRetainUserObject, cudaGraphReleaseUserObject, cudaGraphCreate

__host__cudaError_t cudaUserObjectRelease ( cudaUserObject_t object, unsigned int  count = 1 )
释放对用户对象的引用。
参数
object
- The object to release
count
- The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX.
描述

释放调用者拥有的用户对象引用。如果引用计数降至零,将调用对象的析构函数。

释放不属于调用者拥有的引用,或在所有引用被释放后使用用户对象句柄,属于未定义行为。

有关用户对象的更多信息,请参阅CUDA C++编程指南中的CUDA用户对象部分。

另请参阅:

cudaUserObjectCreate, cudaUserObjectRetain, cudaGraphRetainUserObject, cudaGraphReleaseUserObject, cudaGraphCreate

__host__cudaError_t cudaUserObjectRetain ( cudaUserObject_t object, unsigned int  count = 1 )
保留对用户对象的引用。
参数
object
- The object to retain
count
- The number of references to retain, typically 1. Must be nonzero and not larger than INT_MAX.
描述

保留对用户对象的新引用。这些新引用由调用方拥有。

有关用户对象的更多信息,请参阅CUDA C++编程指南中的CUDA用户对象部分。

另请参阅:

cudaUserObjectCreate, cudaUserObjectRelease, cudaGraphRetainUserObject, cudaGraphReleaseUserObject, cudaGraphCreate