Previous | Next --- Slide 37 of 82
Back to Lecture Thumbnails
ufxela

Do the dimensions for a thread ID correspond to any physical construct? Or is it some abstraction to help us as programmers? Why is it limited to 3 dimensional?

thread17

I think we usually represent 2d with (row, col) but here it seems to be (4,3)=(col,row), is this how it works or just for illustration purpose and does not matter?

assignment7

Do the dimension of thread IDs correspond to some specific operations like matrix or tensor operations?

weimin

I think the limit of 3 is from graphics applications as in physical space objects have x,y,z coordinates. Tensors can have much higher dimension.

kevtan

@ufxela @thread17 @assignment7 The thread ID is just a programming abstraction and doesn't represent any physical construct. It serves the exact same purpose as the programIndex built-in variable in ISPC; it allows each CUDA thread to know what work it's in charge of performing. That being said, it doesn't matter if we think of it as (row, col) or (col, row). As long as you stay consistent with some convention in the host (CPU) and device (GPU) code, you'll be fine. It doesn't correspond to matrix/tensor operations.

tp

Is the purpose of having 2d or 3d thread IDs that they can make it more convenient to split up work depending on what you're trying to accomplish? Could we also divide threads across a single dimension if there isn't any inherent dimensionality to our work?

kevtan

@tp Yup! Block dimensions are 3D (in particular, a data type called dim3) in order to make it convenient to split up the work inside of the kernel. If your workload is not inherently 2D or 3D people generally just use the x component of the block dimensions in their code.

Please log in to leave a comment.