6.24. 图管理

本节介绍底层CUDA驱动应用程序编程接口的图管理功能。

Functions

CUresult cuDeviceGetGraphMemAttribute ( CUdevice device, CUgraphMem_attribute attr, void* value )
Query asynchronous allocation attributes related to graphs.
CUresult cuDeviceGraphMemTrim ( CUdevice device )
Free unused memory that was cached on the specified device for use with graphs back to the OS.
CUresult cuDeviceSetGraphMemAttribute ( CUdevice device, CUgraphMem_attribute attr, void* value )
Set asynchronous allocation attributes related to graphs.
CUresult cuGraphAddBatchMemOpNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_BATCH_MEM_OP_NODE_PARAMS* nodeParams )
Creates a batch memory operation node and adds it to a graph.
CUresult cuGraphAddChildGraphNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, CUgraph childGraph )
Creates a child graph node and adds it to a graph.
CUresult cuGraphAddDependencies ( CUgraph hGraph, const CUgraphNode* from, const CUgraphNode* to, size_t numDependencies )
Adds dependency edges to a graph.
CUresult cuGraphAddDependencies_v2 ( CUgraph hGraph, const CUgraphNode* from, const CUgraphNode* to, const CUgraphEdgeData* edgeData, size_t numDependencies )
Adds dependency edges to a graph (12.3+).
CUresult cuGraphAddEmptyNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies )
Creates an empty node and adds it to a graph.
CUresult cuGraphAddEventRecordNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, CUevent event )
Creates an event record node and adds it to a graph.
CUresult cuGraphAddEventWaitNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, CUevent event )
Creates an event wait node and adds it to a graph.
CUresult cuGraphAddExternalSemaphoresSignalNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS* nodeParams )
Creates an external semaphore signal node and adds it to a graph.
CUresult cuGraphAddExternalSemaphoresWaitNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_EXT_SEM_WAIT_NODE_PARAMS* nodeParams )
Creates an external semaphore wait node and adds it to a graph.
CUresult cuGraphAddHostNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_HOST_NODE_PARAMS* nodeParams )
Creates a host execution node and adds it to a graph.
CUresult cuGraphAddKernelNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_KERNEL_NODE_PARAMS* nodeParams )
Creates a kernel execution node and adds it to a graph.
CUresult cuGraphAddMemAllocNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, CUDA_MEM_ALLOC_NODE_PARAMS* nodeParams )
Creates an allocation node and adds it to a graph.
CUresult cuGraphAddMemFreeNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, CUdeviceptr dptr )
Creates a memory free node and adds it to a graph.
CUresult cuGraphAddMemcpyNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_MEMCPY3D* copyParams, CUcontext ctx )
Creates a memcpy node and adds it to a graph.
CUresult cuGraphAddMemsetNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_MEMSET_NODE_PARAMS* memsetParams, CUcontext ctx )
Creates a memset node and adds it to a graph.
CUresult cuGraphAddNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, CUgraphNodeParams* nodeParams )
Adds a node of arbitrary type to a graph.
CUresult cuGraphAddNode_v2 ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, const CUgraphEdgeData* dependencyData, size_t numDependencies, CUgraphNodeParams* nodeParams )
Adds a node of arbitrary type to a graph (12.3+).
CUresult cuGraphBatchMemOpNodeGetParams ( CUgraphNode hNode, CUDA_BATCH_MEM_OP_NODE_PARAMS* nodeParams_out )
Returns a batch mem op node's parameters.
CUresult cuGraphBatchMemOpNodeSetParams ( CUgraphNode hNode, const CUDA_BATCH_MEM_OP_NODE_PARAMS* nodeParams )
Sets a batch mem op node's parameters.
CUresult cuGraphChildGraphNodeGetGraph ( CUgraphNode hNode, CUgraph* phGraph )
Gets a handle to the embedded graph of a child graph node.
CUresult cuGraphClone ( CUgraph* phGraphClone, CUgraph originalGraph )
Clones a graph.
CUresult cuGraphConditionalHandleCreate ( CUgraphConditionalHandle* pHandle_out, CUgraph hGraph, CUcontext ctx, unsigned int  defaultLaunchValue, unsigned int  flags )
Create a conditional handle.
CUresult cuGraphCreate ( CUgraph* phGraph, unsigned int  flags )
Creates a graph.
CUresult cuGraphDebugDotPrint ( CUgraph hGraph, const char* path, unsigned int  flags )
Write a DOT file describing graph structure.
CUresult cuGraphDestroy ( CUgraph hGraph )
Destroys a graph.
CUresult cuGraphDestroyNode ( CUgraphNode hNode )
Remove a node from the graph.
CUresult cuGraphEventRecordNodeGetEvent ( CUgraphNode hNode, CUevent* event_out )
Returns the event associated with an event record node.
CUresult cuGraphEventRecordNodeSetEvent ( CUgraphNode hNode, CUevent event )
Sets an event record node's event.
CUresult cuGraphEventWaitNodeGetEvent ( CUgraphNode hNode, CUevent* event_out )
Returns the event associated with an event wait node.
CUresult cuGraphEventWaitNodeSetEvent ( CUgraphNode hNode, CUevent event )
Sets an event wait node's event.
CUresult cuGraphExecBatchMemOpNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_BATCH_MEM_OP_NODE_PARAMS* nodeParams )
Sets the parameters for a batch mem op node in the given graphExec.
CUresult cuGraphExecChildGraphNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, CUgraph childGraph )
Updates node parameters in the child graph node in the given graphExec.
CUresult cuGraphExecDestroy ( CUgraphExec hGraphExec )
Destroys an executable graph.
CUresult cuGraphExecEventRecordNodeSetEvent ( CUgraphExec hGraphExec, CUgraphNode hNode, CUevent event )
Sets the event for an event record node in the given graphExec.
CUresult cuGraphExecEventWaitNodeSetEvent ( CUgraphExec hGraphExec, CUgraphNode hNode, CUevent event )
Sets the event for an event wait node in the given graphExec.
CUresult cuGraphExecExternalSemaphoresSignalNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS* nodeParams )
Sets the parameters for an external semaphore signal node in the given graphExec.
CUresult cuGraphExecExternalSemaphoresWaitNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_EXT_SEM_WAIT_NODE_PARAMS* nodeParams )
Sets the parameters for an external semaphore wait node in the given graphExec.
CUresult cuGraphExecGetFlags ( CUgraphExec hGraphExec, cuuint64_t* flags )
Query the instantiation flags of an executable graph.
CUresult cuGraphExecHostNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_HOST_NODE_PARAMS* nodeParams )
Sets the parameters for a host node in the given graphExec.
CUresult cuGraphExecKernelNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_KERNEL_NODE_PARAMS* nodeParams )
Sets the parameters for a kernel node in the given graphExec.
CUresult cuGraphExecMemcpyNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_MEMCPY3D* copyParams, CUcontext ctx )
Sets the parameters for a memcpy node in the given graphExec.
CUresult cuGraphExecMemsetNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_MEMSET_NODE_PARAMS* memsetParams, CUcontext ctx )
Sets the parameters for a memset node in the given graphExec.
CUresult cuGraphExecNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, CUgraphNodeParams* nodeParams )
Update's a graph node's parameters in an instantiated graph.
CUresult cuGraphExecUpdate ( CUgraphExec hGraphExec, CUgraph hGraph, CUgraphExecUpdateResultInfo* resultInfo )
Check whether an executable graph can be updated with a graph and perform the update if possible.
CUresult cuGraphExternalSemaphoresSignalNodeGetParams ( CUgraphNode hNode, CUDA_EXT_SEM_SIGNAL_NODE_PARAMS* params_out )
Returns an external semaphore signal node's parameters.
CUresult cuGraphExternalSemaphoresSignalNodeSetParams ( CUgraphNode hNode, const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS* nodeParams )
Sets an external semaphore signal node's parameters.
CUresult cuGraphExternalSemaphoresWaitNodeGetParams ( CUgraphNode hNode, CUDA_EXT_SEM_WAIT_NODE_PARAMS* params_out )
Returns an external semaphore wait node's parameters.
CUresult cuGraphExternalSemaphoresWaitNodeSetParams ( CUgraphNode hNode, const CUDA_EXT_SEM_WAIT_NODE_PARAMS* nodeParams )
Sets an external semaphore wait node's parameters.
CUresult cuGraphGetEdges ( CUgraph hGraph, CUgraphNode* from, CUgraphNode* to, size_t* numEdges )
Returns a graph's dependency edges.
CUresult cuGraphGetEdges_v2 ( CUgraph hGraph, CUgraphNode* from, CUgraphNode* to, CUgraphEdgeData* edgeData, size_t* numEdges )
Returns a graph's dependency edges (12.3+).
CUresult cuGraphGetNodes ( CUgraph hGraph, CUgraphNode* nodes, size_t* numNodes )
Returns a graph's nodes.
CUresult cuGraphGetRootNodes ( CUgraph hGraph, CUgraphNode* rootNodes, size_t* numRootNodes )
Returns a graph's root nodes.
CUresult cuGraphHostNodeGetParams ( CUgraphNode hNode, CUDA_HOST_NODE_PARAMS* nodeParams )
Returns a host node's parameters.
CUresult cuGraphHostNodeSetParams ( CUgraphNode hNode, const CUDA_HOST_NODE_PARAMS* nodeParams )
Sets a host node's parameters.
CUresult cuGraphInstantiate ( CUgraphExec* phGraphExec, CUgraph hGraph, unsigned long long flags )
Creates an executable graph from a graph.
CUresult cuGraphInstantiateWithParams ( CUgraphExec* phGraphExec, CUgraph hGraph, CUDA_GRAPH_INSTANTIATE_PARAMS* instantiateParams )
Creates an executable graph from a graph.
CUresult cuGraphKernelNodeCopyAttributes ( CUgraphNode dst, CUgraphNode src )
Copies attributes from source node to destination node.
CUresult cuGraphKernelNodeGetAttribute ( CUgraphNode hNode, CUkernelNodeAttrID attr, CUkernelNodeAttrValue* value_out )
Queries node attribute.
CUresult cuGraphKernelNodeGetParams ( CUgraphNode hNode, CUDA_KERNEL_NODE_PARAMS* nodeParams )
Returns a kernel node's parameters.
CUresult cuGraphKernelNodeSetAttribute ( CUgraphNode hNode, CUkernelNodeAttrID attr, const CUkernelNodeAttrValue* value )
Sets node attribute.
CUresult cuGraphKernelNodeSetParams ( CUgraphNode hNode, const CUDA_KERNEL_NODE_PARAMS* nodeParams )
Sets a kernel node's parameters.
CUresult cuGraphLaunch ( CUgraphExec hGraphExec, CUstream hStream )
Launches an executable graph in a stream.
CUresult cuGraphMemAllocNodeGetParams ( CUgraphNode hNode, CUDA_MEM_ALLOC_NODE_PARAMS* params_out )
Returns a memory alloc node's parameters.
CUresult cuGraphMemFreeNodeGetParams ( CUgraphNode hNode, CUdeviceptr* dptr_out )
Returns a memory free node's parameters.
CUresult cuGraphMemcpyNodeGetParams ( CUgraphNode hNode, CUDA_MEMCPY3D* nodeParams )
Returns a memcpy node's parameters.
CUresult cuGraphMemcpyNodeSetParams ( CUgraphNode hNode, const CUDA_MEMCPY3D* nodeParams )
Sets a memcpy node's parameters.
CUresult cuGraphMemsetNodeGetParams ( CUgraphNode hNode, CUDA_MEMSET_NODE_PARAMS* nodeParams )
Returns a memset node's parameters.
CUresult cuGraphMemsetNodeSetParams ( CUgraphNode hNode, const CUDA_MEMSET_NODE_PARAMS* nodeParams )
Sets a memset node's parameters.
CUresult cuGraphNodeFindInClone ( CUgraphNode* phNode, CUgraphNode hOriginalNode, CUgraph hClonedGraph )
Finds a cloned version of a node.
CUresult cuGraphNodeGetDependencies ( CUgraphNode hNode, CUgraphNode* dependencies, size_t* numDependencies )
Returns a node's dependencies.
CUresult cuGraphNodeGetDependencies_v2 ( CUgraphNode hNode, CUgraphNode* dependencies, CUgraphEdgeData* edgeData, size_t* numDependencies )
Returns a node's dependencies (12.3+).
CUresult cuGraphNodeGetDependentNodes ( CUgraphNode hNode, CUgraphNode* dependentNodes, size_t* numDependentNodes )
Returns a node's dependent nodes.
CUresult cuGraphNodeGetDependentNodes_v2 ( CUgraphNode hNode, CUgraphNode* dependentNodes, CUgraphEdgeData* edgeData, size_t* numDependentNodes )
Returns a node's dependent nodes (12.3+).
CUresult cuGraphNodeGetEnabled ( CUgraphExec hGraphExec, CUgraphNode hNode, unsigned int* isEnabled )
Query whether a node in the given graphExec is enabled.
CUresult cuGraphNodeGetType ( CUgraphNode hNode, CUgraphNodeType* type )
Returns a node's type.
CUresult cuGraphNodeSetEnabled ( CUgraphExec hGraphExec, CUgraphNode hNode, unsigned int  isEnabled )
Enables or disables the specified node in the given graphExec.
CUresult cuGraphNodeSetParams ( CUgraphNode hNode, CUgraphNodeParams* nodeParams )
Update's a graph node's parameters.
CUresult cuGraphReleaseUserObject ( CUgraph graph, CUuserObject object, unsigned int  count )
Release a user object reference from a graph.
CUresult cuGraphRemoveDependencies ( CUgraph hGraph, const CUgraphNode* from, const CUgraphNode* to, size_t numDependencies )
Removes dependency edges from a graph.
CUresult cuGraphRemoveDependencies_v2 ( CUgraph hGraph, const CUgraphNode* from, const CUgraphNode* to, const CUgraphEdgeData* edgeData, size_t numDependencies )
Removes dependency edges from a graph (12.3+).
CUresult cuGraphRetainUserObject ( CUgraph graph, CUuserObject object, unsigned int  count, unsigned int  flags )
Retain a reference to a user object from a graph.
CUresult cuGraphUpload ( CUgraphExec hGraphExec, CUstream hStream )
Uploads an executable graph in a stream.
CUresult cuUserObjectCreate ( CUuserObject* object_out, void* ptr, CUhostFn destroy, unsigned int  initialRefcount, unsigned int  flags )
Create a user object.
CUresult cuUserObjectRelease ( CUuserObject object, unsigned int  count )
Release a reference to a user object.
CUresult cuUserObjectRetain ( CUuserObject object, unsigned int  count )
Retain a reference to a user object.

Functions

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

有效属性包括:

另请参阅:

cuDeviceSetGraphMemAttribute, cuGraphAddMemAllocNode, cuGraphAddMemFreeNode

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

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

另请参阅:

cuGraphAddMemAllocNode, cuGraphAddMemFreeNode, cuDeviceSetGraphMemAttribute, cuDeviceGetGraphMemAttribute

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

有效属性包括:

另请参阅:

cuDeviceGetGraphMemAttribute, cuGraphAddMemAllocNode, cuGraphAddMemFreeNode

CUresult cuGraphAddBatchMemOpNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_BATCH_MEM_OP_NODE_PARAMS* nodeParams )
创建一个批量内存操作节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
nodeParams
- Parameters for the node
描述

创建一个新的批量内存操作节点,并将其添加到hGraph中,通过dependencies指定numDependencies个依赖项,并在nodeParams中指定参数。当numDependencies为0时,该节点将被放置在图的根位置。dependencies中不能有任何重复条目。新节点的句柄将在phGraphNode中返回。

当节点被添加时,nodeParams内部的paramArray会被复制,因此在调用返回后可以释放它。

Note:

Warning: Improper use of this API may deadlock the application. Synchronization ordering established through this API is not visible to CUDA. CUDA tasks that are (even indirectly) ordered by this API should also have that order expressed with CUDA-visible dependencies such as events. This ensures that the scheduler does not serialize them in an improper order. For more information, see the Stream Memory Operations section in the programming guide(https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html).

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

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

另请参阅:

cuGraphAddNode, cuStreamBatchMemOp, cuStreamWaitValue32, cuStreamWriteValue32, cuStreamWaitValue64, cuStreamWriteValue64, cuGraphBatchMemOpNodeGetParams, cuGraphBatchMemOpNodeSetParams, cuGraphCreate, cuGraphDestroyNode, cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddKernelNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode

CUresult cuGraphAddChildGraphNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, CUgraph childGraph )
创建一个子图节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
childGraph
- The graph to clone into this node
描述

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

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

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

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

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

另请参阅:

cuGraphAddNode, cuGraphChildGraphNodeGetGraph, cuGraphCreate, cuGraphDestroyNode, cuGraphAddEmptyNode, cuGraphAddKernelNode, cuGraphAddHostNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode, cuGraphClone

CUresult cuGraphAddDependencies ( CUgraph hGraph, const CUgraphNode* from, const CUgraphNode* to, size_t numDependencies )
向图中添加依赖边。
参数
hGraph
- 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定义。fromto中对应索引位置的元素定义一个依赖关系。fromto中的每个节点都必须属于hGraph

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

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

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

另请参阅:

cuGraphRemoveDependencies, cuGraphGetEdges, cuGraphNodeGetDependencies, cuGraphNodeGetDependentNodes

CUresult cuGraphAddDependencies_v2 ( CUgraph hGraph, const CUgraphNode* from, const CUgraphNode* to, const CUgraphEdgeData* edgeData, size_t numDependencies )
向图中添加依赖边(12.3+版本)。
参数
hGraph
- 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定义。fromto中对应索引位置的元素共同定义一个依赖关系。fromto中的每个节点都必须属于hGraph

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

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

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

另请参阅:

cuGraphRemoveDependencies, cuGraphGetEdges, cuGraphNodeGetDependencies, cuGraphNodeGetDependentNodes

CUresult cuGraphAddEmptyNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies )
创建一个空节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
描述

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

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

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

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

另请参阅:

cuGraphAddNode, cuGraphCreate, cuGraphDestroyNode, cuGraphAddChildGraphNode, cuGraphAddKernelNode, cuGraphAddHostNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode

CUresult cuGraphAddEventRecordNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, CUevent event )
创建一个事件记录节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
event
- Event for the node
描述

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

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

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

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

另请参阅:

cuGraphAddNode, cuGraphAddEventWaitNode, cuEventRecordWithFlags, cuStreamWaitEvent, cuGraphCreate, cuGraphDestroyNode, cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddKernelNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode

CUresult cuGraphAddEventWaitNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, CUevent event )
创建一个事件等待节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
event
- Event for the node
描述

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

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

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

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

另请参阅:

cuGraphAddNode, cuGraphAddEventRecordNode, cuEventRecordWithFlags, cuStreamWaitEvent, cuGraphCreate, cuGraphDestroyNode, cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddKernelNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode

CUresult cuGraphAddExternalSemaphoresSignalNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS* nodeParams )
创建一个外部信号量信号节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
nodeParams
- Parameters for the node
描述

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

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

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

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

另请参阅:

cuGraphAddNode, cuGraphExternalSemaphoresSignalNodeGetParams, cuGraphExternalSemaphoresSignalNodeSetParams, cuGraphExecExternalSemaphoresSignalNodeSetParams, cuGraphAddExternalSemaphoresWaitNode, cuImportExternalSemaphore, cuSignalExternalSemaphoresAsync, cuWaitExternalSemaphoresAsync, cuGraphCreate, cuGraphDestroyNode, cuGraphAddEventRecordNode, cuGraphAddEventWaitNode, cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddKernelNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode

CUresult cuGraphAddExternalSemaphoresWaitNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_EXT_SEM_WAIT_NODE_PARAMS* nodeParams )
创建一个外部信号量等待节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
nodeParams
- Parameters for the node
描述

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

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

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

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

另请参阅:

cuGraphAddNode, cuGraphExternalSemaphoresWaitNodeGetParams, cuGraphExternalSemaphoresWaitNodeSetParams, cuGraphExecExternalSemaphoresWaitNodeSetParams, cuGraphAddExternalSemaphoresSignalNode, cuImportExternalSemaphore, cuSignalExternalSemaphoresAsync, cuWaitExternalSemaphoresAsync, cuGraphCreate, cuGraphDestroyNode, cuGraphAddEventRecordNode, cuGraphAddEventWaitNode, cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddKernelNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode

CUresult cuGraphAddHostNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_HOST_NODE_PARAMS* nodeParams )
创建一个主机执行节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
nodeParams
- Parameters for the host node
描述

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

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

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

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

另请参阅:

cuGraphAddNode, cuLaunchHostFunc, cuGraphHostNodeGetParams, cuGraphHostNodeSetParams, cuGraphCreate, cuGraphDestroyNode, cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddKernelNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode

CUresult cuGraphAddKernelNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_KERNEL_NODE_PARAMS* nodeParams )
创建一个内核执行节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
nodeParams
- Parameters for the GPU execution node
描述

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

CUDA_KERNEL_NODE_PARAMS 结构体定义如下:

‎  typedef struct CUDA_KERNEL_NODE_PARAMS_st {
            CUfunction func;
            unsigned int gridDimX;
            unsigned int gridDimY;
            unsigned int gridDimZ;
            unsigned int blockDimX;
            unsigned int blockDimY;
            unsigned int blockDimZ;
            unsigned int sharedMemBytes;
            void **kernelParams;
            void **extra;
            CUkernel kern;
            CUcontext ctx;
        } CUDA_KERNEL_NODE_PARAMS;

当图形启动时,节点将在(gridDimX x gridDimY x gridDimZ)的块网格上调用内核func。每个块包含(blockDimX x blockDimY x blockDimZ)个线程。

sharedMemBytes 设置每个线程块可用的动态共享内存大小。

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

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

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

如果同时使用kernelParamsextra指定内核参数(即kernelParamsextra均非NULL),将返回错误CUDA_ERROR_INVALID_VALUE。如果对协作内核使用extra,也将返回CUDA_ERROR_INVALID_VALUE

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

Note:

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

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

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

另请参阅:

cuGraphAddNode, cuLaunchKernel, cuLaunchCooperativeKernel, cuGraphKernelNodeGetParams, cuGraphKernelNodeSetParams, cuGraphCreate, cuGraphDestroyNode, cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddHostNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode

CUresult cuGraphAddMemAllocNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, CUDA_MEM_ALLOC_NODE_PARAMS* nodeParams )
创建一个分配节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
nodeParams
- Parameters for the node
描述

创建一个新的分配节点并将其添加到hGraph中,通过dependencies指定numDependencies个依赖项,并在nodeParams中指定参数。numDependencies可以为0,这种情况下节点将被放置在图的根位置。dependencies中不能有任何重复条目。新节点的句柄将在phGraphNode中返回。

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

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

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

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

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

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

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

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

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

  • 该图无法被克隆。

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

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

另请参阅:

cuGraphAddNode, cuGraphAddMemFreeNode, cuGraphMemAllocNodeGetParams, cuDeviceGraphMemTrim, cuDeviceGetGraphMemAttribute, cuDeviceSetGraphMemAttribute, cuMemAllocAsync, cuMemFreeAsync, cuGraphCreate, cuGraphDestroyNode, cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddEventRecordNode, cuGraphAddEventWaitNode, cuGraphAddExternalSemaphoresSignalNode, cuGraphAddExternalSemaphoresWaitNode, cuGraphAddKernelNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode

CUresult cuGraphAddMemFreeNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, CUdeviceptr dptr )
创建一个内存空闲节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
dptr
- Address of memory to free
描述

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

cuGraphAddMemFreeNode 如果用户尝试释放以下内容,将返回 CUDA_ERROR_INVALID_VALUE

  • 在同一图中分配两次。

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

  • 无效地址。

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

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

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

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

  • 该图无法被克隆。

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

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

另请参阅:

cuGraphAddNode, cuGraphAddMemAllocNode, cuGraphMemFreeNodeGetParams, cuDeviceGraphMemTrim, cuDeviceGetGraphMemAttribute, cuDeviceSetGraphMemAttribute, cuMemAllocAsync, cuMemFreeAsync, cuGraphCreate, cuGraphDestroyNode, cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddEventRecordNode, cuGraphAddEventWaitNode, cuGraphAddExternalSemaphoresSignalNode, cuGraphAddExternalSemaphoresWaitNode, cuGraphAddKernelNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode

CUresult cuGraphAddMemcpyNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_MEMCPY3D* copyParams, CUcontext ctx )
创建一个memcpy节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
copyParams
- Parameters for the memory copy
ctx
- Context on which to run the node
描述

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

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

关于托管内存,Memcpy节点有一些额外的限制,如果系统中至少有一个设备的设备属性CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS值为零。如果一个或多个操作数引用托管内存,则不允许对这些操作数使用内存类型CU_MEMORYTYPE_UNIFIED。托管内存将被视为驻留在主机或设备上,具体取决于指定的内存类型。

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

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

另请参阅:

cuGraphAddNode, cuMemcpy3D, cuGraphMemcpyNodeGetParams, cuGraphMemcpyNodeSetParams, cuGraphCreate, cuGraphDestroyNode, cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddKernelNode, cuGraphAddHostNode, cuGraphAddMemsetNode

CUresult cuGraphAddMemsetNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, const CUDA_MEMSET_NODE_PARAMS* memsetParams, CUcontext ctx )
创建一个memset节点并将其添加到图中。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
memsetParams
- Parameters for the memory set
ctx
- Context on which to run the node
描述

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

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

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

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

另请参阅:

cuGraphAddNode, cuMemsetD2D32, cuGraphMemsetNodeGetParams, cuGraphMemsetNodeSetParams, cuGraphCreate, cuGraphDestroyNode, cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddKernelNode, cuGraphAddHostNode, cuGraphAddMemcpyNode

CUresult cuGraphAddNode ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, size_t numDependencies, CUgraphNodeParams* nodeParams )
向图中添加任意类型的节点。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- Dependencies of the node
numDependencies
- Number of dependencies
nodeParams
- Specification of the node
描述

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

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

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

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

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

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

另请参阅:

cuGraphCreate, cuGraphNodeSetParams, cuGraphExecNodeSetParams

CUresult cuGraphAddNode_v2 ( CUgraphNode* phGraphNode, CUgraph hGraph, const CUgraphNode* dependencies, const CUgraphEdgeData* dependencyData, size_t numDependencies, CUgraphNodeParams* nodeParams )
向图中添加任意类型的节点(12.3+版本)。
参数
phGraphNode
- Returns newly created node
hGraph
- Graph to which to add the node
dependencies
- 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
描述

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

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

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

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

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

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

另请参阅:

cuGraphCreate, cuGraphNodeSetParams, cuGraphExecNodeSetParams

CUresult cuGraphBatchMemOpNodeGetParams ( CUgraphNode hNode, CUDA_BATCH_MEM_OP_NODE_PARAMS* nodeParams_out )
返回一个批处理内存操作节点的参数。
参数
hNode
- Node to get the parameters for
nodeParams_out
- Pointer to return the parameters
描述

返回批处理内存操作节点hNode的参数到nodeParams_out中。nodeParams_out返回的paramArray归该节点所有。此内存保持有效,直到节点被销毁或其参数被修改,不应直接修改。使用cuGraphBatchMemOpNodeSetParams来更新此节点的参数。

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

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

另请参阅:

cuStreamBatchMemOp, cuGraphAddBatchMemOpNode, cuGraphBatchMemOpNodeSetParams

CUresult cuGraphBatchMemOpNodeSetParams ( CUgraphNode hNode, const CUDA_BATCH_MEM_OP_NODE_PARAMS* nodeParams )
设置批处理内存操作节点的参数。
参数
hNode
- Node to set the parameters for
nodeParams
- Parameters to copy
描述

将批处理内存操作节点hNode的参数设置为nodeParams

nodeParams内部的paramArray会被复制,因此在调用返回后可以释放它。

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

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

另请参阅:

cuGraphNodeSetParams, cuStreamBatchMemOp, cuGraphAddBatchMemOpNode, cuGraphBatchMemOpNodeGetParams

CUresult cuGraphChildGraphNodeGetGraph ( CUgraphNode hNode, CUgraph* phGraph )
获取子图节点中嵌入图的句柄。
参数
hNode
- Node to get the embedded graph for
phGraph
- Location to store a handle to the graph
描述

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

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

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

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

另请参阅:

cuGraphAddChildGraphNode, cuGraphNodeFindInClone

CUresult cuGraphClone ( CUgraph* phGraphClone, CUgraph originalGraph )
克隆一个图形。
参数
phGraphClone
- Returns newly created cloned graph
originalGraph
- Graph to clone
描述

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

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

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

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

另请参阅:

cuGraphCreate, cuGraphNodeFindInClone

CUresult cuGraphConditionalHandleCreate ( CUgraphConditionalHandle* pHandle_out, CUgraph hGraph, CUcontext ctx, unsigned int  defaultLaunchValue, unsigned int  flags )
创建一个条件句柄。
参数
pHandle_out
- Pointer used to return the handle to the caller.
hGraph
- Graph which will contain the conditional node using this handle.
ctx
- Context for the handle and associated conditional node.
defaultLaunchValue
- Optional initial value for the conditional variable. Applied at the beginning of each graph execution if CU_GRAPH_COND_ASSIGN_DEFAULT is set in flags.
flags
- Currently must be CU_GRAPH_COND_ASSIGN_DEFAULT or 0.
描述

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

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

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

句柄只能从与其关联的上下文中设置。

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

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

另请参阅:

cuGraphAddNode

CUresult cuGraphCreate ( CUgraph* phGraph, unsigned int  flags )
创建一个图形。
参数
phGraph
- Returns newly created graph
flags
- Graph creation flags, must be 0
描述

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

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

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

另请参阅:

cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddKernelNode, cuGraphAddHostNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode, cuGraphInstantiate, cuGraphDestroy, cuGraphGetNodes, cuGraphGetRootNodes, cuGraphGetEdges, cuGraphClone

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

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

CUresult cuGraphDestroy ( CUgraph hGraph )
销毁一个图形。
参数
hGraph
- Graph to destroy
描述

销毁由hGraph指定的图及其所有节点。

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

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

另请参阅:

cuGraphCreate

CUresult cuGraphDestroyNode ( CUgraphNode hNode )
从图中移除一个节点。
参数
hNode
- Node to remove
描述

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

属于包含分配或释放节点的图的节点无法被销毁。任何尝试这样做的操作都将返回一个错误。

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

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

另请参阅:

cuGraphAddChildGraphNode, cuGraphAddEmptyNode, cuGraphAddKernelNode, cuGraphAddHostNode, cuGraphAddMemcpyNode, cuGraphAddMemsetNode

CUresult cuGraphEventRecordNodeGetEvent ( CUgraphNode hNode, CUevent* event_out )
返回与事件记录节点关联的事件。
参数
hNode
- Node to get the event for
event_out
- Pointer to return the event
描述

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

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

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

另请参阅:

cuGraphAddEventRecordNode, cuGraphEventRecordNodeSetEvent, cuGraphEventWaitNodeGetEvent, cuEventRecordWithFlags, cuStreamWaitEvent

CUresult cuGraphEventRecordNodeSetEvent ( CUgraphNode hNode, CUevent event )
设置事件记录节点的事件。
参数
hNode
- Node to set the event for
event
- Event to use
描述

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

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

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

另请参阅:

cuGraphNodeSetParams, cuGraphAddEventRecordNode, cuGraphEventRecordNodeGetEvent, cuGraphEventWaitNodeSetEvent, cuEventRecordWithFlags, cuStreamWaitEvent

CUresult cuGraphEventWaitNodeGetEvent ( CUgraphNode hNode, CUevent* event_out )
返回与事件等待节点关联的事件。
参数
hNode
- Node to get the event for
event_out
- Pointer to return the event
描述

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

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

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

另请参阅:

cuGraphAddEventWaitNode, cuGraphEventWaitNodeSetEvent, cuGraphEventRecordNodeGetEvent, cuEventRecordWithFlags, cuStreamWaitEvent

CUresult cuGraphEventWaitNodeSetEvent ( CUgraphNode hNode, CUevent event )
设置事件等待节点的事件。
参数
hNode
- Node to set the event for
event
- Event to use
描述

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

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

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

另请参阅:

cuGraphNodeSetParams, cuGraphAddEventWaitNode, cuGraphEventWaitNodeGetEvent, cuGraphEventRecordNodeSetEvent, cuEventRecordWithFlags, cuStreamWaitEvent

CUresult cuGraphExecBatchMemOpNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_BATCH_MEM_OP_NODE_PARAMS* nodeParams )
为给定graphExec中的批量内存操作节点设置参数。
参数
hGraphExec
- The executable graph in which to set the specified node
hNode
- Batch mem op node from the graph from which graphExec was instantiated
nodeParams
- Updated Parameters to set
描述

设置可执行图hGraphExec中批处理内存操作节点的参数。该节点由不可执行图中对应的节点hNode标识,可执行图是从该不可执行图实例化而来的。

可执行图中操作上的以下字段可以修改:

op.waitValue.address op.waitValue.value[64] op.waitValue.flags 位对应等待类型(即CU_STREAM_WAIT_VALUE_FLUSH 位不可修改) op.writeValue.address op.writeValue.value[64]

其他字段,例如上下文、操作数量或类型,以及其他类型的操作(如内存屏障),可能无法修改。

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

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

nodeParams内部的paramArray会被复制,因此在调用返回后可以释放它。

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

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

另请参阅:

cuGraphExecNodeSetParams, cuStreamBatchMemOp, cuGraphAddBatchMemOpNode, cuGraphBatchMemOpNodeGetParams, cuGraphBatchMemOpNodeSetParams, cuGraphInstantiate

CUresult cuGraphExecChildGraphNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, CUgraph childGraph )
更新给定graphExec中子图节点的节点参数。
参数
hGraphExec
- The executable graph in which to set the specified node
hNode
- Host node from the graph which was used to instantiate graphExec
childGraph
- The graph supplying the updated parameters
描述

更新hGraphExec中由hNode表示的工作节点,使其在实例化时包含子图节点中的参数。hNode必须保留在用于实例化hGraphExec的图中。对hNode的输入输出边的修改将被忽略。

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

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

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

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

另请参阅:

cuGraphExecNodeSetParams, cuGraphAddChildGraphNode, cuGraphChildGraphNodeGetGraph, cuGraphExecKernelNodeSetParams, cuGraphExecMemcpyNodeSetParams, cuGraphExecMemsetNodeSetParams, cuGraphExecHostNodeSetParams, cuGraphExecEventRecordNodeSetEvent, cuGraphExecEventWaitNodeSetEvent, cuGraphExecExternalSemaphoresSignalNodeSetParams, cuGraphExecExternalSemaphoresWaitNodeSetParams, cuGraphExecUpdate, cuGraphInstantiate

CUresult cuGraphExecDestroy ( CUgraphExec hGraphExec )
销毁一个可执行图。
参数
hGraphExec
- Executable graph to destroy
描述

销毁由hGraphExec指定的可执行图及其所有可执行节点。如果该可执行图正在运行,它不会被终止,而是在完成后异步释放。

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

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

另请参阅:

cuGraphInstantiate, cuGraphUpload, cuGraphLaunch

CUresult cuGraphExecEventRecordNodeSetEvent ( CUgraphExec hGraphExec, CUgraphNode hNode, CUevent 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:
  • 图形对象不是线程安全的。更多信息

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

另请参阅:

cuGraphExecNodeSetParams, cuGraphAddEventRecordNode, cuGraphEventRecordNodeGetEvent, cuGraphEventWaitNodeSetEvent, cuEventRecordWithFlags, cuStreamWaitEvent, cuGraphExecKernelNodeSetParams, cuGraphExecMemcpyNodeSetParams, cuGraphExecMemsetNodeSetParams, cuGraphExecHostNodeSetParams, cuGraphExecChildGraphNodeSetParams, cuGraphExecEventWaitNodeSetEvent, cuGraphExecExternalSemaphoresSignalNodeSetParams, cuGraphExecExternalSemaphoresWaitNodeSetParams, cuGraphExecUpdate, cuGraphInstantiate

CUresult cuGraphExecEventWaitNodeSetEvent ( CUgraphExec hGraphExec, CUgraphNode hNode, CUevent 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:
  • 图形对象不是线程安全的。更多信息

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

另请参阅:

cuGraphExecNodeSetParams, cuGraphAddEventWaitNode, cuGraphEventWaitNodeGetEvent, cuGraphEventRecordNodeSetEvent, cuEventRecordWithFlags, cuStreamWaitEvent, cuGraphExecKernelNodeSetParams, cuGraphExecMemcpyNodeSetParams, cuGraphExecMemsetNodeSetParams, cuGraphExecHostNodeSetParams, cuGraphExecChildGraphNodeSetParams, cuGraphExecEventRecordNodeSetEvent, cuGraphExecExternalSemaphoresSignalNodeSetParams, cuGraphExecExternalSemaphoresWaitNodeSetParams, cuGraphExecUpdate, cuGraphInstantiate

CUresult cuGraphExecExternalSemaphoresSignalNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS* 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:
  • 图形对象不是线程安全的。更多信息

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

另请参阅:

cuGraphExecNodeSetParams, cuGraphAddExternalSemaphoresSignalNode, cuImportExternalSemaphore, cuSignalExternalSemaphoresAsync, cuWaitExternalSemaphoresAsync, cuGraphExecKernelNodeSetParams, cuGraphExecMemcpyNodeSetParams, cuGraphExecMemsetNodeSetParams, cuGraphExecHostNodeSetParams, cuGraphExecChildGraphNodeSetParams, cuGraphExecEventRecordNodeSetEvent, cuGraphExecEventWaitNodeSetEvent, cuGraphExecExternalSemaphoresWaitNodeSetParams, cuGraphExecUpdate, cuGraphInstantiate

CUresult cuGraphExecExternalSemaphoresWaitNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_EXT_SEM_WAIT_NODE_PARAMS* 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:
  • 图形对象不是线程安全的。更多信息

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

另请参阅:

cuGraphExecNodeSetParams, cuGraphAddExternalSemaphoresWaitNode, cuImportExternalSemaphore, cuSignalExternalSemaphoresAsync, cuWaitExternalSemaphoresAsync, cuGraphExecKernelNodeSetParams, cuGraphExecMemcpyNodeSetParams, cuGraphExecMemsetNodeSetParams, cuGraphExecHostNodeSetParams, cuGraphExecChildGraphNodeSetParams, cuGraphExecEventRecordNodeSetEvent, cuGraphExecEventWaitNodeSetEvent, cuGraphExecExternalSemaphoresSignalNodeSetParams, cuGraphExecUpdate, cuGraphInstantiate

CUresult cuGraphExecGetFlags ( CUgraphExec hGraphExec, cuuint64_t* flags )
查询可执行图的实例化标志。
参数
hGraphExec
- The executable graph to query
flags
- Returns the instantiation flags
描述

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

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

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

另请参阅:

cuGraphInstantiate, cuGraphInstantiateWithParams

CUresult cuGraphExecHostNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_HOST_NODE_PARAMS* nodeParams )
为给定graphExec中的主机节点设置参数。
参数
hGraphExec
- The executable graph in which to set the specified node
hNode
- Host node from the graph which was used to instantiate graphExec
nodeParams
- The updated parameters to set
描述

更新hGraphExec中由hNode表示的工作,就像hNode在实例化时包含nodeParams一样。hNode必须保留在用于实例化hGraphExec的图中。更改到hNode和从hNode出发的边将被忽略。

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

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

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

另请参阅:

cuGraphExecNodeSetParams, cuGraphAddHostNode, cuGraphHostNodeSetParams, cuGraphExecKernelNodeSetParams, cuGraphExecMemcpyNodeSetParams, cuGraphExecMemsetNodeSetParams, cuGraphExecChildGraphNodeSetParams, cuGraphExecEventRecordNodeSetEvent, cuGraphExecEventWaitNodeSetEvent, cuGraphExecExternalSemaphoresSignalNodeSetParams, cuGraphExecExternalSemaphoresWaitNodeSetParams, cuGraphExecUpdate, cuGraphInstantiate

CUresult cuGraphExecKernelNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_KERNEL_NODE_PARAMS* nodeParams )
为给定graphExec中的内核节点设置参数。
参数
hGraphExec
- The executable graph in which to set the specified node
hNode
- kernel node from the graph from which graphExec was instantiated
nodeParams
- Updated Parameters to set
描述

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

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

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

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

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

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

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

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

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

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

另请参阅:

cuGraphExecNodeSetParams, cuGraphAddKernelNode, cuGraphKernelNodeSetParams, cuGraphExecMemcpyNodeSetParams, cuGraphExecMemsetNodeSetParams, cuGraphExecHostNodeSetParams, cuGraphExecChildGraphNodeSetParams, cuGraphExecEventRecordNodeSetEvent, cuGraphExecEventWaitNodeSetEvent, cuGraphExecExternalSemaphoresSignalNodeSetParams, cuGraphExecExternalSemaphoresWaitNodeSetParams, cuGraphExecUpdate, cuGraphInstantiate

CUresult cuGraphExecMemcpyNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_MEMCPY3D* copyParams, CUcontext ctx )
为给定graphExec中的memcpy节点设置参数。
参数
hGraphExec
- The executable graph in which to set the specified node
hNode
- Memcpy node from the graph which was used to instantiate graphExec
copyParams
- The updated parameters to set
ctx
- Context on which to run the node
描述

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

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

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

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

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

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

另请参阅:

cuGraphExecNodeSetParams, cuGraphAddMemcpyNode, cuGraphMemcpyNodeSetParams, cuGraphExecKernelNodeSetParams, cuGraphExecMemsetNodeSetParams, cuGraphExecHostNodeSetParams, cuGraphExecChildGraphNodeSetParams, cuGraphExecEventRecordNodeSetEvent, cuGraphExecEventWaitNodeSetEvent, cuGraphExecExternalSemaphoresSignalNodeSetParams, cuGraphExecExternalSemaphoresWaitNodeSetParams, cuGraphExecUpdate, cuGraphInstantiate

CUresult cuGraphExecMemsetNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, const CUDA_MEMSET_NODE_PARAMS* memsetParams, CUcontext ctx )
为给定graphExec中的memset节点设置参数。
参数
hGraphExec
- The executable graph in which to set the specified node
hNode
- Memset node from the graph which was used to instantiate graphExec
memsetParams
- The updated parameters to set
ctx
- Context on which to run the node
描述

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

不支持零大小的操作。

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

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

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

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

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

另请参阅:

cuGraphExecNodeSetParams, cuGraphAddMemsetNode, cuGraphMemsetNodeSetParams, cuGraphExecKernelNodeSetParams, cuGraphExecMemcpyNodeSetParams, cuGraphExecHostNodeSetParams, cuGraphExecChildGraphNodeSetParams, cuGraphExecEventRecordNodeSetEvent, cuGraphExecEventWaitNodeSetEvent, cuGraphExecExternalSemaphoresSignalNodeSetParams, cuGraphExecExternalSemaphoresWaitNodeSetParams, cuGraphExecUpdate, cuGraphInstantiate

CUresult cuGraphExecNodeSetParams ( CUgraphExec hGraphExec, CUgraphNode hNode, CUgraphNodeParams* nodeParams )
在实例化的图中即时更新图节点的参数。
参数
hGraphExec
- The executable graph in which to update the specified node
hNode
- Corresponding node from the graph from which graphExec was instantiated
nodeParams
- Updated Parameters to set
描述

设置可执行图hGraphExec中节点的参数。该节点由不可执行图中对应的节点hNode标识,可执行图是从该不可执行图实例化而来。hNode不能已从原始图中移除。

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

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

节点类型

允许的变更

内核

参见 cuGraphExecKernelNodeSetParams

memcpy

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

memset

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

主机

无限制

子图

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

事件等待

无限制

事件记录

无限制

外部信号量信号

信号量操作数量不可更改

外部信号量等待

信号量操作数量不可更改

内存分配

API不支持

内存释放

API不支持

批量内存操作

等待操作的地址、值和操作类型;参见cuGraphExecBatchMemOpNodeSetParams

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

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

另请参阅:

cuGraphAddNode, cuGraphNodeSetParamscuGraphExecUpdate, cuGraphInstantiate

CUresult cuGraphExecUpdate ( CUgraphExec hGraphExec, CUgraph hGraph, CUgraphExecUpdateResultInfo* 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的功能。

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

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

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

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

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

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

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

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

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

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

  • External semaphore wait nodes and record nodes:
    • 不支持更改信号量的数量。

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

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

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

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

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

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

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

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

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

cuGraphExecUpdate 将 resultInfo 的结果成员设置为:

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

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

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

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

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

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

  • 如果节点的某些特性不受支持,例如节点类型或配置,则返回CU_GRAPH_EXEC_UPDATE_ERROR_NOT_SUPPORTED错误码, 此时hErrorNode_out会被设置为来自hGraph的该问题节点

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

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

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

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

另请参阅:

cuGraphInstantiate

CUresult cuGraphExternalSemaphoresSignalNodeGetParams ( CUgraphNode hNode, CUDA_EXT_SEM_SIGNAL_NODE_PARAMS* params_out )
返回外部信号量信号节点的参数。
参数
hNode
- Node to get the parameters for
params_out
- Pointer to return the parameters
描述

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

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

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

另请参阅:

cuLaunchKernel, cuGraphAddExternalSemaphoresSignalNode, cuGraphExternalSemaphoresSignalNodeSetParams, cuGraphAddExternalSemaphoresWaitNode, cuSignalExternalSemaphoresAsync, cuWaitExternalSemaphoresAsync

CUresult cuGraphExternalSemaphoresSignalNodeSetParams ( CUgraphNode hNode, const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS* nodeParams )
设置外部信号量信号节点的参数。
参数
hNode
- Node to set the parameters for
nodeParams
- Parameters to copy
描述

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

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

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

另请参阅:

cuGraphNodeSetParams, cuGraphAddExternalSemaphoresSignalNode, cuGraphExternalSemaphoresSignalNodeSetParams, cuGraphAddExternalSemaphoresWaitNode, cuSignalExternalSemaphoresAsync, cuWaitExternalSemaphoresAsync

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

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

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

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

另请参阅:

cuLaunchKernel, cuGraphAddExternalSemaphoresWaitNode, cuGraphExternalSemaphoresWaitNodeSetParams, cuGraphAddExternalSemaphoresWaitNode, cuSignalExternalSemaphoresAsync, cuWaitExternalSemaphoresAsync

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

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

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

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

另请参阅:

cuGraphNodeSetParams, cuGraphAddExternalSemaphoresWaitNode, cuGraphExternalSemaphoresWaitNodeSetParams, cuGraphAddExternalSemaphoresWaitNode, cuSignalExternalSemaphoresAsync, cuWaitExternalSemaphoresAsync

CUresult cuGraphGetEdges ( CUgraph hGraph, CUgraphNode* from, CUgraphNode* to, size_t* numEdges )
返回图的依赖边。
参数
hGraph
- Graph to get the edges from
from
- Location to return edge endpoints
to
- Location to return edge endpoints
numEdges
- See description
描述

返回hGraph的依赖边列表。边通过fromto中对应的索引返回;也就是说,to[i]中的节点依赖于from[i]中的节点。如果fromto都为NULL,则该函数仅返回numEdges中的边数。否则,将填充numEdges个条目。如果numEdges大于实际边数,则fromto中的剩余条目将被设置为NULL,实际返回的边数将被写入numEdges

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

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

另请参阅:

cuGraphGetNodes, cuGraphGetRootNodes, cuGraphAddDependencies, cuGraphRemoveDependencies, cuGraphNodeGetDependencies, cuGraphNodeGetDependentNodes

CUresult cuGraphGetEdges_v2 ( CUgraph hGraph, CUgraphNode* from, CUgraphNode* to, CUgraphEdgeData* edgeData, size_t* numEdges )
返回一个图的依赖边(12.3+版本)。
参数
hGraph
- 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
描述

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

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

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

另请参阅:

cuGraphGetNodes, cuGraphGetRootNodes, cuGraphAddDependencies, cuGraphRemoveDependencies, cuGraphNodeGetDependencies, cuGraphNodeGetDependentNodes

CUresult cuGraphGetNodes ( CUgraph hGraph, CUgraphNode* nodes, size_t* numNodes )
返回图的节点。
参数
hGraph
- Graph to query
nodes
- Pointer to return the nodes
numNodes
- See description
描述

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

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

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

另请参阅:

cuGraphCreate, cuGraphGetRootNodes, cuGraphGetEdges, cuGraphNodeGetType, cuGraphNodeGetDependencies, cuGraphNodeGetDependentNodes

CUresult cuGraphGetRootNodes ( CUgraph hGraph, CUgraphNode* rootNodes, size_t* numRootNodes )
返回图的根节点。
参数
hGraph
- Graph to query
rootNodes
- Pointer to return the root nodes
numRootNodes
- See description
描述

返回hGraph的根节点列表。rootNodes可能为NULL,在这种情况下该函数将在numRootNodes中返回根节点数量。否则,将填充numRootNodes个条目。如果numRootNodes大于实际根节点数量,rootNodes中剩余的条目将被设为NULL,实际获取的节点数量将在numRootNodes中返回。

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

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

另请参阅:

cuGraphCreate, cuGraphGetNodes, cuGraphGetEdges, cuGraphNodeGetType, cuGraphNodeGetDependencies, cuGraphNodeGetDependentNodes

CUresult cuGraphHostNodeGetParams ( CUgraphNode hNode, CUDA_HOST_NODE_PARAMS* nodeParams )
返回主机节点的参数。
参数
hNode
- Node to get the parameters for
nodeParams
- Pointer to return the parameters
描述

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

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

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

另请参阅:

cuLaunchHostFunc, cuGraphAddHostNode, cuGraphHostNodeSetParams

CUresult cuGraphHostNodeSetParams ( CUgraphNode hNode, const CUDA_HOST_NODE_PARAMS* nodeParams )
设置主机节点的参数。
参数
hNode
- Node to set the parameters for
nodeParams
- Parameters to copy
描述

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

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

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

另请参阅:

cuGraphNodeSetParams, cuLaunchHostFunc, cuGraphAddHostNode, cuGraphHostNodeGetParams

CUresult cuGraphInstantiate ( CUgraphExec* phGraphExec, CUgraph hGraph, unsigned long long flags )
从图形创建可执行图形。
参数
phGraphExec
- Returns instantiated graph
hGraph
- Graph to instantiate
flags
- Flags to control instantiation. See CUgraphInstantiate_flags.
描述

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

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

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

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

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

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

  • 图的节点必须位于单个上下文中。

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

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

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

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

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

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

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

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

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

另请参阅:

cuGraphInstantiate, cuGraphCreate, cuGraphUpload, cuGraphLaunch, cuGraphExecDestroy

CUresult cuGraphInstantiateWithParams ( CUgraphExec* phGraphExec, CUgraph hGraph, CUDA_GRAPH_INSTANTIATE_PARAMS* instantiateParams )
从图形创建可执行图形。
参数
phGraphExec
- Returns instantiated graph
hGraph
- Graph to instantiate
instantiateParams
- Instantiation parameters
描述

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

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

‎    typedef struct {
              cuuint64_t flags;
              CUstream hUploadStream;
              CUgraphNode hErrNode_out;
              CUgraphInstantiateResult result_out;
          } CUDA_GRAPH_INSTANTIATE_PARAMS;

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

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

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

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

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

  • 图的节点必须位于单个上下文中。

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

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

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

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

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

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

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

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

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

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

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

另请参阅:

cuGraphCreate, cuGraphInstantiate, cuGraphExecDestroy

CUresult cuGraphKernelNodeCopyAttributes ( CUgraphNode dst, CUgraphNode src )
将属性从源节点复制到目标节点。
参数
dst
Destination node
src
Source node For list of attributes see CUkernelNodeAttrID
描述

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

Note:

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

另请参阅:

CUaccessPolicyWindow

CUresult cuGraphKernelNodeGetAttribute ( CUgraphNode hNode, CUkernelNodeAttrID attr, CUkernelNodeAttrValue* value_out )
查询节点属性。
参数
hNode
attr
value_out
描述

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

Note:

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

另请参阅:

CUaccessPolicyWindow

CUresult cuGraphKernelNodeGetParams ( CUgraphNode hNode, CUDA_KERNEL_NODE_PARAMS* nodeParams )
返回内核节点的参数。
参数
hNode
- Node to get the parameters for
nodeParams
- Pointer to return the parameters
描述

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

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

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

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

另请参阅:

cuLaunchKernel, cuGraphAddKernelNode, cuGraphKernelNodeSetParams

CUresult cuGraphKernelNodeSetAttribute ( CUgraphNode hNode, CUkernelNodeAttrID attr, const CUkernelNodeAttrValue* value )
设置节点属性。
参数
hNode
attr
value
描述

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

Note:

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

另请参阅:

CUaccessPolicyWindow

CUresult cuGraphKernelNodeSetParams ( CUgraphNode hNode, const CUDA_KERNEL_NODE_PARAMS* nodeParams )
设置内核节点的参数。
参数
hNode
- Node to set the parameters for
nodeParams
- Parameters to copy
描述

将内核节点hNode的参数设置为nodeParams

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

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

另请参阅:

cuGraphNodeSetParams, cuLaunchKernel, cuGraphAddKernelNode, cuGraphKernelNodeGetParams

CUresult cuGraphLaunch ( CUgraphExec hGraphExec, CUstream hStream )
在流中启动可执行图。
参数
hGraphExec
- Executable graph to launch
hStream
- Stream in which to launch the graph
描述

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

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

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

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

另请参阅:

cuGraphInstantiate, cuGraphUpload, cuGraphExecDestroy

CUresult cuGraphMemAllocNodeGetParams ( CUgraphNode hNode, CUDA_MEM_ALLOC_NODE_PARAMS* params_out )
返回内存分配节点的参数。
参数
hNode
- Node to get the parameters for
params_out
- Pointer to return the parameters
描述

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

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

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

另请参阅:

cuGraphAddMemAllocNode, cuGraphMemFreeNodeGetParams

CUresult cuGraphMemFreeNodeGetParams ( CUgraphNode hNode, CUdeviceptr* dptr_out )
返回一个内存空闲节点的参数。
参数
hNode
- Node to get the parameters for
dptr_out
- Pointer to return the device address
描述

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

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

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

另请参阅:

cuGraphAddMemFreeNode, cuGraphMemAllocNodeGetParams

CUresult cuGraphMemcpyNodeGetParams ( CUgraphNode hNode, CUDA_MEMCPY3D* nodeParams )
返回一个memcpy节点的参数。
参数
hNode
- Node to get the parameters for
nodeParams
- Pointer to return the parameters
描述

返回hNode内存拷贝节点在nodeParams中的参数。

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

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

另请参阅:

cuMemcpy3D, cuGraphAddMemcpyNode, cuGraphMemcpyNodeSetParams

CUresult cuGraphMemcpyNodeSetParams ( CUgraphNode hNode, const CUDA_MEMCPY3D* nodeParams )
设置一个memcpy节点的参数。
参数
hNode
- Node to set the parameters for
nodeParams
- Parameters to copy
描述

将memcpy节点hNode的参数设置为nodeParams

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

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

另请参阅:

cuGraphNodeSetParams, cuMemcpy3D, cuGraphAddMemcpyNode, cuGraphMemcpyNodeGetParams

CUresult cuGraphMemsetNodeGetParams ( CUgraphNode hNode, CUDA_MEMSET_NODE_PARAMS* nodeParams )
返回memset节点的参数。
参数
hNode
- Node to get the parameters for
nodeParams
- Pointer to return the parameters
描述

返回 memset 节点 hNodenodeParams 中的参数。

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

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

另请参阅:

cuMemsetD2D32, cuGraphAddMemsetNode, cuGraphMemsetNodeSetParams

CUresult cuGraphMemsetNodeSetParams ( CUgraphNode hNode, const CUDA_MEMSET_NODE_PARAMS* nodeParams )
设置memset节点的参数。
参数
hNode
- Node to set the parameters for
nodeParams
- Parameters to copy
描述

将memset节点hNode的参数设置为nodeParams

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

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

另请参阅:

cuGraphNodeSetParams, cuMemsetD2D32, cuGraphAddMemsetNode, cuGraphMemsetNodeGetParams

CUresult cuGraphNodeFindInClone ( CUgraphNode* phNode, CUgraphNode hOriginalNode, CUgraph hClonedGraph )
查找节点的克隆版本。
参数
phNode
- Returns handle to the cloned node
hOriginalNode
- Handle to the original node
hClonedGraph
- Cloned graph to query
描述

此函数返回hClonedGraph中与原始图中的hOriginalNode相对应的节点。

hClonedGraph 必须是通过 cuGraphClonehOriginalGraph 克隆而来。hOriginalNode 必须在调用 cuGraphClone 时存在于 hOriginalGraph 中,且对应的克隆节点在 hClonedGraph 中未被移除。克隆节点将通过 phClonedNode 返回。

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

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

另请参阅:

cuGraphClone

CUresult cuGraphNodeGetDependencies ( CUgraphNode hNode, CUgraphNode* dependencies, size_t* numDependencies )
返回节点的依赖项。
参数
hNode
- Node to query
dependencies
- Pointer to return the dependencies
numDependencies
- See description
描述

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

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

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

另请参阅:

cuGraphNodeGetDependentNodes, cuGraphGetNodes, cuGraphGetRootNodes, cuGraphGetEdges, cuGraphAddDependencies, cuGraphRemoveDependencies

CUresult cuGraphNodeGetDependencies_v2 ( CUgraphNode hNode, CUgraphNode* dependencies, CUgraphEdgeData* edgeData, size_t* numDependencies )
返回一个节点的依赖项(12.3+版本)。
参数
hNode
- Node to query
dependencies
- Pointer to return the dependencies
edgeData
- Optional array to return edge data for each dependency
numDependencies
- See description
描述

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

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

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

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

另请参阅:

cuGraphNodeGetDependentNodes, cuGraphGetNodes, cuGraphGetRootNodes, cuGraphGetEdges, cuGraphAddDependencies, cuGraphRemoveDependencies

CUresult cuGraphNodeGetDependentNodes ( CUgraphNode hNode, CUgraphNode* dependentNodes, size_t* numDependentNodes )
返回一个节点的依赖节点。
参数
hNode
- Node to query
dependentNodes
- Pointer to return the dependent nodes
numDependentNodes
- See description
描述

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

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

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

另请参阅:

cuGraphNodeGetDependencies, cuGraphGetNodes, cuGraphGetRootNodes, cuGraphGetEdges, cuGraphAddDependencies, cuGraphRemoveDependencies

CUresult cuGraphNodeGetDependentNodes_v2 ( CUgraphNode hNode, CUgraphNode* dependentNodes, CUgraphEdgeData* edgeData, size_t* numDependentNodes )
返回一个节点的依赖节点(12.3+版本)。
参数
hNode
- Node to query
dependentNodes
- Pointer to return the dependent nodes
edgeData
- Optional pointer to return edge data for dependent nodes
numDependentNodes
- See description
描述

返回node的依赖节点列表。dependentNodes可为NULL,此时该函数将在numDependentNodes中返回依赖节点的数量。否则将填充numDependentNodes个条目。如果numDependentNodes高于实际依赖节点数量,dependentNodes中的剩余条目将被设为NULL,实际获取的节点数量将在numDependentNodes中返回。

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

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

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

另请参阅:

cuGraphNodeGetDependencies, cuGraphGetNodes, cuGraphGetRootNodes, cuGraphGetEdges, cuGraphAddDependencies, cuGraphRemoveDependencies

CUresult cuGraphNodeGetEnabled ( CUgraphExec hGraphExec, CUgraphNode 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:
  • 目前仅支持内核(kernel)、内存设置(memset)和内存复制(memcpy)节点。

  • 此函数不会反映设备可更新内核节点的设备端更新。

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

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

另请参阅:

cuGraphNodeSetEnabled, cuGraphExecUpdate, cuGraphInstantiatecuGraphLaunch

CUresult cuGraphNodeGetType ( CUgraphNode hNode, CUgraphNodeType* type )
返回节点的类型。
参数
hNode
- Node to query
type
- Pointer to return the node type
描述

返回hNodetype中的节点类型。

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

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

另请参阅:

cuGraphGetNodes, cuGraphGetRootNodes, cuGraphChildGraphNodeGetGraph, cuGraphKernelNodeGetParams, cuGraphKernelNodeSetParams, cuGraphHostNodeGetParams, cuGraphHostNodeSetParams, cuGraphMemcpyNodeGetParams, cuGraphMemcpyNodeSetParams, cuGraphMemsetNodeGetParams, cuGraphMemsetNodeSetParams

CUresult cuGraphNodeSetEnabled ( CUgraphExec hGraphExec, CUgraphNode 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也不会被此调用修改。

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

Note:

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

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

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

另请参阅:

cuGraphNodeGetEnabled, cuGraphExecUpdate, cuGraphInstantiatecuGraphLaunch

CUresult cuGraphNodeSetParams ( CUgraphNode hNode, CUgraphNodeParams* nodeParams )
更新图节点的参数。
参数
hNode
- Node to set the parameters for
nodeParams
- Parameters to copy
描述

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

不支持修改节点类型 CU_GRAPH_NODE_TYPE_MEM_ALLOC 和 CU_GRAPH_NODE_TYPE_MEM_FREE 的参数。

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

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

另请参阅:

cuGraphAddNode, cuGraphExecNodeSetParams

CUresult cuGraphReleaseUserObject ( CUgraph graph, CUuserObject object, unsigned int  count )
从图中释放用户对象引用。
参数
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用户对象部分。

另请参阅:

cuUserObjectCreate, cuUserObjectRetain, cuUserObjectRelease, cuGraphRetainUserObject, cuGraphCreate

CUresult cuGraphRemoveDependencies ( CUgraph hGraph, const CUgraphNode* from, const CUgraphNode* to, size_t numDependencies )
从图中移除依赖边。
参数
hGraph
- 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
描述

要移除的dependencies数量由numDependencies定义。fromto中对应索引位置的元素定义一个依赖关系。fromto中的每个节点都必须属于hGraph

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

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

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

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

另请参阅:

cuGraphAddDependencies, cuGraphGetEdges, cuGraphNodeGetDependencies, cuGraphNodeGetDependentNodes

CUresult cuGraphRemoveDependencies_v2 ( CUgraph hGraph, const CUgraphNode* from, const CUgraphNode* to, const CUgraphEdgeData* edgeData, size_t numDependencies )
从图中移除依赖边(12.3+版本)。
参数
hGraph
- 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
描述

需要移除的dependencies数量由numDependencies定义。fromto中对应索引位置的元素定义一个依赖关系。fromto中的每个节点都必须属于hGraph

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

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

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

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

另请参阅:

cuGraphAddDependencies, cuGraphGetEdges, cuGraphNodeGetDependencies, cuGraphNodeGetDependentNodes

CUresult cuGraphRetainUserObject ( CUgraph graph, CUuserObject object, unsigned int  count, unsigned int  flags )
保留对图中用户对象的引用。
参数
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 CU_GRAPH_USER_OBJECT_MOVE transfers references from the calling thread, rather than create new references. Pass 0 to create new references.
描述

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

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

另请参阅:

cuUserObjectCreate, cuUserObjectRetain, cuUserObjectRelease, cuGraphReleaseUserObject, cuGraphCreate

CUresult cuGraphUpload ( CUgraphExec hGraphExec, CUstream hStream )
以流的形式上传可执行图。
参数
hGraphExec
- Executable graph to upload
hStream
- Stream in which to upload the graph
描述

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

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

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

另请参阅:

cuGraphInstantiate, cuGraphLaunch, cuGraphExecDestroy

CUresult cuUserObjectCreate ( CUuserObject* object_out, void* ptr, CUhostFn 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 CU_USER_OBJECT_NO_DESTRUCTOR_SYNC, 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用户对象部分。

另请参阅:

cuUserObjectRetain, cuUserObjectRelease, cuGraphRetainUserObject, cuGraphReleaseUserObject, cuGraphCreate

CUresult cuUserObjectRelease ( CUuserObject object, unsigned int  count )
释放对用户对象的引用。
参数
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用户对象部分。

另请参阅:

cuUserObjectCreate, cuUserObjectRetain, cuGraphRetainUserObject, cuGraphReleaseUserObject, cuGraphCreate

CUresult cuUserObjectRetain ( CUuserObject object, unsigned int  count )
保留对用户对象的引用。
参数
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用户对象部分。

另请参阅:

cuUserObjectCreate, cuUserObjectRelease, cuGraphRetainUserObject, cuGraphReleaseUserObject, cuGraphCreate