<div dir="ltr">On 28 October 2013 04:36, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org" target="_blank">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<br><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 10/27/13 11:26 AM, safety0ff wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sunday, 27 October 2013 at 10:45:31 UTC, Andrei Alexandrescu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 10/26/13 8:00 AM, Andrei Alexandrescu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
AlignedMallocator that uses the _aligned_* family on Windows and the<br>
respective functions on Posix. On Windows, allocate() requests would<br>
pass a default of platformSize (i.e. 16 I suspect) to _aligned_malloc.<br>
</blockquote>
<br>
Just implemented AlignedMallocator and pushed.<br>
<br>
<a href="http://erdani.com/d/phobos-prerelease/std_allocator.html#.AlignedMallocator" target="_blank">http://erdani.com/d/phobos-<u></u>prerelease/std_allocator.html#<u></u>.AlignedMallocator</a><br>
<br>
</blockquote>
The constraints on the alignment parameter are neither documented nor<br>
checked.<br>
<br>
i.e. Alignment must be a power of two, and for posix_memalign it must<br>
additionally be greater than sizeof(void*).<br>
</blockquote>
<br></div>
Fixed, will push soon.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I can only think of one use case for needing runtime specified<br>
alignment: allocating operating system page sized chunks.<br>
Are there any other use cases?<br>
</blockquote>
<br></div>
Cache-line aligned.<br>
<br>
<a href="http://stackoverflow.com/questions/794632/programmatically-get-the-cache-line-size/1900464" target="_blank">http://stackoverflow.com/<u></u>questions/794632/<u></u>programmatically-get-the-<u></u>cache-line-size/1900464</a><br>

<br>
Also some I/O requires aligned buffers.<br>
<br>
<a href="http://goo.gl/ni860U" target="_blank">http://goo.gl/ni860U</a></blockquote><div><br></div><div>GPU's also tend to deal with strict alignments of various buffers.</div><div><br></div><div>SIMD requires >= 16byte alignment, which is higher than the default 4-8 byte alignment of many allocators.</div>
</div></div></div>