I have several classes that suffer from cache contention and are allocated with the "new" operator. Can I somehow make sure that "new" returns an address aligned to a cache line?
I am using GCC (if it's not portably possible).
You can use memalign or _aligned_alloc for glibc or windows CRT systems respectively. you can even use a custom allocator like nedmalloc and have it align the blocks, which could also give you some other added bonuses.
you should also mark them with __attribute__((aligned(64))), just in case they get statically allocated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With