I have been getting a different value for the size of a structure on the host and the device. As I load an array of my structure into shared memory and calculate the size of shared memory on the host this has previosuly caused me probems (at least Ive spent a while finding the problem). My struct is declared as
struct message
{
int2 _position;
int state;
int val1;
int val2;
};
On the host the size of this is 20bytes (as expected), on the device the sizeof function returns 24bytes. I get round this by enforcing alignment i.e. align(16) to give a 32byte size which has the added benefit of avoiding bank conflicts but I just wondered where the extra 4 bytes is coming from.
Im sure this must be covered in some documentation somewhere. Can anyone point me in the right direction?