tags:

views:

58

answers:

1

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?

+3  A: 

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.

wnbell
Are you sure this is right? The device code needs to be converted in to ptx commands. It would be weird if it this process was host architecture specific. I've looked in the CUDA docs and wasn't able to find anything.
nsanders
Yep, the device data types must match the host types, otherwise it would be impossible to predict how much memcpy to do to the host.
Edric
Thanks. That's exactly what I needed. It does make sense because it would be a nightmare if I was responsible to match the types between my host code and my kernel code.
John Gordon