Reference

Constants

  • CACHE_LINE_SIZE::Int: L1 cache line size detected at load time, falling back to FallbackCacheLineSize.
  • FallbackCacheLineSize::Int: Static fallback alignment (64 bytes).

Public Functions

  • alignment(xs::AbstractArray) -> Int: Largest power-of-two alignment dividing the array's data pointer (returns 0 for empty arrays).
AlignedAllocs.memalignFunction
memalign(::Type{T}, nitems::Integer, align::Integer=CACHE_LINE_SIZE) where T

Allocate 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.

source
AlignedAllocs.memalign_clearFunction
memalign_clear(::Type{T}, nitems::Integer, align::Integer=CACHE_LINE_SIZE) where T

Allocate aligned storage for nitems elements of type T, zero-initialize it, and return a Vector{T}.

source
AlignedAllocs.memalignedFunction
memaligned(::Type{T}, dims...; align=CACHE_LINE_SIZE) where T

Allocate 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.

source
AlignedAllocs.memaligned_clearFunction
memaligned_clear(::Type{T}, dims...; align=CACHE_LINE_SIZE) where T

Allocate aligned storage for a multi-dimensional array and zero-initialise the contents before reshaping to dims.

source
AlignedAllocs.memalign_fixedFunction
memalign_fixed(::Type{T}, dims...; align=CACHE_LINE_SIZE) where T

Allocate 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.

source
AlignedAllocs.memalign_clear_fixedFunction
memalign_clear_fixed(::Type{T}, dims...; align=CACHE_LINE_SIZE) where T

Allocate aligned storage for a FixedSizeArray of element type T with shape dims and initialize all entries to zero.

source
AlignedAllocs.alignmentFunction
alignment(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.

source

Supporting Internals

The following helpers are useful when extending the package to other platforms or writing integration tests.

  • is_alignment_valid(align::Integer) -> Bool
  • check_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.