GPU Programming

On a GPU whose limit is 1024 threads per thread block, a CUDA kernel is launched with blockDim.x set to 2048. What generally happens?

  1. AThe GPU automatically splits it into two blocks of 1024 threads each and runs them
  2. BOnly the first 1024 threads run and the rest are ignored
  3. CThe launch configuration is treated as invalid, so the kernel does not run and an error is returned
Show answer and explanation

Answer: C. The launch configuration is treated as invalid, so the kernel does not run and an error is returned

All threads of a thread block must reside on one SM at the same time and be able to cooperate through shared memory and __syncthreads(), so the number of threads per block is limited. If a kernel is launched with a configuration above the limit, not a single thread runs, and the launch fails with an error indicating an invalid configuration. A kernel launch returns no value, so unless the error is checked with cudaGetLastError() or similar, it is easy to miss that the result array was never updated. Work for 2048 threads is divided among multiple blocks of 1024 threads or fewer.

  • A. There is no automatic splitting. The program decides the number of blocks and threads.
  • B. The kernel does not run partially; the launch itself fails.
  • C. Correct. Make a habit of checking for errors after a launch.
Practice this topic Back to topic

Related calculators

Books on GPU Programming Ad

As an Amazon Associate I earn from qualifying purchases.

More GPU Programming questions

  1. Assume an SM of a GPU has one issue unit that can issue instructions from one warp per cycle. Each warp repeatedly issues 20 cycles of instructions and then waits 400 cycles for the result of a memory load. If switching warps takes no time, at least how many warps are needed to eliminate idle time due to memory waits (latency hiding)?
  2. How do the design philosophies of CPUs and GPUs differ?
  3. Which characteristic best describes work that GPUs process quickly?
  4. Which processing tends to run inefficiently on a GPU?
  5. In GPU programming such as CUDA, what is a "kernel"?

Comparisons in this topic