[fpc-pascal] Memory alignment with FPC

dhkblaszyk at zeelandnet.nl dhkblaszyk at zeelandnet.nl
Thu Oct 11 15:23:00 CEST 2012


  

On 11 okt '12, Jonas Maebe wrote: 

> On 11 Oct 2012, at 15:00,
dhkblaszyk at zeelandnet.nl [1]wrote:
> 
>> So misalignment of for instance
a double (or whatever type) will only happen if the record is packed and
the packed value is smaller than what the ABI prescribes, correct?
> 
>
Yes.
> 
>> Let's assume I set the record to packed 16bytes, this would
make reading and writing records as a whole safe on all platform/
architecture combinations right? Apart from a few padding bytes, what
are the performance penalties of doing this then? Why would there be
penalties?
> 
> The cpu cache will contain lots of unused padding
bytes.

Thanks, I think everything is clear now. My plan now is to
respect default padding and write records in one go to disk. The padding
value will be written to the file header so the records can be read back
one variable at a time when padding differs, otherwise they will be read
back in one go again. This will sure come at a cost, but only if the
file is shared between different ABI's (as is the case when sharing
between different endianess). The result will be that the data
structures will be at default padding internally allways making optimal
use of the CPU. 

So is there a way to get the padding value at runtime?


Darius 

Links:
------
[1] mailto:dhkblaszyk at zeelandnet.nl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20121011/1001c5f1/attachment.html>


More information about the fpc-pascal mailing list