Reference
Constants
CACHE_LINE_SIZE::Int: L1 cache line size detected at load time, falling back toFallbackCacheLineSize.FallbackCacheLineSize::Int: Static fallback alignment (64 bytes).
Public Functions
alignment(xs::AbstractArray) -> Int: Largest power-of-two alignment dividing the array's data pointer (returns0for empty arrays).
AlignedAllocs.memalign — Functionmemalign(::Type{T}, nitems::Integer, align::Integer=CACHE_LINE_SIZE) where TAllocate aligned storage for nitems elements of type T and return a Vector{T} whose data pointer is aligned to align bytes. align must be a power of two at least 16.
AlignedAllocs.memalign_clear — Functionmemalign_clear(::Type{T}, nitems::Integer, align::Integer=CACHE_LINE_SIZE) where TAllocate aligned storage for nitems elements of type T, zero-initialize it, and return a Vector{T}.
AlignedAllocs.memaligned — Functionmemaligned(::Type{T}, dims...; align=CACHE_LINE_SIZE) where TAllocate aligned storage for a multi-dimensional array with element type T. The return value shares storage with a vector allocated via [memalign] and is reshaped to match dims.
AlignedAllocs.memaligned_clear — Functionmemaligned_clear(::Type{T}, dims...; align=CACHE_LINE_SIZE) where TAllocate aligned storage for a multi-dimensional array and zero-initialise the contents before reshaping to dims.
AlignedAllocs.memalign_fixed — Functionmemalign_fixed(::Type{T}, dims...; align=CACHE_LINE_SIZE) where TAllocate aligned storage for a FixedSizeArray of element type T with shape dims. The returned array uses memalign and preserves the alignment guarantee for the underlying dense storage.
AlignedAllocs.memalign_clear_fixed — Functionmemalign_clear_fixed(::Type{T}, dims...; align=CACHE_LINE_SIZE) where TAllocate aligned storage for a FixedSizeArray of element type T with shape dims and initialize all entries to zero.
AlignedAllocs.alignment — Functionalignment(xs::AbstractArray)Return the largest power-of-two alignment that divides the data pointer of xs. Empty arrays return 0 because they do not own storage.
Supporting Internals
The following helpers are useful when extending the package to other platforms or writing integration tests.
is_alignment_valid(align::Integer) -> Boolcheck_args(::Type{T}, nitems::Integer, align::Integer)zeromem(ptr::Ptr{UInt8}, nbytes::Int)confirm_alignment(ptr::Ptr, align::Integer)alloc_error(err)
Continue to the Technical Notes for information on compatibility and implementation internals.