memory alignment how to align a int and ushort

Hi, i need an array of a struct of an int and a ushort. And i don’t know what kind of align i should specify ? (2,4,8,16)

can anyone help ?

8 seems like a logical choice

It depends on how you access it. Most likely you’ll have consecutive threads moving consecutive array cells between shared and global memory. In that case, make sure you’re structure is aligned on at least 8 byte boundaries to get coalescing (see the section on memory bandwidth in the Programming Guide). With 8-byte alignment you’ll have 2-way bank conflicts in shared memory, but that shouldn’t be too detrimental to your performance.


Thnaks for the info, think i finaly have this thing figured out.

Also, 6 (4+2) is not really a nice size for a structure when concerned with aligned reads; it might be better for performance to store your data as two arrays, one of ints and one of shorts.