Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

CUDA: dim3

📅 2011-Feb-16 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cuda ⬩ 📚 Archive

dim3 is an integer vector type that can be used in CUDA code. Its most common application is to pass the grid and block dimensions in a kernel invocation. It can also be used in any user code for holding values of 3 dimensions.

For example:

dim3 grid( 512 );         // 512 x 1 x 1
dim3 block( 1024, 1024 ); // 1024 x 1024 x 1
fooKernel<<< grid, block >>>();

The only facts to know about dim3 are:

dim3 is modeled after similar vector types that are available in shader languages like Cg, GLSL or HLSL. However, unlike them dim3 is disappointingly simple and incapable of anything useful. It cannot be used directly in any arithmetic operations ( grid + block ) or in any sort of vector swizzling ( grid.xyz = block.zyx ).

Tried with: CUDA 3.2


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧