Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What size are integers when programming cuda kernels

Tags:

cuda

I can't seem to find an answer to this simple question in the Cuda Programming Guide: When compiling a kernel with nvcc, What size integer is declared by short, int, long, and long long? Does it depend on my host architecture, so I should use int16_t, int32_t, and int64_t, or is it always a fixed size?

like image 688
John Gordon Avatar asked Oct 14 '10 17:10

John Gordon


1 Answers

It depends on the host compiler. Specifically, nvcc's definition of those types will agree with the host compiler's representation.

In practice, the char, short, and int data types have predictable sizes on all platforms that CUDA supports (8, 16, and 32 bits respectively). However the size of long varies from platform to platform.

like image 116
wnbell Avatar answered Sep 21 '22 15:09

wnbell