Data structure alignment: Difference between revisions

Content deleted Content added
Add concrete example
Allocating memory aligned to cache lines: Indicate that performance degradation is due to false sharing
Tag: Reverted
Line 237:
 
==Allocating memory aligned to cache lines==
It would be beneficial to allocate memory aligned to [[cache line]]s. If an array is partitioned for more than one thread to operate on, having the sub-array boundaries unaligned to cache lines could lead to performance degradation due to [[false sharing]]. Here is an example to allocate memory (double array of size 10) aligned to cache of 64 bytes.
<syntaxhighlight lang="c">
#include <stdlib.h>