std.allocator ready for some abuse
Manu
turkeyman at gmail.com
Sun Oct 27 19:30:40 PDT 2013
On 28 October 2013 04:36, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20131028/46353a44/attachment.html>
More information about the Digitalmars-d
mailing list