Alex Rivera | Logout

How many grids in CUDA

Asked 2012-10-09T13:15:15.673
8

How many CUDA grids are possible in a GPU?

Can two grids exist together in a GPU? Or does one GPU device have only one grid?

Kernel1<<gridDim, blockDim>>(dst1, param1);
Kernel1<<gridDim, blockDim>>(dst2, param2);

Do two kernels above run concurrently or sequentially?

Edit
Report

1 Answer

5

To elaborate on Robert's answer, here's an example of how you could use streams to make your two instances of Kernel1 run concurrently:

cudaStream_t stream1; cudaStreamCreate(&stream1);
cudaStream_t stream2; cudaStreamCreate(&stream2);

Kernel1<<gridDim, blockDim, 0, stream1>>(dst1, param1);
Kernel1<<gridDim, blockDim, 0, stream2>>(dst2, param2);

A few more notes about concurrent execution with streams:

  • If we launch a kernel without specifying a stream Kernel1<<<g, b>>>(), and then launch a kernel with a specific stream Kernel2<<<g, b, 0, stream>>>(), then Kernel2 will wait for Kernel1 to finish.
  • When a kernel is launched without a stream (Kernel1<<<g, b>>>()), Nvidia calls this "using the NULL stream."
  • If you use cudaEvents, your work can sometimes get serialized even if you distribute the kernels over several streams.
answered 2012-10-20T04:45:05.823

Your Answer