6.30. 图管理

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

函数

__host__cudaError_t cudaDeviceGetGraphMemAttribute ( int  device, cudaGraphMemAttributeType attr, void* value )
查询与图相关的异步分配属性。
__host__cudaError_t cudaDeviceGraphMemTrim ( int  device )
释放指定设备上为图缓存的未使用内存,将其返回给操作系统。
__host__cudaError_t cudaDeviceSetGraphMemAttribute ( int  device, cudaGraphMemAttributeType attr, void* value )
设置与图相关的异步分配属性。
__device__cudaGraphExec_t cudaGetCurrentGraphExec ( void )
获取当前正在运行的设备图 ID。
__host__cudaError_t cudaGraphAddChildGraphNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaGraph_t childGraph )
创建一个子图节点并将其添加到图中。
__host__cudaError_t cudaGraphAddDependencies ( cudaGraph_t graph, const cudaGraphNode_t* from, const cudaGraphNode_t* to, size_t numDependencies )
向图中添加依赖边。
__host__cudaError_t cudaGraphAddDependencies_v2 ( cudaGraph_t graph, const cudaGraphNode_t* from, const cudaGraphNode_t* to, const cudaGraphEdgeData* edgeData, size_t numDependencies )
向图中添加依赖边。(12.3+)
__host__cudaError_t cudaGraphAddEmptyNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies )
创建一个空节点并将其添加到图中。
__host__cudaError_t cudaGraphAddEventRecordNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaEvent_t event )
创建一个事件记录节点并将其添加到图中。
__host__cudaError_t cudaGraphAddEventWaitNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaEvent_t event )
创建一个事件等待节点并将其添加到图中。
__host__cudaError_t cudaGraphAddExternalSemaphoresSignalNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaExternalSemaphoreSignalNodeParams* nodeParams )
创建一个外部信号量信号节点并将其添加到图中。
__host__cudaError_t cudaGraphAddExternalSemaphoresWaitNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaExternalSemaphoreWaitNodeParams* nodeParams )
创建一个外部信号量等待节点并将其添加到图中。
__host__cudaError_t cudaGraphAddHostNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaHostNodeParams* pNodeParams )
创建一个主机执行节点并将其添加到图中。
__host__cudaError_t cudaGraphAddKernelNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaKernelNodeParams* pNodeParams )
创建一个内核执行节点并将其添加到图中。
__host__cudaError_t cudaGraphAddMemAllocNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaMemAllocNodeParams* nodeParams )
创建一个分配节点并将其添加到图中。
__host__cudaError_t cudaGraphAddMemFreeNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, void* dptr )
创建一个内存释放节点并将其添加到图中。
__host__cudaError_t cudaGraphAddMemcpyNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaMemcpy3DParms* pCopyParams )
创建一个 memcpy 节点并将其添加到图中。
__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 )
创建一个 1D memcpy 节点并将其添加到图中。
__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 节点,用于从设备上的符号复制数据,并将其添加到图中。
__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 节点,用于复制到设备上的符号,并将其添加到图中。
__host__cudaError_t cudaGraphAddMemsetNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, const cudaMemsetParams* pMemsetParams )
创建一个 memset 节点并将其添加到图中。
__host__cudaError_t cudaGraphAddNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies, cudaGraphNodeParams* nodeParams )
向图中添加任意类型的节点。
__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+)。
__host__cudaError_t cudaGraphChildGraphNodeGetGraph ( cudaGraphNode_t node, cudaGraph_t* pGraph )
获取子图节点的嵌入式图的句柄。
__host__cudaError_t cudaGraphClone ( cudaGraph_t* pGraphClone, cudaGraph_t originalGraph )
克隆一个图。
__host__cudaError_t cudaGraphConditionalHandleCreate ( cudaGraphConditionalHandle* pHandle_out, cudaGraph_t graph, unsigned int  defaultLaunchValue = 0, unsigned int  flags = 0 )
创建一个条件句柄。
__host__cudaError_t cudaGraphCreate ( cudaGraph_t* pGraph, unsigned int  flags )
创建一个图。
__host__cudaError_t cudaGraphDebugDotPrint ( cudaGraph_t graph, const char* path, unsigned int  flags )
写入描述图结构的 DOT 文件。
__host__cudaError_t cudaGraphDestroy ( cudaGraph_t graph )
销毁一个图。
__host__cudaError_t cudaGraphDestroyNode ( cudaGraphNode_t node )
从图中移除一个节点。
__host__cudaError_t cudaGraphEventRecordNodeGetEvent ( cudaGraphNode_t node, cudaEvent_t* event_out )
返回与事件记录节点关联的事件。
__host__cudaError_t cudaGraphEventRecordNodeSetEvent ( cudaGraphNode_t node, cudaEvent_t event )
设置事件记录节点的事件。
__host__cudaError_t cudaGraphEventWaitNodeGetEvent ( cudaGraphNode_t node, cudaEvent_t* event_out )
返回与事件等待节点关联的事件。
__host__cudaError_t cudaGraphEventWaitNodeSetEvent ( cudaGraphNode_t node, cudaEvent_t event )
设置事件等待节点的事件。
__host__cudaError_t cudaGraphExecChildGraphNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, cudaGraph_t childGraph )
更新给定 graphExec 中子图节点中的节点参数。
__host__cudaError_t cudaGraphExecDestroy ( cudaGraphExec_t graphExec )
销毁一个可执行图。
__host__cudaError_t cudaGraphExecEventRecordNodeSetEvent ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, cudaEvent_t event )
设置给定 graphExec 中事件记录节点的事件。
__host__cudaError_t cudaGraphExecEventWaitNodeSetEvent ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, cudaEvent_t event )
设置给定 graphExec 中事件等待节点的事件。
__host__cudaError_t cudaGraphExecExternalSemaphoresSignalNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, const cudaExternalSemaphoreSignalNodeParams* nodeParams )
为给定 graphExec 中的外部信号量信号节点设置参数。
__host__cudaError_t cudaGraphExecExternalSemaphoresWaitNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, const cudaExternalSemaphoreWaitNodeParams* nodeParams )
为给定 graphExec 中的外部信号量等待节点设置参数。
__host__cudaError_t cudaGraphExecGetFlags ( cudaGraphExec_t graphExec, unsigned long long* flags )
查询可执行图的实例化标志。
__host__cudaError_t cudaGraphExecHostNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaHostNodeParams* pNodeParams )
为给定 graphExec 中的主机节点设置参数。
__host__cudaError_t cudaGraphExecKernelNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaKernelNodeParams* pNodeParams )
为给定 graphExec 中的内核节点设置参数。
__host__cudaError_t cudaGraphExecMemcpyNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaMemcpy3DParms* pNodeParams )
为给定 graphExec 中的 memcpy 节点设置参数。
__host__cudaError_t cudaGraphExecMemcpyNodeSetParams1D ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, void* dst, const void* src, size_t count, cudaMemcpyKind kind )
为给定 graphExec 中的 memcpy 节点设置参数以执行一维复制。
__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 节点设置参数,以从设备上的符号复制。
__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 节点设置参数,以复制到设备上的符号。
__host__cudaError_t cudaGraphExecMemsetNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaMemsetParams* pNodeParams )
为给定 graphExec 中的 memset 节点设置参数。
__host__cudaError_t cudaGraphExecNodeSetParams ( cudaGraphExec_t graphExec, cudaGraphNode_t node, cudaGraphNodeParams* nodeParams )
更新已实例化图中的图节点参数。
__host__cudaError_t cudaGraphExecUpdate ( cudaGraphExec_t hGraphExec, cudaGraph_t hGraph, cudaGraphExecUpdateResultInfo* resultInfo )
检查可执行图是否可以使用图进行更新,并在可能的情况下执行更新。
__host__cudaError_t cudaGraphExternalSemaphoresSignalNodeGetParams ( cudaGraphNode_t hNode, cudaExternalSemaphoreSignalNodeParams* params_out )
返回外部信号量信号节点的参数。
__host__cudaError_t cudaGraphExternalSemaphoresSignalNodeSetParams ( cudaGraphNode_t hNode, const cudaExternalSemaphoreSignalNodeParams* nodeParams )
设置外部信号量信号节点的参数。
__host__cudaError_t cudaGraphExternalSemaphoresWaitNodeGetParams ( cudaGraphNode_t hNode, cudaExternalSemaphoreWaitNodeParams* params_out )
返回外部信号量等待节点的参数。
__host__cudaError_t cudaGraphExternalSemaphoresWaitNodeSetParams ( cudaGraphNode_t hNode, const cudaExternalSemaphoreWaitNodeParams* nodeParams )
设置外部信号量等待节点的参数。
__host__cudaError_t cudaGraphGetEdges ( cudaGraph_t graph, cudaGraphNode_t* from, cudaGraphNode_t* to, size_t* numEdges )
返回图的依赖边。
__host__cudaError_t cudaGraphGetEdges_v2 ( cudaGraph_t graph, cudaGraphNode_t* from, cudaGraphNode_t* to, cudaGraphEdgeData* edgeData, size_t* numEdges )
返回图的依赖边 (12.3+)。
__host__cudaError_t cudaGraphGetNodes ( cudaGraph_t graph, cudaGraphNode_t* nodes, size_t* numNodes )
返回图的节点。
__host__cudaError_t cudaGraphGetRootNodes ( cudaGraph_t graph, cudaGraphNode_t* pRootNodes, size_t* pNumRootNodes )
返回图的根节点。
__host__cudaError_t cudaGraphHostNodeGetParams ( cudaGraphNode_t node, cudaHostNodeParams* pNodeParams )
返回主机节点的参数。
__host__cudaError_t cudaGraphHostNodeSetParams ( cudaGraphNode_t node, const cudaHostNodeParams* pNodeParams )
设置主机节点的参数。
__host__cudaError_t cudaGraphInstantiate ( cudaGraphExec_t* pGraphExec, cudaGraph_t graph, unsigned long long flags = 0 )
从图创建可执行图。
__host__cudaError_t cudaGraphInstantiateWithFlags ( cudaGraphExec_t* pGraphExec, cudaGraph_t graph, unsigned long long flags = 0 )
从图创建可执行图。
__host__cudaError_t cudaGraphInstantiateWithParams ( cudaGraphExec_t* pGraphExec, cudaGraph_t graph, cudaGraphInstantiateParams* instantiateParams )
从图创建可执行图。
__host__cudaError_t cudaGraphKernelNodeCopyAttributes ( cudaGraphNode_t hSrc, cudaGraphNode_t hDst )
将属性从源节点复制到目标节点。
__host__cudaError_t cudaGraphKernelNodeGetAttribute ( cudaGraphNode_t hNode, cudaKernelNodeAttrID attr, cudaKernelNodeAttrValue* value_out )
查询节点属性。
__host__cudaError_t cudaGraphKernelNodeGetParams ( cudaGraphNode_t node, cudaKernelNodeParams* pNodeParams )
返回内核节点的参数。
__host__cudaError_t cudaGraphKernelNodeSetAttribute ( cudaGraphNode_t hNode, cudaKernelNodeAttrID attr, const cudaKernelNodeAttrValue* value )
设置节点属性。
__device__cudaError_t cudaGraphKernelNodeSetEnabled ( cudaGraphDeviceNode_t node, bool  enable )
启用或禁用给定的内核节点。
__device__cudaError_t cudaGraphKernelNodeSetGridDim ( cudaGraphDeviceNode_t node, dim3 gridDim )
更新给定内核节点的网格维度。
template < typename T >__device__cudaError_t cudaGraphKernelNodeSetParam ( cudaGraphDeviceNode_t node, size_t offset, const T& value )
更新给定内核节点的内核参数。
__device__cudaError_t cudaGraphKernelNodeSetParam ( cudaGraphDeviceNode_t node, size_t offset, const void* value, size_t size )
更新给定内核节点的内核参数。
__host__cudaError_t cudaGraphKernelNodeSetParams ( cudaGraphNode_t node, const cudaKernelNodeParams* pNodeParams )
设置内核节点的参数。
__device__cudaError_t cudaGraphKernelNodeUpdatesApply ( const cudaGraphKernelNodeUpdate* updates, size_t updateCount )
批量应用多个内核节点更新。
__host____device__cudaError_t cudaGraphLaunch ( cudaGraphExec_t graphExec, cudaStream_t stream )
在流中启动可执行图。
__host__cudaError_t cudaGraphMemAllocNodeGetParams ( cudaGraphNode_t node, cudaMemAllocNodeParams* params_out )
返回内存分配节点的参数。
__host__cudaError_t cudaGraphMemFreeNodeGetParams ( cudaGraphNode_t node, void* dptr_out )
返回内存释放节点的参数。
__host__cudaError_t cudaGraphMemcpyNodeGetParams ( cudaGraphNode_t node, cudaMemcpy3DParms* pNodeParams )
返回 memcpy 节点的参数。
__host__cudaError_t cudaGraphMemcpyNodeSetParams ( cudaGraphNode_t node, const cudaMemcpy3DParms* pNodeParams )
设置 memcpy 节点的参数。
__host__cudaError_t cudaGraphMemcpyNodeSetParams1D ( cudaGraphNode_t node, void* dst, const void* src, size_t count, cudaMemcpyKind kind )
设置 memcpy 节点的参数以执行一维复制。
__host__cudaError_t cudaGraphMemcpyNodeSetParamsFromSymbol ( cudaGraphNode_t node, void* dst, const void* symbol, size_t count, size_t offset, cudaMemcpyKind kind )
设置 memcpy 节点的参数以从设备上的符号复制。
__host__cudaError_t cudaGraphMemcpyNodeSetParamsToSymbol ( cudaGraphNode_t node, const void* symbol, const void* src, size_t count, size_t offset, cudaMemcpyKind kind )
设置 memcpy 节点的参数以复制到设备上的符号。
__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.

函数

__host__cudaError_t cudaDeviceGetGraphMemAttribute ( int  device, cudaGraphMemAttributeType attr, void* value )
查询与图相关的异步分配属性。
参数
device
- 指定查询的范围
attr
- 要获取的属性
value
- 检索到的值
描述

有效的属性包括

注意

另请参阅

cudaDeviceSetGraphMemAttribute, cudaGraphAddMemAllocNode, cudaGraphAddMemFreeNode, cudaDeviceGraphMemTrim, cudaMallocAsync, cudaFreeAsync

__host__cudaError_t cudaDeviceGraphMemTrim ( int  device )
将为图缓存的指定设备上的未使用内存释放回操作系统。
参数
device
- 应该释放缓存内存的设备。
描述

当前未被正在执行或计划执行的图使用的块将被释放回操作系统。

注意

另请参阅

cudaGraphAddMemAllocNode, cudaGraphAddMemFreeNode, cudaDeviceGetGraphMemAttribute, cudaDeviceSetGraphMemAttribute, cudaMallocAsync, cudaFreeAsync

__host__cudaError_t cudaDeviceSetGraphMemAttribute ( int  device, cudaGraphMemAttributeType attr, void* value )
设置与图相关的异步分配属性。
参数
device
- 指定查询的范围
attr
- 要获取的属性
value
- 指向要设置的值的指针
描述

有效的属性包括

注意

另请参阅

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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
childGraph
- 要克隆到此节点的图
描述

创建一个新节点,该节点执行嵌入式图,并将其添加到graph使用numDependencies通过以下方式指定的依赖项pDependencies。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。pDependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

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

该节点执行嵌入式子图。 子图在此调用中克隆。

注意

另请参阅

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
- 向其添加依赖项的图
from
- 提供依赖项的节点数组
to
- 依赖节点数组
numDependencies
- 要添加的依赖项数量
描述

要添加的依赖项数量由以下项定义numDependencies中的元素pFrompTo在对应索引处定义依赖项。 中的每个节点pFrompTo必须属于graph.

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

注意

另请参阅

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
- 向其添加依赖项的图
from
- 提供依赖项的节点数组
to
- 依赖节点数组
edgeData
- 可选的边数据数组。 如果为 NULL,则假定为默认(零值)边数据。
numDependencies
- 要添加的依赖项数量
描述

要添加的依赖项数量由以下项定义numDependencies中的元素pFrompTo在对应索引处定义依赖项。 中的每个节点pFrompTo必须属于graph.

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

注意

另请参阅

cudaGraphRemoveDependencies, cudaGraphGetEdges, cudaGraphNodeGetDependencies, cudaGraphNodeGetDependentNodes

__host__cudaError_t cudaGraphAddEmptyNode ( cudaGraphNode_t* pGraphNode, cudaGraph_t graph, const cudaGraphNode_t* pDependencies, size_t numDependencies )
创建空节点并将其添加到图中。
参数
pGraphNode
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
描述

创建一个不执行任何操作的新节点,并将其添加到graph使用numDependencies通过以下方式指定的依赖项pDependencies。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。pDependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

空的节点在执行期间不执行任何操作,但可以用于传递排序。例如,具有 2 组 n 个节点的阶段性执行图,它们之间有一个屏障,可以使用一个空节点和 2*n 个依赖边来表示,而不是没有空节点和 n^2 个依赖边。

注意

另请参阅

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
- 依赖项的数量
event
- 节点的事件
描述

创建一个新的事件记录节点并将其添加到hGraph使用numDependencies通过以下方式指定的依赖项dependencies和指定的事件event。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。dependencies可能没有任何重复条目。 新节点的句柄将在phGraphNode.

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

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

注意

另请参阅

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
- 依赖项的数量
event
- 节点的事件
描述

创建一个新的事件等待节点并将其添加到hGraph使用numDependencies通过以下方式指定的依赖项dependencies和指定的事件event。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。dependencies可能没有任何重复条目。 新节点的句柄将在phGraphNode.

图节点将等待在event. 有关事件捕获内容的详细信息,请参见 cuEventRecord()。当适用时,同步将在设备上高效执行。event可能来自与启动流不同的上下文或设备。

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

注意

另请参阅

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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
nodeParams
- 节点的参数
描述

创建一个新的外部信号量信号节点并将其添加到graph使用numDependencies通过以下方式指定的依赖项dependencies和指定的参数nodeParams。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。dependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

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

注意

另请参阅

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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
nodeParams
- 节点的参数
描述

创建一个新的外部信号量等待节点并将其添加到graph使用numDependencies通过以下方式指定的依赖项dependencies和指定的参数nodeParams。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。dependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

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

注意

另请参阅

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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
pNodeParams
- 主机节点的参数
描述

创建一个新的 CPU 执行节点并将其添加到graph使用numDependencies通过以下方式指定的依赖项pDependencies和指定的参数pNodeParams。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。pDependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

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

注意

另请参阅

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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
pNodeParams
- GPU 执行节点的参数
描述

创建一个新的内核执行节点并将其添加到graph使用numDependencies通过以下方式指定的依赖项pDependencies和指定的参数pNodeParams。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。pDependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

cudaKernelNodeParams 结构定义为

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

当图启动时,节点将在 (func) 上调用内核gridDim.xxgridDim.yxgridDim.z) 区块网格。每个区块包含 (blockDim.xxblockDim.yxblockDim.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数组以及它指向的参数值。

注意

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

注意

另请参阅

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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
nodeParams
- 节点的参数
描述

创建一个新的分配节点并将其添加到graph使用numDependencies通过以下方式指定的依赖项pDependencies和指定的参数nodeParams。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。pDependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

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

如果在同一图中通过使用 cudaGraphAddMemFreeNode 创建释放节点来释放分配,则在分配节点之后但在释放节点之前的节点可以访问该分配。这些分配不能在拥有图之外释放,并且在拥有图中只能释放一次。

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

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

  • 将分配传递给 cudaMemFreeAsync 或 cudaMemFree;

  • 启动具有该分配的释放节点的图;或

  • 指定实例化期间的 cudaGraphInstantiateFlagAutoFreeOnLaunch,这使得每次启动的行为都如同为每个未释放的分配调用了 cudaMemFreeAsync。

不可能在拥有图和另一个图中都释放分配。如果在同一图中释放了分配,则无法向另一个图添加释放节点。如果在另一个图中释放了分配,则无法再向拥有图添加释放节点。

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

  • 无法删除图的节点和边。

  • 该图不能在子节点中使用。

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

  • 该图不能被克隆。

注意
  • 图对象不是线程安全的。 更多信息请点击此处

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

另请参阅

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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
dptr
- 要释放的内存地址
描述

创建一个新的内存释放节点并将其添加到graph使用numDependencies通过以下方式指定的依赖项pDependencies和指定的地址dptr。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。pDependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

cudaGraphAddMemFreeNode 将在以下情况下返回 cudaErrorInvalidValue:如果用户尝试释放

  • 在同一图中两次释放同一分配。

  • 释放并非由分配节点返回的地址。

  • 释放无效地址。

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

  • 无法删除图的节点和边。

  • 该图不能在子节点中使用。

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

  • 该图不能被克隆。

注意
  • 图对象不是线程安全的。 更多信息请点击此处

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

另请参阅

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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
pCopyParams
- 内存复制的参数
描述

创建一个新的 memcpy 节点并将其添加到graph使用numDependencies通过以下方式指定的依赖项pDependencies。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。pDependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

当图启动时,该节点将执行由以下内容描述的 memcpy:pCopyParams。 有关结构及其限制的描述,请参见 cudaMemcpy3D()

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

注意

另请参阅

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 )
创建一个 1D memcpy 节点并将其添加到图中。
参数
pGraphNode
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
dst
- 目标内存地址
src
- 源内存地址
count
- 要复制的字节大小
kind
- 传输类型
描述

创建一个新的 1D memcpy 节点并将其添加到graph使用numDependencies通过以下方式指定的依赖项pDependencies。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。pDependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

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

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

注意

另请参阅

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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
dst
- 目标内存地址
symbol
- 设备符号地址
count
- 要复制的字节大小
offset
- 从符号起始位置的字节偏移量
kind
- 传输类型
描述

创建一个新的 memcpy 节点,用于从symbol复制,并将其添加到graph使用numDependencies通过以下方式指定的依赖项pDependencies。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。pDependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

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

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

注意

另请参阅

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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
symbol
- 设备符号地址
src
- 源内存地址
count
- 要复制的字节大小
offset
- 从符号起始位置的字节偏移量
kind
- 传输类型
描述

创建一个新的 memcpy 节点,用于复制到symbol复制,并将其添加到graph使用numDependencies通过以下方式指定的依赖项pDependencies。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。pDependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

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

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

注意

另请参阅

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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
pMemsetParams
- 内存设置的参数
描述

创建一个新的 memset 节点并将其添加到graph使用numDependencies通过以下方式指定的依赖项pDependencies。 有可能numDependencies为 0,在这种情况下,节点将放置在图的根目录。pDependencies可能没有任何重复条目。 新节点的句柄将在pGraphNode.

元素大小必须为 1、2 或 4 字节。 当图启动时,该节点将执行由以下内容描述的 memset:pMemsetParams.

注意

另请参阅

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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
numDependencies
- 依赖项的数量
nodeParams
- 节点的规范
描述

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

nodeParams是一个标记联合。 节点类型应在type字段中指定,类型特定的参数在相应的联合成员中指定。 所有未使用的字节(即,reserved0以及所有超出已使用联合成员的字节)必须设置为零。 建议使用花括号初始化或 memset 来确保所有字节都已初始化。

请注意,对于某些节点类型,nodeParams可能包含在调用期间修改的“输出参数”,例如nodeParams->alloc.dptr.

新节点的句柄将在phGraphNode.

注意

另请参阅

中返回。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
- 返回新创建的节点
graph
- 要向其添加节点的图
pDependencies
- 节点的依赖项
dependencyData
- 依赖项的可选边缘数据。 如果为 NULL,则假定所有依赖项的数据为默认值(清零)。
numDependencies
- 依赖项的数量
nodeParams
- 节点的规范
描述

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

nodeParams是一个标记联合。 节点类型应在type字段中指定,类型特定的参数在相应的联合成员中指定。 所有未使用的字节(即,reserved0以及所有超出已使用联合成员的字节)必须设置为零。 建议使用花括号初始化或 memset 来确保所有字节都已初始化。

请注意,对于某些节点类型,nodeParams可能包含在调用期间修改的“输出参数”,例如nodeParams->alloc.dptr.

新节点的句柄将在phGraphNode.

注意

另请参阅

中返回。cudaGraphCreate, cudaGraphNodeSetParams, cudaGraphExecNodeSetParams

__host__cudaError_t cudaGraphChildGraphNodeGetGraph ( cudaGraphNode_t node, cudaGraph_t* pGraph )
获取子图节点的嵌入图的句柄。
参数
node
- 要获取嵌入图的节点
pGraph
- 存储图句柄的位置
描述

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

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

注意

另请参阅

cudaGraphAddChildGraphNode, cudaGraphNodeFindInClone

__host__cudaError_t cudaGraphClone ( cudaGraph_t* pGraphClone, cudaGraph_t originalGraph )
克隆一个图。
参数
pGraphClone
- 返回新创建的克隆图
originalGraph
- 要克隆的图
描述

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

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

注意

另请参阅

cudaGraphCreate, cudaGraphNodeFindInClone

__host__cudaError_t cudaGraphConditionalHandleCreate ( cudaGraphConditionalHandle* pHandle_out, cudaGraph_t graph, unsigned int  defaultLaunchValue = 0, unsigned int  flags = 0 )
创建一个条件句柄。
参数
pHandle_out
- 用于向调用者返回句柄的指针。
graph
defaultLaunchValue
- 条件变量的可选初始值。 如果在flags.
flags
- 中设置了 cudaGraphCondAssignDefault,则在每次图执行开始时应用。
描述

创建一个与hGraph.

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

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

注意
  • 图对象不是线程安全的。 更多信息请点击此处

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

另请参阅

cuGraphAddNode,

__host__cudaError_t cudaGraphCreate ( cudaGraph_t* pGraph, unsigned int  flags )
创建一个图。
参数
pGraph
- 返回新创建的图
flags
- 图创建标志,必须为 0
描述

创建一个空图,并通过pGraph.

注意

另请参阅

返回。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
- 从其创建 DOT 文件的图
path
- 写入 DOT 文件的路径
flags
- 来自 cudaGraphDebugDotFlags 的标志,用于指定要写入的附加节点信息
描述

使用提供的graph,写入到path图的 DOT 格式描述。默认情况下,这包括图拓扑、节点类型、节点 ID、内核名称和 memcpy 方向。flags可以指定写入有关每种节点类型的更多详细信息,例如参数值、内核属性、节点和函数句柄。

__host__cudaError_t cudaGraphDestroy ( cudaGraph_t graph )
销毁一个图。
参数
graph
- 要销毁的图
描述

销毁由以下项指定的图graph,以及它的所有节点。

注意

另请参阅

cudaGraphCreate

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

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

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

注意

另请参阅

cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddKernelNode, cudaGraphAddHostNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode

__host__cudaError_t cudaGraphEventRecordNodeGetEvent ( cudaGraphNode_t node, cudaEvent_t* event_out )
返回与事件记录节点关联的事件。
参数
node
event_out
- 指向返回事件的指针
描述

返回事件记录节点hNode中的事件event_out.

注意

另请参阅

cudaGraphAddEventRecordNode, cudaGraphEventRecordNodeSetEvent, cudaGraphEventWaitNodeGetEvent, cudaEventRecordWithFlags, cudaStreamWaitEvent

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

设置事件记录节点hNodetoevent.

注意

另请参阅

cudaGraphNodeSetParams, cudaGraphAddEventRecordNode, cudaGraphEventRecordNodeGetEvent, cudaGraphEventWaitNodeSetEvent, cudaEventRecordWithFlags, cudaStreamWaitEvent

__host__cudaError_t cudaGraphEventWaitNodeGetEvent ( cudaGraphNode_t node, cudaEvent_t* event_out )
返回与事件等待节点关联的事件。
参数
node
event_out
- 指向返回事件的指针
描述

返回事件等待节点hNode中的事件event_out.

注意

另请参阅

的事件

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

设置事件等待节点hNodetoevent.

注意

另请参阅

cudaGraphNodeSetParams, cudaGraphAddEventWaitNode, cudaGraphEventWaitNodeGetEvent, cudaGraphEventRecordNodeSetEvent, cudaEventRecordWithFlags, cudaStreamWaitEvent

__host__cudaError_t cudaGraphExecChildGraphNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, cudaGraph_t childGraph )
更新给定 graphExec 中子图节点中的节点参数。
参数
hGraphExec
- 要在其中设置指定节点的可执行图
node
- 来自用于实例化 graphExec 的图的主机节点
childGraph
- 提供更新参数的图
描述

更新由node中的事件hGraphExec表示的工作,就像节点图包含子图的节点在实例化时的参数一样。node必须保留在用于实例化hGraphExec的图中。到node和来自

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的node启动不受此调用的影响。

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

注意

另请参阅

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

__host__cudaError_t cudaGraphExecDestroy ( cudaGraphExec_t graphExec )
销毁一个可执行图。
参数
graphExec
- 要销毁的可执行图
描述

销毁由以下项指定的可执行图graphExec.

注意

另请参阅

cudaGraphInstantiate, cudaGraphUpload, cudaGraphLaunch

__host__cudaError_t cudaGraphExecEventRecordNodeSetEvent ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, cudaEvent_t event )
设置给定 graphExec 中事件记录节点的事件。
参数
hGraphExec
- 要在其中设置指定节点的可执行图
hNode
- 来自从中实例化 graphExec 的图的事件记录节点
event
- 要使用的更新事件
描述

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

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的hNode启动不受此调用的影响。

注意

另请参阅

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
- 要在其中设置指定节点的可执行图
hNode
- 来自从中实例化 graphExec 的图的事件等待节点
event
- 要使用的更新事件
描述

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

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的hNode启动不受此调用的影响。

注意

另请参阅

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
- 要在其中设置指定节点的可执行图
hNode
- 来自从中实例化 graphExec 的图的信号量信号节点
nodeParams
- 要设置的更新参数
描述

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

hNode不得从原始图中移除。

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的hNode启动不受此调用的影响。

不支持更改nodeParams->numExtSems

注意

另请参阅

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
- 要在其中设置指定节点的可执行图
hNode
- 来自从中实例化 graphExec 的图的信号量等待节点
nodeParams
- 要设置的更新参数
描述

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

hNode不得从原始图中移除。

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的hNode启动不受此调用的影响。

不支持更改nodeParams->numExtSems

注意

另请参阅

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
- 要查询的可执行图
flags
- 返回实例化标志
描述

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

注意

另请参阅

cudaGraphInstantiate, cudaGraphInstantiateWithFlags, cudaGraphInstantiateWithParams

__host__cudaError_t cudaGraphExecHostNodeSetParams ( cudaGraphExec_t hGraphExec, cudaGraphNode_t node, const cudaHostNodeParams* pNodeParams )
设置给定 graphExec 中主机节点的参数。
参数
hGraphExec
- 要在其中设置指定节点的可执行图
node
- 来自用于实例化 graphExec 的图的主机节点
pNodeParams
- 要设置的更新参数
描述

更新由node中的事件hGraphExec如同node已包含pNodeParams在实例化时。node必须保留在用于实例化hGraphExec的图中。到node和来自

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的node启动不受此调用的影响。

注意

另请参阅

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
- 要在其中设置指定节点的可执行图
node
- 来自 graphExec 实例化的图的内核节点
pNodeParams
- 要设置的更新参数
描述

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

node绝不能从原始图中删除。所有nodeParams字段可能会更改,但以下限制适用于func更新

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

  • 最初其函数未使用 CUDA 动态并行性的节点无法更新为使用 CDP 的函数

  • 最初其函数未进行设备端更新调用的节点无法更新为进行设备端更新调用的函数。

  • 中返回。如果hGraphExec未针对设备启动进行实例化,最初其函数未使用设备端 cudaGraphLaunch() 的节点无法更新为使用设备端 cudaGraphLaunch() 的函数,除非该节点与在实例化时包含此类调用的节点位于同一设备上。如果在实例化时不存在此类调用,则根本无法执行这些更新。

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的node启动不受此调用的影响。

中返回。如果node是一个设备可更新的内核节点,下一次上传/启动hGraphExec将覆盖任何先前的设备端更新。此外,当设备可更新的内核节点正在从设备更新时,对其应用主机更新将导致未定义的行为。

注意

另请参阅

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
- 要在其中设置指定节点的可执行图
node
- 来自用于实例化 graphExec 的图的 Memcpy 节点
pNodeParams
- 要设置的更新参数
描述

更新由node中的事件hGraphExec如同node已包含pNodeParams在实例化时。node必须保留在用于实例化hGraphExec的图中。到node和来自

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

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的node启动不受此调用的影响。

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

注意

另请参阅

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
- 要在其中设置指定节点的可执行图
node
- 来自用于实例化 graphExec 的图的 Memcpy 节点
dst
- 目标内存地址
src
- 源内存地址
count
- 要复制的字节大小
kind
- 传输类型
描述

更新由node中的事件hGraphExec如同node已包含实例化时给定的参数。node必须保留在用于实例化hGraphExec的图中。到node和来自

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

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的node启动不受此调用的影响。

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

注意

另请参阅

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
- 要在其中设置指定节点的可执行图
node
- 来自用于实例化 graphExec 的图的 Memcpy 节点
dst
- 目标内存地址
symbol
- 设备符号地址
count
- 要复制的字节大小
offset
- 从符号起始位置的字节偏移量
kind
- 传输类型
描述

更新由node中的事件hGraphExec如同node已包含实例化时给定的参数。node必须保留在用于实例化hGraphExec的图中。到node和来自

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

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的node启动不受此调用的影响。

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

注意

另请参阅

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
- 要在其中设置指定节点的可执行图
node
- 来自用于实例化 graphExec 的图的 Memcpy 节点
symbol
- 设备符号地址
src
- 源内存地址
count
- 要复制的字节大小
offset
- 从符号起始位置的字节偏移量
kind
- 传输类型
描述

更新由node中的事件hGraphExec如同node已包含实例化时给定的参数。node必须保留在用于实例化hGraphExec的图中。到node和来自

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

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的node启动不受此调用的影响。

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

注意

另请参阅

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
- 要在其中设置指定节点的可执行图
node
- 来自用于实例化 graphExec 的图的 Memset 节点
pNodeParams
- 要设置的更新参数
描述

更新由node中的事件hGraphExec如同node已包含pNodeParams在实例化时。node必须保留在用于实例化hGraphExec的图中。到node和来自

不支持零大小操作。

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

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

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的node启动不受此调用的影响。

注意

另请参阅

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
- 在其中更新指定节点的可执行图
node
- 来自 graphExec 实例化的图的对应节点
nodeParams
- 要设置的更新参数
描述

设置可执行图中节点的参数graphExec。节点由非可执行图中的相应节点node在从中实例化可执行图的非可执行图中。node不得从原始图中移除。

的已更改边缘将被忽略。graphExec修改仅影响graphExec的未来启动。已经排队或正在运行的node启动不受此调用的影响。

对可执行图上的参数允许的更改如下

节点类型

允许的更改

内核

请参阅 cudaGraphExecKernelNodeSetParams

memcpy

如果在一context中分配,则为一维副本的地址; 请参阅 cudaGraphExecMemcpyNodeSetParams

memset

如果在一context中分配,则为一维 memset 的地址; 请参阅 cudaGraphExecMemsetNodeSetParams

主机

不受限制

子图

拓扑结构必须匹配,并且限制以递归方式应用; 请参阅 cudaGraphExecUpdate

事件等待

不受限制

事件记录

不受限制

外部信号量信号

信号量操作的数量不能更改

外部信号量等待

信号量操作的数量不能更改

内存分配

API 不支持

内存释放

API 不支持

注意

另请参阅

cudaGraphAddNode, cudaGraphNodeSetParamscudaGraphExecUpdate, cudaGraphInstantiate

__host__cudaError_t cudaGraphExecUpdate ( cudaGraphExec_t hGraphExec, cudaGraph_t hGraph, cudaGraphExecUpdateResultInfo* resultInfo )
检查是否可以使用图形更新可执行图形,并在可能的情况下执行更新。
参数
hGraphExec
要更新的实例化图
hGraph
包含更新参数的图
resultInfo
错误信息结构
描述

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

限制

  • 内核节点
    • 函数的所属上下文不能更改。

    • 最初其函数未使用 CUDA 动态并行性的节点无法更新为使用 CDP 的函数。

    • 最初其函数未进行设备端更新调用的节点无法更新为进行设备端更新调用的函数。

    • 协作节点不能更新为非协作节点,反之亦然。

    • 如果图形是使用 cudaGraphInstantiateFlagUseNodePriority 实例化的,则优先级属性不能更改。在将优先级值钳制到设备支持的范围之前,对原始请求的优先级值进行相等性检查。

    • 中返回。如果hGraphExec未针对设备启动进行实例化,最初其函数未使用设备端 cudaGraphLaunch() 的节点无法更新为使用设备端 cudaGraphLaunch() 的函数,除非该节点与在实例化时包含此类调用的节点位于同一设备上。如果在实例化时不存在此类调用,则根本无法执行这些更新。

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

  • Memset 和 memcpy 节点
    • 分配/映射操作数的 CUDA 设备不能更改。

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

    • 对于 2d memset,只能更新地址和赋值。

    • 对于 1d memsets,也允许更新维度,但如果由此产生的操作无法映射到已为节点分配的工作资源,则可能会失败。

  • 额外的 memcpy 节点限制
    • 不支持更改源或目标内存类型(即 CU_MEMORYTYPE_DEVICE、CU_MEMORYTYPE_ARRAY 等)。

  • 条件节点
    • 不支持更改节点参数。

    • 更改条件体图中的节点参数须遵守上述规则。

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

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

cudaGraphExecUpdate 设置了 result 成员,如果resultInfo在以下情况下返回 cudaGraphExecUpdateErrorTopologyChanged

  • 直接位于hGraphExechGraph中的节点计数不同,在这种情况下,resultInfo->errorNode 将设置为 NULL。

  • hGraphhGraph拥有更多的退出节点,在这种情况下,resultInfo->errorNode 将设置为 hGraph 中的一个退出节点。

  • 中的一个节点hGraph与其配对的来自hGraphExec的节点具有不同数量的依赖项,在这种情况下,resultInfo->errorNode 将设置为来自hGraph.

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

cudaGraphExecUpdate 设置result 成员,如果传递了无效值,则返回resultInfoto

  • cudaGraphExecUpdateError。

  • 如果图拓扑已更改,则返回 cudaGraphExecUpdateErrorTopologyChanged

  • 如果节点类型已更改,则返回 cudaGraphExecUpdateErrorNodeTypeChanged,在这种情况下hErrorNode_out将设置为来自hGraph.

  • 如果内核节点的功能已更改 (CUDA driver < 11.2),则返回 cudaGraphExecUpdateErrorFunctionChanged

  • 如果内核的 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。

注意

另请参阅

cudaGraphInstantiate

__host__cudaError_t cudaGraphExternalSemaphoresSignalNodeGetParams ( cudaGraphNode_t hNode, cudaExternalSemaphoreSignalNodeParams* params_out )
返回外部信号量信号节点的参数。
参数
hNode
- 获取参数的节点
params_out
- 指向返回参数的指针
描述

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

注意

另请参阅

cudaLaunchKernel, cudaGraphAddExternalSemaphoresSignalNode, cudaGraphExternalSemaphoresSignalNodeSetParams, cudaGraphAddExternalSemaphoresWaitNode, cudaSignalExternalSemaphoresAsync, cudaWaitExternalSemaphoresAsync

__host__cudaError_t cudaGraphExternalSemaphoresSignalNodeSetParams ( cudaGraphNode_t hNode, const cudaExternalSemaphoreSignalNodeParams* nodeParams )
设置外部信号量信号节点的参数。
参数
hNode
- 要设置参数的节点
nodeParams
- 要复制的参数
描述

设置外部信号量信号节点的参数hNodetonodeParams.

注意

另请参阅

cudaGraphNodeSetParams, cudaGraphAddExternalSemaphoresSignalNode, cudaGraphExternalSemaphoresSignalNodeSetParams, cudaGraphAddExternalSemaphoresWaitNode, cudaSignalExternalSemaphoresAsync, cudaWaitExternalSemaphoresAsync

__host__cudaError_t cudaGraphExternalSemaphoresWaitNodeGetParams ( cudaGraphNode_t hNode, cudaExternalSemaphoreWaitNodeParams* params_out )
返回外部信号量等待节点的参数。
参数
hNode
- 获取参数的节点
params_out
- 指向返回参数的指针
描述

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

注意

另请参阅

cudaLaunchKernel, cudaGraphAddExternalSemaphoresWaitNode, cudaGraphExternalSemaphoresWaitNodeSetParams, cudaGraphAddExternalSemaphoresWaitNode, cudaSignalExternalSemaphoresAsync, cudaWaitExternalSemaphoresAsync

__host__cudaError_t cudaGraphExternalSemaphoresWaitNodeSetParams ( cudaGraphNode_t hNode, const cudaExternalSemaphoreWaitNodeParams* nodeParams )
设置外部信号量等待节点的参数。
参数
hNode
- 要设置参数的节点
nodeParams
- 要复制的参数
描述

设置外部信号量等待节点的参数hNodetonodeParams.

注意

另请参阅

cudaGraphNodeSetParams, cudaGraphAddExternalSemaphoresWaitNode, cudaGraphExternalSemaphoresWaitNodeSetParams, cudaGraphAddExternalSemaphoresWaitNode, cudaSignalExternalSemaphoresAsync, cudaWaitExternalSemaphoresAsync

__host__cudaError_t cudaGraphGetEdges ( cudaGraph_t graph, cudaGraphNode_t* from, cudaGraphNode_t* to, size_t* numEdges )
返回图的依赖边。
参数
graph
- 获取边的图
from
- 返回边端点的位置
to
- 返回边端点的位置
numEdges
- 请参阅说明
描述

返回的依赖边列表。边通过fromto中相应的索引返回;也就是说,to[i] 中的节点依赖于from[i] 中的节点。fromtonumEdges都可以为 NULL,在这种情况下,此函数仅返回numEdges中的边数。否则,将填充numEdges个条目。如果fromto高于实际边数,则numEdges.

注意

另请参阅

中的剩余条目将设置为 NULL,并且实际返回的边数将写入

__host__cudaError_t cudaGraphGetEdges_v2 ( cudaGraph_t graph, cudaGraphNode_t* from, cudaGraphNode_t* to, cudaGraphEdgeData* edgeData, size_t* numEdges )
返回图的依赖边 (12.3+)。
参数
graph
- 获取边的图
from
- 返回边端点的位置
to
- 返回边端点的位置
edgeData
- 返回边数据的可选位置
numEdges
- 请参阅说明
描述

返回的依赖边列表。边通过from, toedgeData中相应的索引返回;也就是说,to[i] 中的节点依赖于from[i] 与数据edgeData[i] 中的节点。fromtonumEdges都可以为 NULL,在这种情况下,此函数仅返回numEdges中的边数。否则,将填充numEdges个条目。如果fromto高于实际边数,则numEdges. edgeData可以单独为 NULL,在这种情况下,边必须都具有默认(归零)边数据。尝试通过 NULL 进行有损查询edgeData将导致 cudaErrorLossyQuery。如果edgeData为非 NULL,则fromto也必须为非 NULL。

注意

另请参阅

中的剩余条目将设置为 NULL,并且实际返回的边数将写入

__host__cudaError_t cudaGraphGetNodes ( cudaGraph_t graph, cudaGraphNode_t* nodes, size_t* numNodes )
返回图的节点。
参数
graph
- 要查询的图
nodes
- 指向返回节点的指针
numNodes
- 请参阅说明
描述

返回节点数。nodes可以为 NULL,在这种情况下,此函数将返回numNodes都可以为 NULL,在这种情况下,此函数仅返回numNodes中的边数。否则,将填充numNodes中的节点数。如果nodes高于实际节点数,则numNodes.

注意

另请参阅

中的剩余条目将设置为 NULL,并且实际获取的节点数将返回到

__host__cudaError_t cudaGraphGetRootNodes ( cudaGraph_t graph, cudaGraphNode_t* pRootNodes, size_t* pNumRootNodes )
返回图的根节点。
参数
graph
- 要查询的图
pRootNodes
- 指向返回根节点的指针
pNumRootNodes
- 请参阅说明
描述

返回根节点数。pRootNodes可以为 NULL,在这种情况下,此函数将返回pNumRootNodes都可以为 NULL,在这种情况下,此函数仅返回pNumRootNodes中的边数。否则,将填充pNumRootNodes中的根节点数。如果pRootNodes高于实际节点数,则pNumRootNodes.

注意

另请参阅

高于实际根节点数,则

__host__cudaError_t cudaGraphHostNodeGetParams ( cudaGraphNode_t node, cudaHostNodeParams* pNodeParams )
返回主机节点的参数。
参数
node
- 获取参数的节点
pNodeParams
- 指向返回参数的指针
描述

返回主机节点的参数node中的事件pNodeParams.

注意

另请参阅

cudaLaunchHostFunc, cudaGraphAddHostNode, cudaGraphHostNodeSetParams

__host__cudaError_t cudaGraphHostNodeSetParams ( cudaGraphNode_t node, const cudaHostNodeParams* pNodeParams )
设置主机节点的参数。
参数
node
- 要设置参数的节点
pNodeParams
- 要复制的参数
描述

设置主机节点的参数nodetonodeParams.

注意

另请参阅

cudaGraphNodeSetParams, cudaLaunchHostFunc, cudaGraphAddHostNode, cudaGraphHostNodeGetParams

__host__cudaError_t cudaGraphInstantiate ( cudaGraphExec_t* pGraphExec, cudaGraph_t graph, unsigned long long flags = 0 )
从图中创建可执行图。
参数
pGraphExec
- 返回实例化的图
graph
- 要实例化的图
flags
- 用于控制实例化的标志。请参阅 CUgraphInstantiate_flags
描述

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

在调用期间,将复制flags中返回。参数控制实例化和后续图启动的行为。有效的标志为

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

中返回。如果graph包含任何分配或释放节点,则对于该图,一次最多只能存在一个可执行图。尝试在销毁第一个可执行图之前使用 cudaGraphExecDestroy 实例化第二个可执行图将导致错误。如果graph包含任何设备可更新的内核节点,情况也是如此。

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

  • 图的节点必须驻留在单个设备上。

  • 图只能包含内核节点、memcpy 节点、memset 节点和子图节点。

  • 图不能为空,并且必须至少包含一个内核、memcpy 或 memset 节点。特定于操作的限制在下面概述。

  • 内核节点
    • 不允许使用 CUDA 动态并行。

    • 只要不使用 MPS,就允许协同启动。

  • Memcpy 节点
    • 仅允许涉及设备内存和/或pinned device-mapped host memory 的复制。

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

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

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

注意

另请参阅

cudaGraphInstantiateWithFlags, cudaGraphCreate, cudaGraphUpload, cudaGraphLaunch, cudaGraphExecDestroy

__host__cudaError_t cudaGraphInstantiateWithFlags ( cudaGraphExec_t* pGraphExec, cudaGraph_t graph, unsigned long long flags = 0 )
从图中创建可执行图。
参数
pGraphExec
- 返回实例化的图
graph
- 要实例化的图
flags
- 用于控制实例化的标志。请参阅 CUgraphInstantiate_flags
描述

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

在调用期间,将复制flags中返回。参数控制实例化和后续图启动的行为。有效的标志为

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

中返回。如果graph包含任何分配或释放节点,则对于该图,一次最多只能存在一个可执行图。尝试在销毁第一个可执行图之前使用 cudaGraphExecDestroy 实例化第二个可执行图将导致错误。如果graph包含任何设备可更新的内核节点,情况也是如此。

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

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

  • 图的节点必须驻留在单个设备上。

  • 图只能包含内核节点、memcpy 节点、memset 节点和子图节点。

  • 图不能为空,并且必须至少包含一个内核、memcpy 或 memset 节点。特定于操作的限制在下面概述。

  • 内核节点
    • 不允许使用 CUDA 动态并行。

    • 只要不使用 MPS,就允许协同启动。

  • Memcpy 节点
    • 仅允许涉及设备内存和/或pinned device-mapped host memory 的复制。

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

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

注意

另请参阅

cudaGraphInstantiate, cudaGraphCreate, cudaGraphUpload, cudaGraphLaunch, cudaGraphExecDestroy

__host__cudaError_t cudaGraphInstantiateWithParams ( cudaGraphExec_t* pGraphExec, cudaGraph_t graph, cudaGraphInstantiateParams* instantiateParams )
从图中创建可执行图。
参数
pGraphExec
- 返回实例化的图
graph
- 要实例化的图
instantiateParams
- 实例化参数
描述

graph根据instantiateParams结构将实例化为可执行图。该图会针对之前未验证的任何结构约束或节点内约束进行验证。如果实例化成功,则实例化的图的句柄将在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() 的内核,这将导致错误。

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

  • 图的节点必须驻留在单个设备上。

  • 图只能包含内核节点、memcpy 节点、memset 节点和子图节点。

  • 图不能为空,并且必须至少包含一个内核、memcpy 或 memset 节点。特定于操作的限制在下面概述。

  • 内核节点
    • 不允许使用 CUDA 动态并行。

    • 只要不使用 MPS,就允许协同启动。

  • Memcpy 节点
    • 仅允许涉及设备内存和/或pinned device-mapped host memory 的复制。

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

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

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

  • cudaGraphInstantiateError,如果传递了无效值或发生了意外错误(函数返回值描述了该错误)。errNode_out将设置为 NULL。

  • cudaGraphInstantiateInvalidStructure,如果图结构无效。errNode_out将设置为其中一个违规节点。

  • cudaGraphInstantiateNodeOperationNotSupported,如果图是为设备启动而实例化的,但包含不受支持的节点类型的节点,或者执行不受支持操作的节点,例如在内核节点中使用 CUDA 动态并行。errNode_out将设置为此节点。

  • cudaGraphInstantiateMultipleDevicesNotSupported,如果图是为设备启动而实例化的,但一个节点的设备与另一个节点的设备不同。如果图不是为设备启动而实例化的,并且它包含从多个设备调用设备端 cudaGraphLaunch() 的内核,也可能返回此错误。errNode_out将设置为此节点。

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

注意

另请参阅

cudaGraphCreate, cudaGraphInstantiate, cudaGraphInstantiateWithFlags, cudaGraphExecDestroy

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

cudaSuccess, cudaErrorInvalidContext

描述

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

注意

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

另请参阅

cudaAccessPolicyWindow

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

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

注意

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

另请参阅

cudaAccessPolicyWindow

__host__cudaError_t cudaGraphKernelNodeGetParams ( cudaGraphNode_t node, cudaKernelNodeParams* pNodeParams )
返回内核节点的参数。
参数
node
- 获取参数的节点
pNodeParams
- 指向返回参数的指针
描述

返回内核节点的参数node中的事件pNodeParams。在kernelParamsextra返回的数组在pNodeParams以及它指向的参数值,都归节点所有。此内存保持有效,直到节点被销毁或其参数被修改,并且不应直接修改。使用 cudaGraphKernelNodeSetParams 更新此节点的参数。

参数将包含以下之一kernelParamsextra取决于最近在节点上设置的是哪一个。

注意

另请参阅

cudaLaunchKernel, cudaGraphAddKernelNode, cudaGraphKernelNodeSetParams

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

设置属性attr在节点上hNode从对应的属性value.

注意

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

另请参阅

cudaAccessPolicyWindow

__device__cudaError_t cudaGraphKernelNodeSetEnabled ( cudaGraphDeviceNode_t node, bool  enable )
启用或禁用给定的内核节点。
参数
node
- 要更新的节点
enable
- 是否启用或禁用节点
返回值

cudaSucces, cudaErrorInvalidValue

描述

启用或禁用node基于enableenable如果 `enable` 为 true,节点将被启用;如果为 false,节点将被禁用。禁用的节点在执行期间将充当 NOP。node必须是设备可更新的,并且必须与调用内核位于同一设备上。

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

注意

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

另请参阅

cudaGraphKernelNodeSetParam, cudaGraphKernelNodeSetGridDim, cudaGraphKernelNodeUpdatesApply

__device__cudaError_t cudaGraphKernelNodeSetGridDim ( cudaGraphDeviceNode_t node, dim3 gridDim )
更新给定内核节点的网格维度。
参数
node
- 要更新的节点
gridDim
- 要设置的网格维度
返回值

cudaSucces, cudaErrorInvalidValue

描述

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

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

注意

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

另请参阅

cudaGraphKernelNodeSetParam, cudaGraphKernelNodeSetEnabled, cudaGraphKernelNodeUpdatesApply

template < typename T >

__device__cudaError_t cudaGraphKernelNodeSetParam ( cudaGraphDeviceNode_t node, size_t offset, const T& value ) [inline]
更新给定内核节点的内核参数。
参数
node
- 要更新的节点
offset
- 进行更新的参数偏移量
value
- 要写入的参数值
返回值

cudaSucces, cudaErrorInvalidValue

描述

更新内核参数nodeoffsettovalue. node必须是设备可更新的,并且必须与调用内核位于同一设备上。

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

注意

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

另请参阅

etblGraphKernelNodeSetEnabled, etblGraphKernelNodeSetGridDim, etblGraphKernelNodeUpdatesApply

__device__cudaError_t cudaGraphKernelNodeSetParam ( cudaGraphDeviceNode_t node, size_t offset, const void* value, size_t size )
更新给定内核节点的内核参数。
参数
node
- 要更新的节点
offset
- 进行更新的参数偏移量
value
- 包含要写入参数的缓冲区
size
- 要更新的字节大小
返回值

cudaSucces, cudaErrorInvalidValue

描述

更新size内核参数中的字节数nodeoffset为以下内容value. node必须是设备可更新的,并且必须与调用内核位于同一设备上。

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

注意

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

另请参阅

cudaGraphKernelNodeSetEnabled, cudaGraphKernelNodeSetGridDim, cudaGraphKernelNodeUpdatesApply

__host__cudaError_t cudaGraphKernelNodeSetParams ( cudaGraphNode_t node, const cudaKernelNodeParams* pNodeParams )
设置内核节点的参数。
参数
node
- 要设置参数的节点
pNodeParams
- 要复制的参数
描述

设置内核节点的参数nodetopNodeParams.

注意

另请参阅

cudaGraphNodeSetParams, cudaLaunchKernel, cudaGraphAddKernelNode, cudaGraphKernelNodeGetParams

__device__cudaError_t cudaGraphKernelNodeUpdatesApply ( const cudaGraphKernelNodeUpdate* updates, size_t updateCount )
批量应用多个内核节点更新。
参数
更新
- 要应用的更新
updateCount
- 要应用的更新数量
返回值

cudaSucces, cudaErrorInvalidValue

描述

基于以下信息批量应用一个或多个内核节点更新更新. updateCount指定要应用的更新数量。中的每个条目更新必须指定要更新的节点、要应用的更新类型以及该更新类型的参数。有关更多详细信息,请参阅 cudaGraphKernelNodeUpdate 的文档。

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

注意

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

另请参阅

cudaGraphKernelNodeSetParam, cudaGraphKernelNodeSetEnabled, cudaGraphKernelNodeSetGridDim

__host____device__cudaError_t cudaGraphLaunch ( cudaGraphExec_t graphExec, cudaStream_t stream )
在流中启动可执行图。
参数
graphExec
- 要启动的可执行图
stream
- 在其中启动图的流
描述

执行graphExec中的事件streamgraphExec`graphExec` 可能一次只执行一个实例。每次启动都在 `stream` 中任何先前的工作之后以及任何先前的启动之后排序streamgraphExec要并发执行图,必须将其多次实例化为多个可执行图。

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

注意

另请参阅

cudaGraphInstantiate, cudaGraphUpload, cudaGraphExecDestroy

__host__cudaError_t cudaGraphMemAllocNodeGetParams ( cudaGraphNode_t node, cudaMemAllocNodeParams* params_out )
返回内存分配节点的参数。
参数
node
- 获取参数的节点
params_out
- 指向返回参数的指针
描述

返回内存分配节点的参数hNode中的事件params_out。在poolPropsaccessDescs中返回的params_out`poolProps` 和 `accessDescs`,都归节点所有。此内存保持有效,直到节点被销毁。返回的参数不得修改。

注意

另请参阅

cudaGraphAddMemAllocNode, cudaGraphMemFreeNodeGetParams

__host__cudaError_t cudaGraphMemFreeNodeGetParams ( cudaGraphNode_t node, void* dptr_out )
返回内存释放节点的参数。
参数
node
- 获取参数的节点
dptr_out
- 返回设备地址的指针
描述

返回内存释放节点的地址hNode中的事件dptr_out.

注意

另请参阅

cudaGraphAddMemFreeNode, cudaGraphMemFreeNodeGetParams

__host__cudaError_t cudaGraphMemcpyNodeGetParams ( cudaGraphNode_t node, cudaMemcpy3DParms* pNodeParams )
返回 memcpy 节点的参数。
参数
node
- 获取参数的节点
pNodeParams
- 指向返回参数的指针
描述

返回 memcpy 节点的参数node中的事件pNodeParams.

注意

另请参阅

cudaMemcpy3D, cudaGraphAddMemcpyNode, cudaGraphMemcpyNodeSetParams

__host__cudaError_t cudaGraphMemcpyNodeSetParams ( cudaGraphNode_t node, const cudaMemcpy3DParms* pNodeParams )
设置 memcpy 节点的参数。
参数
node
- 要设置参数的节点
pNodeParams
- 要复制的参数
描述

设置 memcpy 节点的参数nodetopNodeParams.

注意

另请参阅

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
- 要设置参数的节点
dst
- 目标内存地址
src
- 源内存地址
count
- 要复制的字节大小
kind
- 传输类型
描述

设置 memcpy 节点的参数node到由提供的参数描述的复制。

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

注意

另请参阅

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
- 要设置参数的节点
dst
- 目标内存地址
symbol
- 设备符号地址
count
- 要复制的字节大小
offset
- 从符号起始位置的字节偏移量
kind
- 传输类型
描述

设置 memcpy 节点的参数node到由提供的参数描述的复制。

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

注意

另请参阅

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 )
设置 memcpy 节点的参数以复制到设备上的符号。
参数
node
- 要设置参数的节点
symbol
- 设备符号地址
src
- 源内存地址
count
- 要复制的字节大小
offset
- 从符号起始位置的字节偏移量
kind
- 传输类型
描述

设置 memcpy 节点的参数node到由提供的参数描述的复制。

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

注意

另请参阅

cudaMemcpyToSymbol, cudaGraphMemcpyNodeSetParams, cudaGraphMemcpyNodeSetParamsFromSymbol, cudaGraphAddMemcpyNode, cudaGraphMemcpyNodeGetParams

__host__cudaError_t cudaGraphMemsetNodeGetParams ( cudaGraphNode_t node, cudaMemsetParams* pNodeParams )
返回 memset 节点的参数。
参数
node
- 获取参数的节点
pNodeParams
- 指向返回参数的指针
描述

返回 memset 节点的参数node中的事件pNodeParams.

注意

另请参阅

cudaMemset2D, cudaGraphAddMemsetNode, cudaGraphMemsetNodeSetParams

__host__cudaError_t cudaGraphMemsetNodeSetParams ( cudaGraphNode_t node, const cudaMemsetParams* pNodeParams )
设置 memset 节点的参数。
参数
node
- 要设置参数的节点
pNodeParams
- 要复制的参数
描述

设置 memset 节点的参数nodetopNodeParams.

注意

另请参阅

cudaGraphNodeSetParams, cudaMemset2D, cudaGraphAddMemsetNode, cudaGraphMemsetNodeGetParams

__host__cudaError_t cudaGraphNodeFindInClone ( cudaGraphNode_t* pNode, cudaGraphNode_t originalNode, cudaGraph_t clonedGraph )
查找节点的克隆版本。
参数
pNode
- 返回克隆节点的句柄
originalNode
- 原始节点的句柄
clonedGraph
- 要查询的克隆图
描述

此函数返回 `clonedGraph` 中的节点clonedGraph对应于originalNode原始图中的 `originalNode`。

clonedGraph`clonedGraph` 必须已从originalGraph通过 cudaGraphClone 克隆。originalNode`originalNode` 必须在originalGraph调用 cudaGraphClone 时存在于原始图 `originalGraph` 中,并且 `clonedGraph` 中的相应克隆节点clonedGraph不得已被删除。然后通过pNode.

注意

另请参阅

cudaGraphClone

__host__cudaError_t cudaGraphNodeGetDependencies ( cudaGraphNode_t node, cudaGraphNode_t* pDependencies, size_t* pNumDependencies )
返回节点的依赖项。
参数
node
- 要查询的节点
pDependencies
- 返回依赖项的指针
pNumDependencies
- 请参阅说明
描述

返回节点依赖项。pDependencies`pDependencies` 可以为 NULL,在这种情况下,此函数将返回 `node` 中的依赖项数量pNumDependencies都可以为 NULL,在这种情况下,此函数仅返回pNumDependencies中的边数。否则,将填充pNumDependencies如果提供的 `pDependencies` 大于实际依赖项数量,则 `pDependencies` 中的其余条目pDependencies高于实际节点数,则pNumDependencies.

注意

另请参阅

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
- 要查询的节点
pDependencies
- 返回依赖项的指针
edgeData
- 可选数组,用于返回每个依赖项的边数据
pNumDependencies
- 请参阅说明
描述

返回节点依赖项。pDependencies`pDependencies` 可以为 NULL,在这种情况下,此函数将返回 `node` 中的依赖项数量pNumDependencies都可以为 NULL,在这种情况下,此函数仅返回pNumDependencies中的边数。否则,将填充pNumDependencies如果提供的 `pDependencies` 大于实际依赖项数量,则 `pDependencies` 中的其余条目pDependencies高于实际节点数,则pNumDependencies.

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

注意

另请参阅

cudaGraphNodeGetDependentNodes, cudaGraphGetNodes, cudaGraphGetRootNodes, cudaGraphGetEdges, cudaGraphAddDependencies, cudaGraphRemoveDependencies

__host__cudaError_t cudaGraphNodeGetDependentNodes ( cudaGraphNode_t node, cudaGraphNode_t* pDependentNodes, size_t* pNumDependentNodes )
返回节点的被依赖节点。
参数
node
- 要查询的节点
pDependentNodes
- 指向返回被依赖节点的指针
pNumDependentNodes
- 请参阅说明
描述

返回节点被依赖节点。pDependentNodes可以为 NULL,在这种情况下,此函数将返回被依赖节点的数量,存储在pNumDependentNodes都可以为 NULL,在这种情况下,此函数仅返回pNumDependentNodes中的边数。否则,将填充pNumDependentNodes高于被依赖节点的实际数量,则 `pDependentNodes` 中的剩余条目pDependentNodes高于实际节点数,则pNumDependentNodes.

注意

另请参阅

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
- 要查询的节点
pDependentNodes
- 指向返回被依赖节点的指针
edgeData
- 可选指针,用于返回被依赖节点的边数据
pNumDependentNodes
- 请参阅说明
描述

返回节点被依赖节点。pDependentNodes可以为 NULL,在这种情况下,此函数将返回被依赖节点的数量,存储在pNumDependentNodes都可以为 NULL,在这种情况下,此函数仅返回pNumDependentNodes中的边数。否则,将填充pNumDependentNodes高于被依赖节点的实际数量,则 `pDependentNodes` 中的剩余条目pDependentNodes高于实际节点数,则pNumDependentNodes.

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

注意

另请参阅

cudaGraphNodeGetDependencies, cudaGraphGetNodes, cudaGraphGetRootNodes, cudaGraphGetEdges, cudaGraphAddDependencies, cudaGraphRemoveDependencies

__host__cudaError_t cudaGraphNodeGetEnabled ( cudaGraphExec_t hGraphExec, cudaGraphNode_t hNode, unsigned int* isEnabled )
查询给定 graphExec 中的节点是否已启用。
参数
hGraphExec
- 要在其中设置指定节点的可执行图
hNode
- 从实例化 graphExec 的图中的节点
isEnabled
- 用于返回节点启用状态的位置
描述

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

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

hNode不得从原始图中移除。

注意

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

注意

另请参阅

cudaGraphNodeSetEnabled, cudaGraphExecUpdate, cudaGraphInstantiatecudaGraphLaunch

__host__cudaError_t cudaGraphNodeGetType ( cudaGraphNode_t node, cudaGraphNodeType ** pType )
返回节点的类型。
参数
node
- 要查询的节点
pType
- 指向返回节点类型的指针
描述

返回节点 `node` 的节点类型。node中的事件pType.

注意

另请参阅

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
- 要在其中设置指定节点的可执行图
hNode
- 从实例化 graphExec 的图中的节点
isEnabled
- 如果 != 0,则节点已启用,否则节点已禁用
描述

设置 `hNode`hNode为启用或禁用状态。禁用的节点在重新启用之前在功能上等同于空节点。禁用/启用节点不会影响现有的节点参数。

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

hNode不得从原始图中移除。

的已更改边缘将被忽略。hGraphExec修改仅影响hGraphExec的未来启动。已经排队或正在运行的hNode启动不受此调用的影响。

注意

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

注意

另请参阅

cudaGraphNodeGetEnabled, cudaGraphExecUpdate, cudaGraphInstantiatecudaGraphLaunch

__host__cudaError_t cudaGraphNodeSetParams ( cudaGraphNode_t node, cudaGraphNodeParams* nodeParams )
更新图节点的参数。
参数
node
- 要设置参数的节点
nodeParams
- 要复制的参数
描述

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

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

注意

另请参阅

cudaGraphAddNode, cudaGraphExecNodeSetParams

__host__cudaError_t cudaGraphReleaseUserObject ( cudaGraph_t graph, cudaUserObject_t object, unsigned int  count = 1 )
从图中释放用户对象引用。
参数
graph
- 将释放引用的图
object
- 要释放引用的用户对象
count
- 要释放的引用数量,通常为 1。必须为非零且不大于 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
- 从中移除依赖边的图
from
- 提供依赖项的节点数组
to
- 依赖节点数组
numDependencies
- 要移除的依赖边数量
描述

要移除的依赖边数量pDependencies由 `numDependencies` 定义。numDependencies`from` 和 `to` 中的元素pFrompTo在对应索引处定义依赖项。 中的每个节点pFrompTo必须属于graph.

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

注意

另请参阅

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
- 从中移除依赖边的图
from
- 提供依赖项的节点数组
to
- 依赖节点数组
edgeData
- 可选的边数据数组。如果为 NULL,则假定边数据为默认值(清零)。
numDependencies
- 要移除的依赖边数量
描述

要移除的依赖边数量pDependencies由 `numDependencies` 定义。numDependencies`from` 和 `to` 中的元素pFrompTo在对应索引处定义依赖项。 中的每个节点pFrompTo必须属于graph.

中返回。如果numDependencies为 0,则将忽略pFrompTo`from` 和 `to` 中的元素将被忽略。指定图中不存在的边,且数据与 `edgeData` 匹配edgeData,将导致错误。edgeData`edgeData` 可以为 NULL,这等效于为每条边传递默认值(清零)数据。

注意

另请参阅

cudaGraphAddDependencies, cudaGraphGetEdges, cudaGraphNodeGetDependencies, cudaGraphNodeGetDependentNodes

__host__cudaError_t cudaGraphRetainUserObject ( cudaGraph_t graph, cudaUserObject_t object, unsigned int  count = 1, unsigned int  flags = 0 )
从图中保留用户对象引用。
参数
graph
- 要将引用关联到的图
object
- 要保留引用的用户对象
count
- 要添加到图中的引用数量,通常为 1。必须为非零且不大于 INT_MAX。
flags
- 可选标志 cudaGraphUserObjectMove 从调用线程传输引用,而不是创建新引用。传递 0 以创建新引用。
描述

创建或移动将由 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 )
在流中上传可执行图。
描述

上传 `graphExec`hGraphExec到设备,在 `stream` 中。hStream而不执行它。相同 `graphExec` 的上传hGraphExec将被序列化。每次上传都排在 `stream` 中之前的所有工作之后。hStreamhGraphExec使用由 `graphExec` 缓存的内存stream来支持 `graphExec` 拥有的分配。graphExec.

注意

另请参阅

cudaGraphInstantiate, cudaGraphLaunch, cudaGraphExecDestroy

__host__cudaError_t cudaUserObjectCreate ( cudaUserObject_t* object_out, void* ptr, cudaHostFn_t destroy, unsigned int  initialRefcount, unsigned int  flags )
创建用户对象。
参数
object_out
- 用于返回用户对象句柄的位置
ptr
- 要传递给销毁函数的指针
destroy
- 当用户对象不再使用时,用于释放用户对象的回调函数
initialRefcount
- 创建对象时使用的初始引用计数,通常为 1。初始引用由调用线程拥有。
flags
- 目前,需要传递 cudaUserObjectNoDestructorSync,这是唯一定义的标志。这表明销毁回调不能被任何 CUDA API 等待。需要同步回调的用户应手动发出其完成信号。
描述

使用指定的析构函数回调和初始引用计数创建用户对象。初始引用由调用者拥有。

析构函数回调不能进行 CUDA API 调用,并且应避免阻塞行为,因为它们由共享内部线程执行。如果这样做不会阻塞通过 CUDA 调度的任务的向前进度,则可以向另一个线程发出信号以执行此类操作。

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

另请参阅

cudaUserObjectRetain, cudaUserObjectRelease, cudaGraphRetainUserObject, cudaGraphReleaseUserObject, cudaGraphCreate

__host__cudaError_t cudaUserObjectRelease ( cudaUserObject_t object, unsigned int  count = 1 )
释放用户对象引用。
参数
object
- 要释放的对象
count
- 要释放的引用数量,通常为 1。必须为非零且不大于 INT_MAX。
描述

释放调用者拥有的用户对象引用。如果引用计数达到零,则会调用对象的析构函数。

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

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

另请参阅

cudaUserObjectCreate, cudaUserObjectRetain, cudaGraphRetainUserObject, cudaGraphReleaseUserObject, cudaGraphCreate

__host__cudaError_t cudaUserObjectRetain ( cudaUserObject_t object, unsigned int  count = 1 )
保留用户对象引用。
参数
object
- 要保留的对象
count
- 要保留的引用数量,通常为 1。必须为非零且不大于 INT_MAX。
描述

保留用户对象的新引用。新引用由调用者拥有。

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

另请参阅

cudaUserObjectCreate, cudaUserObjectRelease, cudaGraphRetainUserObject, cudaGraphReleaseUserObject, cudaGraphCreate