Aligning to cache line and knowing the cache line size

前端 未结 7 1740
盖世英雄少女心
盖世英雄少女心 2020-12-12 10:07

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

7条回答
  •  [愿得一人]
    2020-12-12 10:45

    Here's a table I made that has most Arm/Intel processors on it. You can use it for reference when defining constants, that way you don't have to generalize the cache line size for all architectures.

    For C++, hopefully, we will soon see hardware interface size which should be an accurate way to get this information (assuming you tell the compiler your target architecture).

提交回复
热议问题