0Pricing
CUDA Academy · Lesson

cudaDeviceSynchronize Explained

Why the CPU must wait for the GPU.

The CPU Does Not Wait

After a launch, the CPU rushes ahead while the GPU is still working. To pause and wait, you call cudaDeviceSynchronize. ⏳

myKernel<<<g, b>>>(p);
cudaDeviceSynchronize();

What Synchronize Means

cudaDeviceSynchronize blocks the host until every queued GPU task has finished. Only then does your next CPU line run.

All lessons in this course

  1. Anatomy of a Kernel
  2. The Triple-Angle-Bracket Launch
  3. printf Inside a Kernel
  4. cudaDeviceSynchronize Explained
← Back to CUDA Academy