Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CUDA - what if I choose too many blocks?

Tags:

c++

matrix

cuda

I'm still getting mad on these unknown-size matrices which may vary from 10-20.000 for each dimension.

I'm looking at the CUDA sdk and wondering: what if I choose a number of blocks too high?

Something like a grid of 9999 x 9999 blocks in the X and Y dimensions, if my hardware has SMs which can't hold all these blocks, will the kernel have problems or the performances would simply collapse?

I don't know how to dimension in blocks/threads something which may vary so much.. I'm thinking at using the MAXIMUM number of blocks my hardware supports and then making the threads inside them work across all the matrix, is this the right way?

like image 537
Marco A. Avatar asked Mar 29 '11 16:03

Marco A.


People also ask

How many blocks can CUDA run?

Each CUDA card has a maximum number of threads in a block (512, 1024, or 2048). Each thread also has a thread id: threadId = x + y Dx + z Dx Dy The threadId is like 1D representation of an array in memory.

How many maximum threads can you create what is block what is grid?

The maximum number of threads in the block is limited to 1024. This is the product of whatever your threadblock dimensions are (xyz). For example (32,32,1) creates a block of 1024 threads.

How many blocks and threads GPU?

Hardwire limits the number of blocks in a single launch to 65,535. Hardwire also limits the number of threads per block with which we can launch a kernel. – For many GPUs, maxThreadsPerBlock = 512 (or 1024, version 2.

What is grid size CUDA?

1024 x 1024 x 64. • Maximum size of each. dimension of grid of. thread blocks: 65535 x 65535 x 65535.


1 Answers

The thread blocks do not have a one to one mapping with the cores. Blocks are scheduled to cores as they become available, meaning you can request as many as you want (up to a limit probably). Requesting a huge number of blocks would just slow the system down as it loads and unloads do-nothing thread blocks to the cores.

You can specify the dimensions of the grid and blocks at run time.

Edit: Here are the limits on the dimensions of the grid and the blocks, from the documentation.

enter image description here

like image 90
Null Set Avatar answered Sep 29 '22 11:09

Null Set