Most malloc implementations that I'm aware of provide, at best, 16-byte
allignment. However, newer SIMD instructions (like avx) require more
alignment. Additionally, atomic operations may need to operate on an entire
cacheline (64 bytes
https://www.google.com/search?q=x64+cacheline+size&ie=utf-8&oe=utf-8#q=x64+cache+line+size)
to avoid expensive pipelining stalls.

There is currently no direct way to request 64-byte aligned memory in
Julia, although I can see the benefits of observing such a requirement. By
considering some of the characteristics of the GC, the following will
currently work (in 0.4 and master):

type Align64 # offset 8 (hidden tag)
    padding16::NTuple{6, Int64} # offset 16
    aligned64::NTuple{8, Int64} # any 64 byte object (or smaller)
    padding8::NTuple{1, Int64} # padding to make sure this ends up in the
128-byte pool
end # offset 136


On Fri, Sep 18, 2015 at 12:13 PM Stefan Karpinski <[email protected]>
wrote:

> I don't think most CPUs require more than 16-byte alignment. 64-byte
> alignment seems extreme.
>
> On Fri, Sep 18, 2015 at 5:32 AM, Tim Holy <[email protected]> wrote:
>
>> Your best bet is to check src/gc.jl. I'm pretty sure they're already
>> aligned
>> to 16 bytes, but I don't know about 64 and haven't looked myself.
>>
>> --Tim
>>
>> On Friday, September 18, 2015 12:14:19 AM [email protected] wrote:
>> > Hi all,
>> > I would like to ask if it is possible to enforce memory alignment for
>> large
>> > arrays, such that that arrays are aligned to 64 bytes and can be
>> > efficiently with SIMD instructions. I assume to call library functions
>> > wirtten in c/c++.
>> > Thanks for the answer.
>> > Tomas
>>
>>
>

Reply via email to