How are 2D / 3D CUDA blocks divided into warps?

前端 未结 2 1071
南方客
南方客 2020-11-28 11:26

If I start my kernel with a grid whose blocks have dimensions:

dim3 block_dims(16,16);

How are the grid blocks now split into warps? Do the

相关标签:
2条回答
  • 2020-11-28 11:52

    To illustrate @talonmies's answer through 'Visual Studio WarpWatch' window for two consecutive warps (dim3 block_dims(16,16); and WarpSize = 32):

    0 讨论(0)
  • 2020-11-28 11:53

    Threads are numbered in order within blocks so that threadIdx.x varies the fastest, then threadIdx.y the second fastest varying, and threadIdx.z the slowest varying. This is functionally the same as column major ordering in multidimensional arrays. Warps are sequentially constructed from threads in this ordering. So the calculation for a 2d block is

    unsigned int tid = threadIdx.x + threadIdx.y * blockDim.x;
    unsigned int warpid = tid / warpSize;
    

    This is covered both in the programming guide and the PTX guide.

    0 讨论(0)
提交回复
热议问题