I found in more than one SIMD program the instruction __attribute__((aligned(16)))
. When I looked for an explanation I found
The keyword attribute allows you to specify special attributes of variables or structure fields.
Apparently variables have attributes. Are these attributes language-specific? what attributes can a variable have? where are these attributes stored? Regarding the subject of aligned(16), I found this it
causes the compiler to allocate [a variable] on a 16-byte boundary
But is it mandatory for SIMD variables (m128i for example) to be aligned on a 16 bytes? If yes, I suppose this is the reason why we use __attribute((aligned(16))) like so:
int a[16] __attribute__((aligned(16))) = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
__vector signed int *va = (__vector signed int *) a;