C++17 added a new compile time constant std::
which tells you (basically) the size of a cache line. The purpose of this is to allow you to lay out your structures in a way that avoids false sharing.
Why is
std::hardware_destructive_interference_size
a Compile-time Constant Instead of a Run-time Value?by Raymond Chen
From the article:
C++17 added a new compile time constant
std::
which tells you (basically) the size of a cache line. The purpose of this is to allow you to lay out your structures in a way that avoids false sharing.¹hardware_ destructive_ interference_ size But how does the compiler know what the cache line size will be of the CPU the program will eventually be run on? Shouldn’t this be a run-time value instead of a compile-time value?
Well yes, the actual size of the cache line isn’t know until run-time, because it is only then that the program meets a CPU. But really, you want this to be a ...
Add a Comment
Comments are closed.