Cache lines, false sharing and alignment

后端 未结 3 375
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 14:22

I wrote the following short C++ program to reproduce the false sharing effect as described by Herb Sutter:

Say, we want to perform a total amount of WORKLOAD integer op

3条回答
  •  别那么骄傲
    2021-02-05 14:28

    You should be able to request the required alignment from the compiler:

    alignas(64) int arr[PARALELL * PADDING]; // align the array to a 64 byte line
    

提交回复
热议问题