[fpc-pascal] Cache-line alignment for records

Matias Ezequiel Vara Larsen matiasevara at gmail.com
Wed Mar 29 16:59:46 CEST 2023


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 <fpc-pascal at lists.freepascal.org> 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 align with the cache? That seems like something the compiler could do easily for you behind the scenes. I may not understand the need to "align the elements on the cache” though.

I do not think you would like to have everything aligned to the
cacheline. This use-case requires it because each element in the array
will be accessed from a different CPU and you would try to prevent cache
ping-pong, i.e., sharing the same cacheline between different cpu's cache.

Matias


More information about the fpc-pascal mailing list