Malloc and sizeof


I am wondering what happens if I lets say use 64bit integers on my computer?

As we all know sizeof(int) is not always 4 - it is computer dependent. However CUDA GPUs use 32 bit int - sizeof(int) = 4.

What I am wondering about is if I malloc on my cpu with sizeof(int) - this is 8 since I use 64bit int - and then i cudaMalloc with sizeof(int), how does CUDA handle this?

Thanks for your assistance.

This is one of the reasons why CUDA does not work with arbitrary host compilers. It is part of the programming interface that we can expect variable size (and binary representation!) on host and device to match. So CUDA gets released only for compilers where this indeed is the case.

In fact sizeof(int) is NOT computer-dependent, but purely compiler dependent, and the selected representation model (usually linked to a specific OS more than).