Previous | Next --- Slide 25 of 54
Back to Lecture Thumbnails
rojo

I understand the fact that grids contain some number of blocks and blocks contain some number of threads. But is there any limitation on number of grids or number of blocks/threads a grid can contain? How is grids related to number of cores?

rbcarlso

As I understand it, blocks are akin to the tasks in ISPC. The grid dimensions are arbitrary, and at a given time some n blocks will be assigned to the n cores, while the others wait in a queue. The dimensions of the grid depends solely on what's convenient and sensible to program.

rojo

@rbcarlso: Thanks for the answer. So does it mean that it is not necessary to run all blocks in a grid on the same core or run all of blocks in a grid simultaneously on multiple cores?

rbcarlso

@rojo: I think there's only ever one "grid." The grid is just a description for how your blocks are designated. For example, you can have a hundred blocks labelled 0..99 or (0..9,0..9).

Sherry

I wonder what happens to CPU and OS when "matrixAdd" is called? How do they collaborate?

Maybe to OS, GPU is just another device which has a driver running in the OS kernel mode. When "matrixAdd" is called, the OS switches to kernel mode and issue the command to GPU driver which makes the GPU perform the actual calculation. The C program thread on CPU gets switched out. Just like a disk read request.

But if it worked like this, the performance would be quite bad. As GPU computation is designed for performance, it must not work this way?