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
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to