PDA

View Full Version : Size of a structure. Should it be multiple of 16 ?



wonwoolee
04-21-2010, 10:42 PM
Hello.
I wonder that my own structure shoulde have the size of multiple of 16 bytes.
I remember that I read a post saying it would be better to make the size of a structure be multiple of 16. However, I'm not sure that.

If I define a structure like this, the size of A is 20 bytes.



Struct A
{
float a, b, c, d ;
int k ;
};


Considering memory access, I think 20 bytes is not a good size since OpenCL works with numbers, such as 16, 32, 128.

Thanks in advance !

santtt
05-07-2010, 09:34 AM
Well the aligment multiple by 16 comes by the way the SIMT pushes the work on the computeElements. There exists some called HalfWarp, that consist on 16 workItems that have a determinated size in Bytes of aligment, so this halfwarp reads the memory and produce this access in a determinated way, if your size of half warp is p.e. 32B, then yo have and overhead of 12B per lecture (this is because you have your estructure of 20B). It's clear?

Saludos!