title: Aligning to cache line and knowing the cache line size
body: <p>To prevent false sharing, I want to align each element of an array to a cache line. So first I need to know the size of a cache line, so I assign each element that amount of bytes. Secondly I want the start of the array to be aligned to a cache line. </p>
  
  <p>I am using Linux and 8-core x86 platform. First how do I find the cache line size. Secondly, how do I align to a cache line in C. I am using the gcc compiler. </p>
  
  <p>So the structure would be following for example, assuming a cache line size of 64.</p>
  
  <pre><code>element[0] occupies bytes 0-63
  element[1] occupies bytes 64-127
  element[2] occupies bytes 128-191
  </code></pre>
  
  <p>and so on, assuming of-course that 0-63 is aligned to a cache line.</p>