GPU Programming

In CUDA, what generally happens right after the CPU-side program launches a kernel?

  1. AThe CPU always halts and can do nothing until the kernel finishes
  2. BThe kernel runs on the CPU
  3. CThe launch is asynchronous, so the CPU proceeds without waiting for the kernel to finish and must synchronize before using the results
Show answer and explanation

Answer: C. The launch is asynchronous, so the CPU proceeds without waiting for the kernel to finish and must synchronize before using the results

A kernel launch merely appends work to the GPU's command queue, and control returns to the CPU immediately. The CPU can therefore prepare the next data while the GPU computes. Before reading results on the CPU, however, it must confirm the kernel has finished, with cudaDeviceSynchronize or a copy of the results (which, in the same stream, waits for prior work). Timing measurements likewise need synchronization to capture kernel time correctly.

  • A. The launch call returns immediately.
  • B. The kernel runs on the GPU.
  • C. Correct. The CPU can do other work in the meantime.
Practice this topic Back to topic

More GPU Programming questions

  1. How do the design philosophies of CPUs and GPUs differ?
  2. Which characteristic best describes work that GPUs process quickly?
  3. Which processing tends to run inefficiently on a GPU?
  4. In GPU programming such as CUDA, what is a "kernel"?
  5. Which correctly orders the CUDA thread hierarchy from largest to smallest?