Re: [fpc-pascal] Cache-line alignment for records

2023-03-30 Thread Matias Ezequiel Vara Larsen via fpc-pascal
On Wed, Mar 29, 2023 at 11:07:18PM +0200, Jonas Maebe via fpc-pascal wrote: > On 29/03/2023 16:00, Matias Ezequiel Vara Larsen via fpc-pascal wrote: > > So if I have a type like: > > > > test = record > >r: DWord; > >s: Word; > > end; > > > > Then, I define the variable `nada` as an array

Re: [fpc-pascal] Cache-line alignment for records

2023-03-29 Thread Ralf Quint via fpc-pascal
On 3/29/2023 2:38 PM, Ched via fpc-pascal wrote: Hello, Ok for the records for internal calculations. But sometimes, records are used for reading/writing structured files. Does "packed" in "packed array" and "packed record" always forbid the compiler to play with alignments ? If that recor

Re: [fpc-pascal] Cache-line alignment for records

2023-03-29 Thread Ched via fpc-pascal
Hello, Ok for the records for internal calculations. But sometimes, records are used for reading/writing structured files. Does "packed" in "packed array" and "packed record" always forbid the compiler to play with alignments ? Kindest regards, Ched' Le 29.03.23 à 21:07, Jonas Maebe via f

Re: [fpc-pascal] Cache-line alignment for records

2023-03-29 Thread Jonas Maebe via fpc-pascal
On 29/03/2023 16:00, Matias Ezequiel Vara Larsen via fpc-pascal wrote: So if I have a type like: test = record r: DWord; s: Word; end; Then, I define the variable `nada` as an array of `test` type: var nada: array[0..2] of test; Is the `@nada[1].r` element aligned to 4-bytes? Recor

Re: [fpc-pascal] Cache-line alignment for records

2023-03-29 Thread Matias Ezequiel Vara Larsen via fpc-pascal
On Wed, Mar 29, 2023 at 08:11:40PM +0700, Hairy Pixels via fpc-pascal wrote: > > > > On Mar 29, 2023, at 1:33 PM, Sven Barth via fpc-pascal > > wrote: > > > > No, array types are defined as never having padding between the elements. > > You need to make sure that the element is appropriately

Re: [fpc-pascal] Cache-line alignment for records

2023-03-29 Thread Matias Ezequiel Vara Larsen via fpc-pascal
On Wed, Mar 29, 2023 at 08:33:58AM +0200, Sven Barth via fpc-pascal wrote: > Matias Ezequiel Vara Larsen via fpc-pascal > schrieb am Mi., 29. März 2023, 00:27: > > > Hello, > > > > On Mon, Mar 27, 2023 at 09:35:38PM +0200, Jonas Maebe via fpc-pascal wrote: > > > On 27/03/2023 21:25, denisgolovan

Re: [fpc-pascal] Cache-line alignment for records

2023-03-29 Thread Hairy Pixels via fpc-pascal
> On Mar 29, 2023, at 1:33 PM, Sven Barth via fpc-pascal > wrote: > > No, array types are defined as never having padding between the elements. You > need to make sure that the element is appropriately sized then. > Wouldn’t that be better for performance if each element was padded to alig

Re: [fpc-pascal] Cache-line alignment for records

2023-03-29 Thread Matias Ezequiel Vara Larsen via fpc-pascal
On Mon, Mar 27, 2023 at 08:52:40PM +0200, Jonas Maebe via fpc-pascal wrote: > 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 requireme

Re: [fpc-pascal] Cache-line alignment for records

2023-03-29 Thread Matias Ezequiel Vara Larsen via fpc-pascal
On Wed, Mar 29, 2023 at 08:33:58AM +0200, Sven Barth via fpc-pascal wrote: > Matias Ezequiel Vara Larsen via fpc-pascal > schrieb am Mi., 29. März 2023, 00:27: > > > Hello, > > > > On Mon, Mar 27, 2023 at 09:35:38PM +0200, Jonas Maebe via fpc-pascal wrote: > > > On 27/03/2023 21:25, denisgolovan

Re: [fpc-pascal] Cache-line alignment for records

2023-03-28 Thread Sven Barth via fpc-pascal
Matias Ezequiel Vara Larsen via fpc-pascal schrieb am Mi., 29. März 2023, 00:27: > Hello, > > On Mon, Mar 27, 2023 at 09:35:38PM +0200, Jonas Maebe via fpc-pascal wrote: > > On 27/03/2023 21:25, denisgolovan via fpc-pascal wrote: > > > > > But it's still not possible to attach alignment to type i

Re: [fpc-pascal] Cache-line alignment for records

2023-03-28 Thread Matias Ezequiel Vara Larsen via fpc-pascal
Hello, On Mon, Mar 27, 2023 at 09:35:38PM +0200, Jonas Maebe via fpc-pascal wrote: > On 27/03/2023 21:25, denisgolovan via fpc-pascal wrote: > > > But it's still not possible to attach alignment to type itself instead of > > variable, right? > > It is possible > (https://gitlab.com/freepascal.

Re: [fpc-pascal] Cache-line alignment for records

2023-03-27 Thread denisgolovan via fpc-pascal
> It is possible > (https://gitlab.com/freepascal.org/fpc/source/-/blob/main/tests/test/talignrec1.pp), > but it is subject to the same limitations when declaring variables of > those types. > > Jonas Aha. Nice! Does it work recursively? I mean - does it work when aligned record is itself a f

Re: [fpc-pascal] Cache-line alignment for records

2023-03-27 Thread Jonas Maebe via fpc-pascal
On 27/03/2023 21:25, denisgolovan via fpc-pascal wrote: But it's still not possible to attach alignment to type itself instead of variable, right? It is possible (https://gitlab.com/freepascal.org/fpc/source/-/blob/main/tests/test/talignrec1.pp), but it is subject to the same limitations wh

Re: [fpc-pascal] Cache-line alignment for records

2023-03-27 Thread denisgolovan via fpc-pascal
> 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 But it's still not possible to attach alignment to type itself instead

Re: [fpc-pascal] Cache-line alignment for records

2023-03-27 Thread Jonas Maebe via fpc-pascal
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

[fpc-pascal] Cache-line alignment for records

2023-03-27 Thread Matias Ezequiel Vara Larsen via fpc-pascal
Hello everyone, 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 decl