

Instead, I mentally replace blockDim by threads-per-block and gridDim by blocks-per-grid. CUDA (or Compute Unified Device Architecture) is a parallel computing platform and application programming interface (API) that allows software to use certain types of graphics processing units (GPUs) for general purpose processing, an approach called general-purpose computing on GPUs (). Similarly, I also find the global variables blockDim and gridDim very confusing.

With 4 SMs, block 0 & 4 is assigned to SM0, block 1, 5 to SM1, block 2, 6 to SM2 and block 3, 7 to SM3. bytes is optional if present, it must be a scalar integer, and specifies the number of. If block is an integer, it is converted to dim3(block,1,1). It can be executed on a GPU with 2 SMs or 4SMs. The CUDA threads are organized into thread blocks, and each thread has a global thread block index. Here, we have a CUDA application composes of 8 blocks. Needless to say that many programmers must have swore at NVIDIA for that weird restriction! 😁 Pascal GP100 can handle maximum of 32 thread blocks and 2048 threads per SM. This seems obvious, but in the CUDA 1.x days, the minimum dimension of a block was 2. See the programming guide, section 4.3.1. dimBlock () and dimGrid () are setting the initial values using constructors. In CUDA, they are organized in a two-level hierarchy: a grid comprises blocks, and each block comprises threads. SimonGreen May 30, 2008, 8:01am 2 dim3 is just a structure designed for storing block and grid dimensions. They have specific coordinates to distinguish themselves from each other and identify the relevant portion of data to process. Thus, a block has a maximum of 3 dimensions and a grid a maximum of 2 dimensions.Ī block has a minimum of 1 dimension and a grid too has a minimum of 1 dimension. Threads in a grid execute the same kernel function. Grid: A grid is a lattice of horizontal and vertical lines. It has all 3 dimensions: length, width and height.

I try to distinguish their dimensions by the meaning of their words:īlock: Think of a block of wood. This is not helped by the fact that both of their dimensions is specified by the type dim3. Sometimes the number of possible dimensions of a CUDA block and grid can get confusing.
