On 28 October 2013 04:36, Andrei Alexandrescu <[email protected] > wrote:
> On 10/27/13 11:26 AM, safety0ff wrote: > >> On Sunday, 27 October 2013 at 10:45:31 UTC, Andrei Alexandrescu wrote: >> >>> On 10/26/13 8:00 AM, Andrei Alexandrescu wrote: >>> >>>> AlignedMallocator that uses the _aligned_* family on Windows and the >>>> respective functions on Posix. On Windows, allocate() requests would >>>> pass a default of platformSize (i.e. 16 I suspect) to _aligned_malloc. >>>> >>> >>> Just implemented AlignedMallocator and pushed. >>> >>> http://erdani.com/d/phobos-**prerelease/std_allocator.html#** >>> .AlignedMallocator<http://erdani.com/d/phobos-prerelease/std_allocator.html#.AlignedMallocator> >>> >>> The constraints on the alignment parameter are neither documented nor >> checked. >> >> i.e. Alignment must be a power of two, and for posix_memalign it must >> additionally be greater than sizeof(void*). >> > > Fixed, will push soon. > > > I can only think of one use case for needing runtime specified >> alignment: allocating operating system page sized chunks. >> Are there any other use cases? >> > > Cache-line aligned. > > http://stackoverflow.com/**questions/794632/**programmatically-get-the-** > cache-line-size/1900464<http://stackoverflow.com/questions/794632/programmatically-get-the-cache-line-size/1900464> > > Also some I/O requires aligned buffers. > > http://goo.gl/ni860U GPU's also tend to deal with strict alignments of various buffers. SIMD requires >= 16byte alignment, which is higher than the default 4-8 byte alignment of many allocators.
