In this article
Device-side launches suit genuinely discovered parallel work; compare them with compacted queues and ordinary kernels before adopting nested grids.
CUDA dynamic parallelism lets device code launch additional kernels. That changes who discovers and submits work; it does not turn every irregular algorithm into an efficient GPU program. The useful question is whether creating child grids expresses meaningful independent work or merely replaces a cheap loop with an expensive scheduling boundary.
Discovering work without a host round trip
A parent kernel can inspect data and discover that a region needs additional processing. Launching a child grid can express that processing without first sending a decision back to the host. Adaptive subdivision is a useful mental example. However, the launch remains a runtime operation with resource and ordering rules. It does not behave like an ordinary function call whose body immediately runs in the calling thread.
Primary reference: CUDA Programming Guide: CUDA Dynamic Parallelism.
Choose the launching thread deliberately
If every thread discovers the same region and launches the same child grid, the program duplicates work. The launching decision needs an explicit ownership rule: perhaps one elected thread handles a region after the block agrees that subdivision is necessary. Distinguish a grid describing many child tasks from many threads redundantly describing the same grid. This error can look like mysterious scaling failure rather than an obvious correctness bug.
Primary reference: CUDA Programming Guide.
Child inputs need an appropriate lifetime
A child grid needs accessible input storage that remains valid for its execution. Parent local variables and shared-memory scratch space should not be treated as general child buffers. Store transferable task descriptions in supported device-accessible memory and establish the documented ordering around publication. An address is not sufficient evidence: its memory space and lifetime determine whether another execution context can safely use it.
Primary reference: CUDA C++ Best Practices Guide.
Nested launches versus a work queue
Consider an irregular tree traversal. One implementation creates child grids for newly discovered branches. Another writes branch descriptions into a queue processed by a later kernel. The queue introduces compaction and another scheduling phase; child launches introduce their own runtime overhead and limits. Compare complete traversal time and memory consumption using the same tree. The number of source-code lines is a poor proxy for either cost.
Read the execution-model version
Dynamic parallelism has evolved, and old examples can rely on device synchronization behavior that newer execution models no longer support in the same way. Check the current compiler target, runtime documentation, and supported launch mechanisms together. Begin with a tiny parent-child correctness test before measuring an adaptive workload. A successful compilation alone cannot establish that an inherited synchronization design remains valid on the intended platform.
Related reading: A GPU inference benchmark you can trust; Reproducible inference stacks: preserving a GPU pilot’s result.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.