<div dir="ltr"><div>I don't imagine anyone wants to align to anything that's not a power of 2, or less than a word size. Still, unless the current generality results in extra complication or overheads I wouldn't change it.</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, 22 Oct 2018 at 11:44, Ömer Sinan Ağacan <<a href="mailto:omeragacan@gmail.com">omeragacan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for all the answers. Another surprising thing about the pinned object<br>
allocation primops is that the aligned allocator allows alignment to bytes,<br>
rather than to words (the documentation doesn't say whether it's words or bytes,<br>
but it can be seen from the code that it's actually aligning to the given<br>
byte). Is there a use case for this or people mostly use alignment on word<br>
boundaries?<br>
<br>
Ömer<br>
<br>
Sven Panne <<a href="mailto:svenpanne@gmail.com" target="_blank">svenpanne@gmail.com</a>>, 17 Eki 2018 Çar, 10:29 tarihinde şunu yazdı:<br>
><br>
> Am Di., 16. Okt. 2018 um 23:18 Uhr schrieb Simon Marlow <<a href="mailto:marlowsd@gmail.com" target="_blank">marlowsd@gmail.com</a>>:<br>
>><br>
>> I vaguely recall that this was because 16 byte alignment is the minimum you need for certain foreign types, and it's what malloc() does. Perhaps check the FFI spec and the guarantees that mallocForeignPtrBytes and friends provide?<br>
><br>
><br>
> mallocForeignPtrBytes is defined in terms of malloc (<a href="https://www.haskell.org/onlinereport/haskell2010/haskellch29.html#x37-28400029.1.3" rel="noreferrer" target="_blank">https://www.haskell.org/onlinereport/haskell2010/haskellch29.html#x37-28400029.1.3</a>), which in turn has the following guarantee (<a href="https://www.haskell.org/onlinereport/haskell2010/haskellch31.html#x39-28700031.1" rel="noreferrer" target="_blank">https://www.haskell.org/onlinereport/haskell2010/haskellch31.html#x39-28700031.1</a>):<br>
><br>
> "... All storage allocated by functions that allocate based on a size in bytes must be sufficiently aligned for any of the basic foreign types that fits into the newly allocated storage. ..."<br>
><br>
> The largest basic foreign types are Word64/Double and probably Ptr/FunPtr/StablePtr (<a href="https://www.haskell.org/onlinereport/haskell2010/haskellch8.html#x15-1700008.7" rel="noreferrer" target="_blank">https://www.haskell.org/onlinereport/haskell2010/haskellch8.html#x15-1700008.7</a>), so per spec you need at least an 8-byte alignement. But in an SSE-world I would be *very* reluctant to use an alignment less strict than 16 bytes, otherwise people will probably hate you... :-]<br>
><br>
> Cheers,<br>
> S.<br>
</blockquote></div>