Richard Laurant
Richard Laurant

Reputation: 657

CUDA: Maximum number of blocks in a grid != CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X?

I want to start a kernel in such a fashion:

kernel_code<<<NUMBER_BLOCKS, NUMBER_THREADS_PER_BLOCK>>> (param1, param2, param3, param4);

Thus, using only the x-dimension of the grid. I want to call the kernel with the maximum number of blocks possible. I thought the max. number of blocks in a grid for one dimension would be 65535.

However, I explored the constant CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X which sounds like exact the same number I want to find out. However, this constant returns 1899336 on my GeForce 210 (CUDA 1.2). What am I getting wrong?

Upvotes: 0

Views: 537

Answers (1)

Robert Crovella
Robert Crovella

Reputation: 151879

Referring to the driver API documentation for cuDeviceGetAttribute, the parameter which gives the maximum number of blocks in the x-direction of a grid is:

•CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X: Maximum x-dimension of a grid;

As you surmised, the parameter you indicated gives the maximum number of threads in a block (x-dimension):

•CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X: Maximum x-dimension of a block;

On a GeForce 210, the MAX_GRID_DIM_X parameter should be 65535. (True for all cc 1.x devices.)

If you are getting some other number, there is either something wrong with your code that you are using to retrieve this data (which you haven't shown), or else something wrong with your machine setup.

Try running and also inspecting the code for the CUDA driver API deviceQuery sample.

Upvotes: 2

Related Questions