Built-in variables

Language extensions: built-in variables

circle-info

You can use those variables inside kernel code ie: to go through loop

struct dim3 {int x, y, z}


dim3 gridDim;
// dimestions of the grid in blocks (gridDim.z unused prior to CUDA 4.0)

dim3 blockDim;
// dimensions of the block in threads

dim3 blockIdx;
// block index within grid

dim3 threadIdx;
// thread index within block

Example: 1D blocks and grids

circle-info

Simple Program Multiplt Data - concept!

1D blocks and grid

Example: 2D blocks and grids

2D blocks and grid

Computing global thread ID

Global thread ID can be used to decide what data thread will work on

Computing global thread ID

Global thread ID can be used to decida what data a thread will work on - reading memory array idx.

Last updated