To prevent false sharing, I want each element of the array to be bound to a cache line. So first I need to know the size of the cache line, so I assign so many bytes to each element. Secondly, I want the beginning of the array to be aligned with the cache line.
I use Linux and the x86 octa-core platform. First, how to find the size of the cache line. Secondly, how do I align the cache line in C. I use the gcc compiler.
Thus, the structure will follow, for example, provided that the size of the cache line is 64.
element[0] occupies bytes 0-63 element[1] occupies bytes 64-127 element[2] occupies bytes 128-191
etc., assuming 0-63 is aligned with the cache line.
c linux caching memory-alignment computer-architecture
MetallicPriest 02 Sep 2018-11-11T00: 00Z
source share