pub unsafe extern "C" fn cudaGraphAddKernelNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
pNodeParams: *const cudaKernelNodeParams,
) -> cudaError_tExpand description
Creates a kernel execution node and adds it to a graph.
Creates a new kernel execution node and adds it to graph with numDependencies dependencies specified via pDependencies and arguments specified in pNodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
The cudaKernelNodeParams structure is defined as:
struct cudaKernelNodeParams
{
void* func;
dim3 gridDim;
dim3 blockDim;
unsigned int sharedMemBytes;
void **kernelParams;
void **extra;
};When the graph is launched, the node will invoke kernel func on a (gridDim.x x gridDim.y x gridDim.z) grid of blocks. Each block contains (blockDim.x x blockDim.y x blockDim.z) threads.
sharedMem sets the amount of dynamic shared memory that will be available to each thread block.
Kernel parameters to func can be specified in one of two ways:
-
Kernel parameters can be specified via
kernelParams. If the kernel has N parameters, thenkernelParamsneeds to be an array of N pointers. Each pointer, fromkernelParams[0] tokernelParams[N-1], points to the region of memory from which the actual parameter will be copied. The number of kernel parameters and their offsets and sizes do not need to be specified as that information is retrieved directly from the kernel’s image. -
Kernel parameters can also be packaged by the application into a single buffer that is passed in via
extra. This places the burden on the application of knowing each kernel parameter’s size and alignment/padding within the buffer. Theextraparameter exists to allow this function to take additional less commonly used arguments.extraspecifies a list of names of extra settings and their corresponding values. Each extra setting name is immediately followed by the corresponding value. The list must be terminated with either NULL or CU_LAUNCH_PARAM_END.
CU_LAUNCH_PARAM_END, which indicates the end of theextraarray;CU_LAUNCH_PARAM_BUFFER_POINTER, which specifies that the next value inextrawill be a pointer to a buffer containing all the kernel parameters for launching kernelfunc;CU_LAUNCH_PARAM_BUFFER_SIZE, which specifies that the next value inextrawill be a pointer to a size_t containing the size of the buffer specified withCU_LAUNCH_PARAM_BUFFER_POINTER;
The error cudaError_t::CUDA_ERROR_INVALID_VALUE will be returned if kernel parameters are specified with both kernelParams and extra (i.e. both kernelParams and extra are non-NULL).
The kernelParams or extra array, as well as the argument values it points to, are copied during this call.
Note: Kernels launched using graphs must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects.
Note: Graph objects are not threadsafe. More here.
Note that this function may also return error codes from previous, asynchronous launches.
Note that this function may also return cudaError_t::CUDA_ERROR_NOT_INITIALIZED, cudaErrorInsufficientDriver or cudaError_t::CUDA_ERROR_NO_DEVICE if this call tries to initialize internal CUDA RT state.
Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaError_t::CUDA_ERROR_NOT_PERMITTED may, but is not guaranteed to, be returned as a diagnostic in such case.
Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLibraryGetKernel or cudaGetKernel and then passing it to the API by casting to void*. The symbol entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same CUDA Runtime instance.
Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is cudaKernel_t.
§Parameters
pGraphNode: Returns newly created node.graph: Graph to which to add the node.pDependencies: Dependencies of the node.numDependencies: Number of dependencies.pNodeParams: Parameters for the GPU execution node.
§Return value
See also: cudaGraphAddNode, cudaLaunchKernel, cudaGraphKernelNodeGetParams, cudaGraphKernelNodeSetParams, cudaGraphCreate, cudaGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAddHostNode, cudaGraphAddMemcpyNode, cudaGraphAddMemsetNode.