[fpc-pascal] Cache-line alignment for records
Jonas Maebe
jonas at freepascal.org
Mon Mar 27 20:52:40 CEST 2023
On 27/03/2023 09:28, Matias Ezequiel Vara Larsen via fpc-pascal wrote:
> Apologies in the case this subject has been already discussed. I require
> that some global variables be cache-line aligned. This is a requirement
> for per-CPU variables that are statically defined to prevent cache
> ping-pong. Is there any way to do this at fpc when the record is
> declared?
{$push}
{$codealign varmin=16}
{$codealign constmin=16}
const
constdata: array[0..3] of longint = (1,2,3,4);
var
x: array[0..15] of longint;
{$pop}
However, the maximum alignment you can specify this way is limited per
target (hardcoded in the compiler). In 3.2.x, it's 16 bytes for most
desktop targets. On 3.3.x, it's 64 bytes for most desktop targets.
Jonas
More information about the fpc-pascal
mailing list