cuda.bindings._v2.driver.graph_add_mem_alloc_node#
- cuda.bindings._v2.driver.graph_add_mem_alloc_node(
- intptr_t h_graph,
- dependencies,
- size_t num_dependencies,
- node_params,
Creates an allocation node and adds it to a graph.
Creates a new allocation node and adds it to
h_graphwithnum_dependenciesdependencies specified viadependenciesand arguments specified innode_params. It is possible fornum_dependenciesto be 0, in which case the node will be placed at the root of the graph.dependenciesmay not have any duplicate entries. A handle to the new node will be returned inph_graph_node. WhencuGraphAddMemAllocNodecreates an allocation node, it returns the address of the allocation innode_params.dptr. The allocation’s address remains fixed across instantiations and launches. If the allocation is freed in the same graph, by creating a free node usingcuGraphAddMemFreeNode, the allocation can be accessed by nodes ordered after the allocation node but before the free node. These allocations cannot be freed outside the owning graph, and they can only be freed once in the owning graph. If the allocation is not freed in the same graph, then it can be accessed not only by nodes in the graph which are ordered after the allocation node, but also by stream operations ordered after the graph’s execution but before the allocation is freed. Allocations which are not freed in the same graph can be freed by:.passing the allocation to
cuMemFreeAsyncorcuMemFree;.launching a graph with a free node for that allocation; or.
specifying
CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCHduring instantiation, which makes each launch behave as though it calledcuMemFreeAsyncfor every unfreed allocation.
It is not possible to free an allocation in both the owning graph and another graph. If the allocation is freed in the same graph, a free node cannot be added to another graph. If the allocation is freed in another graph, a free node can no longer be added to the owning graph. The following restrictions apply to graphs which contain allocation and/or memory free nodes:.
Nodes and edges of the graph cannot be deleted.
The graph can only be used in a child node if the ownership is moved to the parent.
Only one instantiation of the graph may exist at any point in time.
The graph cannot be cloned.
- Parameters:
h_graph (intptr_t) – Graph to which to add the node.
dependencies (object) –
Dependencies of the node. It can be:
num_dependencies (size_t) – Number of dependencies.
node_params (intptr_t) – Parameters for the node.
- Returns:
Returns newly created node.
- Return type:
intptr_t
See also
cuGraphAddMemAllocNode