CUDA Dynamic Parallelism: When and How to Launch Child Kernels
CUDA Dynamic Parallelism lets a kernel running on the GPU launch another GPU kernel when a runtime condition calls for it. It can reduce the need to return each execution decision to the host when the GPU is examining an input structure and deciding whether more work exists or how large that work should be. The launch, memory, and synchronization rules still apply, so small child tasks are not automatically faster and parent and child kernels are not guaranteed to overlap.
CUDA Dynamic Parallelism: When and How to Launch Child Kernels
CUDA Dynamic Parallelism lets a kernel running on the GPU launch another GPU kernel when a runtime condition calls for it. It can reduce the need to return each execution decision to the host when the GPU is examining an input structure and deciding whether more work exists or how large that work should be. The launch, memory, and synchronization rules still apply, so small child tasks are not automatically faster and parent and child kernels are not guaranteed to overlap.
This article follows NVIDIA CUDA Programming Guide and CUDA Runtime API documentation checked on 2026-11-22, with a focus on CDP2, the default behavior since CUDA 12.0. CDP1 is mentioned only to explain why older examples may not apply to current code.
When is Dynamic Parallelism useful?
In a typical CUDA program, host code launches kernels. With CUDA Dynamic Parallelism (CDP), a GPU thread can inspect input while the kernel is running, then decide whether to launch a child kernel and what grid size to use. This can express data-dependent work without returning to the host after each decision.
For example, while processing a tree node, the GPU may discover a list of child nodes and start a child grid to process them. This is a way to express irregular work that grows from data on the device, not a feature that makes any kernel faster by itself. If each child task is tiny or the program creates too many child grids, launch-management costs can outweigh the useful work.
NVIDIA's current guide says CDP2 is the default with CUDA 12.0 and later, and the only Dynamic Parallelism mode on compute capability 9.0 and later. Older targets can still opt into CDP1, but it is a legacy path slated for future removal. Do not copy device-side cudaDeviceSynchronize() calls or direct child-result reads from old examples into CDP2 code.
How are parent and child grids ordered?
The grid containing a device thread that configures and launches another kernel is the parent grid; the newly launched work is the child grid. Child launches are nested: the parent grid is not complete until its child grids complete, and the runtime provides implicit synchronization between parent and child.
This does not guarantee that a child runs at the same time as its parent. A device-side launch is asynchronous with respect to the calling thread. The child can begin when dependencies and hardware resources permit, but its start may be delayed until the parent reaches an implicit synchronization point. Do not make correctness depend on overlap between different blocks or between parent and child grids.
The diagram shows the completion boundary and the two ways to continue after child work. It does not promise overlapping execution.
Time ─────────────────────────────────────────────────────────────→
Host stream: [launch parent grid] ── parent and children complete ── [next host stage]
Parent grid: [decision ── launch child grid] ──────────────────────┘
Child grid: [child work ── write global memory] ──────┘
Device tail: [tail kernel]A device launch returns before its child has finished. In CDP2, device code cannot use cudaDeviceSynchronize() to wait for child results. To continue on the GPU, launch a dependent kernel in cudaStreamTailLaunch, described below. If the host should continue, wait for the parent to complete and enqueue the next host-launched kernel in the same stream.
How can the child access parent data?
Parent and child grids share global memory, but a child cannot access the parent's local memory or shared memory. Pass pointers to global device allocations, such as buffers allocated by the host, rather than pointers to stack arrays or shared memory. A local variable may be placed in local memory by the compiler even when that placement is not obvious in the source.
A child sees global-memory writes made by the parent thread that launches it before the launch. If other threads in the same parent block prepare data for the child, synchronize those threads with an appropriate block barrier such as __syncthreads() before launching. That barrier covers only the block; it does not order writes from every other block in the parent grid.
The reverse direction is different in CDP2: a child grid's global-memory updates are not guaranteed to be visible to threads in the parent grid after the child returns. Do not read child results directly in the parent. A follow-up kernel launched into cudaStreamTailLaunch runs after the parent and child grids reach their implicit completion boundary, so it can consume the child results. Alternatively, the host can wait for the parent to complete and launch another kernel in the same stream.
Should the host, a child kernel, or a work queue start the next stage?
Choose based on where the decision is made and how much work each task contains. Dynamic Parallelism can reduce host-device control round trips, but each child grid adds device-runtime management and resource constraints.
| Approach | Fits when | Costs and limits to consider |
|---|---|---|
| Host-launched kernel | The host already knows the next stage or the result is needed by the host | The host coordinates each stage; a decision based on device data may require synchronization and returning data |
| Device-side child kernel (CDP2) | The GPU discovers irregular follow-up work and each child grid contains enough work to justify a separate launch | Device-side launch, runtime memory, error, and ordering rules; parent-child overlap is not guaranteed |
| Batched work queue | Individual tasks are small but can be collected and processed in batches | The application must design queue updates, capacity, termination, and load balancing |
For example, if a GPU finds a few large subtrees while traversing a tree or graph, it may be reasonable to consider child grids. If it finds thousands of very small tasks, creating one grid per task can multiply launch-management work. Compare that with collecting tasks in a queue for one or a few larger kernels, or launching known stages from the host. These are design choices, not performance results measured on a particular GPU.
How can a child result feed a tail launch?
The C++ below is an illustrative skeleton: the GPU reads the number of child items, launches a child kernel when there is work, then launches a follow-up kernel to consume the result. The buffers are assumed to be global device allocations made by the host. Results are written only when the count is positive; the caller handles the no-work case. The count and grid dimensions are assumed to fit the device's supported range.
#include <cuda_runtime.h>
__global__ void expandChildren(const int* childIds, int* stage, int count) {
const int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < count) {
stage[i] = childIds[i] * 2; // Illustrative per-item work.
}
}
__global__ void consumeChildren(const int* stage, int* output, int count) {
const int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < count) {
output[i] = stage[i] + 1;
}
}
__global__ void dispatchChildren(
const int* childCount, const int* childIds, int* stage, int* output) {
if (blockIdx.x == 0 && threadIdx.x == 0) {
const int count = childCount[0]; // Stored in global device memory.
if (count > 0) {
const int blocks = (count + 255) / 256;
expandChildren<<<blocks, 256>>>(childIds, stage, count);
if (cudaGetLastError() != cudaSuccess) {
return;
}
consumeChildren<<<blocks, 256, 0, cudaStreamTailLaunch>>>(
stage, output, count);
}
}
}
// Host code: buffers are device-global allocations made before this call.
void run(const int* childCount, const int* childIds, int* stage, int* output) {
dispatchChildren<<<1, 1>>>(childCount, childIds, stage, output);
if (cudaGetLastError() != cudaSuccess) {
return;
}
const cudaError_t status = cudaDeviceSynchronize(); // Host-side wait.
if (status != cudaSuccess) {
// Handle the asynchronous execution error.
}
}The parent reads childCount from global memory and starts a child grid only when the count is positive. The child writes to stage; the tail-launched consumer reads those values and writes output. The arithmetic is illustrative and makes no performance claim. The host-side cudaDeviceSynchronize() waits at the application boundary and lets the host check execution errors. It is different from calling cudaDeviceSynchronize() inside device code, which CDP2 does not support.
NVIDIA's current guide builds its self-contained device-launch example with relocatable device code and the device runtime, using a command of the form nvcc -arch=sm_75 -rdc=true hello_world.cu -o hello -lcudadevrt. The sm_75 target is the guide's example, not a minimum requirement; select an architecture supported by your installed toolkit and device. Check the project's separate-compilation and linking setup as well.
Which limits and failures should you check first?
Dynamic Parallelism lets device code change the work graph, but it makes launch resources and memory visibility part of the program design. Check the CDP2 boundary, pointer scope, and pending launches before increasing complexity.
| Symptom or design | Cause | Check or recovery |
|---|---|---|
| Child results look stale or inconsistent in the parent | In CDP2, child global-memory updates are not guaranteed visible directly to the parent grid | Use cudaStreamTailLaunch for a device-side continuation, or let the host wait for parent completion before the next stage |
| A child reads an invalid parent array pointer | The pointer refers to parent local or shared memory | Confirm it points to global device memory and remove local/shared pointers from child arguments |
| Correctness depends on parent and child running at the same time | CUDA does not guarantee parent-child or cross-block concurrency | Remove overlap-dependent data dependencies and use explicit completion and ordering boundaries |
| Device launches fail after creating many children | The device runtime's pending-launch slots are exhausted | Check cudaGetLastError() and final execution status. The default pending count is 2048; query it with cudaDeviceGetLimit() |
If more than the default 2048 pending launches are needed, inspect cudaLimitDevRuntimePendingLaunchCount and cudaDeviceSetLimit(). A larger pool reserves more device memory in advance, so increasing the limit is not a universal fix. First reduce the number of simultaneously outstanding child grids or batch small tasks. Linking the device runtime can also add management overhead to kernels even when they do not launch children, so measure the whole application before and after adopting it.
How do you evaluate whether to use it?
Write down whether the GPU must decide that more work exists or determine its size. If the host already knows the stages, use a host launch as the baseline.
Estimate the number of child grids and the useful work in each. If tasks are small and numerous, design a batched work-queue alternative.
Check the toolkit and compute capability for the default CDP2 behavior. Do not carry device-side cudaDeviceSynchronize() calls from CDP1 examples into current CDP2 code.
Confirm that launch arguments point to global device memory. Add required block synchronization before the child reads parent-produced data, and define a tail-launch or host-completion boundary for consuming child output.
Check device-launch and asynchronous execution errors, record pending-launch constraints, and measure end-to-end time on representative inputs. Compare CDP2 with host launches and a queue-based alternative before drawing a performance conclusion.
Dynamic Parallelism is most useful when the GPU must choose subsequent work from data already on the device. Its value depends on whether that choice saves enough host orchestration to justify child launches and device-runtime constraints. Do not assume one design is faster until it is measured on the target workload.
Sources
[NVIDIA CUDA Programming Guide — CUDA Dynamic Parallelism](https://docs.nvidia.com/cuda/cuda-programming-guide/04-special-topics/dynamic-parallelism.html)
[NVIDIA CUDA Programming Guide — Device-Callable APIs and Intrinsics](https://docs.nvidia.com/cuda/cuda-programming-guide/05-appendices/device-callable-apis.html)
[NVIDIA CUDA Runtime API 13.5 — Device Management](https://docs.nvidia.com/cuda/cuda-runtime-api/cuda_runtime_api/group__CUDART__DEVICE.html)
[NVIDIA CUDA C++ Best Practices Guide](https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/)