Sad Clouds <cryintothebluesky%googlemail.com@localhost> writes: > Apart from allocating memory dynamically via posix_memalign(), does > anyone know if there are other ways of making sure the variables are > aligned on 32 or 64-byte boundary? I've tried GCC aligned attribute, > but then it does not guarantee data alignment to that particular > boundary. Quite often it will align to 8 or 16 bytes, etc. I think the real issue is that what you want is memory that is in different cache lines, not alignment. Have you tried allocating 64 bytes, aligned to 32, and then using the integers at 28 and 36? I suspect that will be fast. I don't think the CPU architecture itself guarantees anything about cache line size. So it's not clear to me what a portable program should do. Although keeping objects to be accessed in different threads somewhat far apart seems like a good plan.
Attachment:
pgpT6tcJKxk_Q.pgp
Description: PGP signature