AlignedAllocs
lightweight cross-platform allocation of aligned memory for an n-Vector{T} where isbitstype(T)
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.2%) to scientific vocabulary
Keywords
Repository
lightweight cross-platform allocation of aligned memory for an n-Vector{T} where isbitstype(T)
Basic Info
- Host: GitHub
- Owner: JeffreySarnoff
- License: mit
- Language: Julia
- Default Branch: main
- Homepage: https://github.com/JeffreySarnoff/AlignedAllocs.jl
- Size: 175 KB
Statistics
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
- Releases: 13
Topics
Metadata Files
README.md
AlignedAllocs.jl
lightweight cross-platform allocation of aligned memory
Copyright 2025 by Jeffrey Sarnoff. Relased under the MIT License.
exports
memalign(T, item_count, byte_alignment)- returns an uninitialized DenseVector{T} of length
item_countaligned tobyte_alignmentbytes Tis a bitstype
- returns an uninitialized DenseVector{T} of length
memalign_clear(T, item_count, byte_alignment)- returns a zeroed DenseVector{T} of length
item_countaligned tobyte_alignmentbytes Tis a bitstype (ensurezero(T)exists)
- returns a zeroed DenseVector{T} of length
alignment(vector)- returns the byte alignment of the vector
why it matters
Modern processors retrieve data in memory into fast chip-local caches. In practice, the unit of memory retrieval is the cache line. For most general purpose computing, the size of (the Level 1) cache line is 64 bytes (one cache line holds 64 UInt8s, 32 Int16s, 16 Float32s, or 8 Float64s). When data is stored aligned to this size, its retrieval is simpler. Straddling two cache lines with a single primitive bitstype value incurs costly delays.
When using SIMD, alignment of 256 bytes (or more, depending on the processor) is critical to getting the throughput one expects from SIMD operations. Running unaligned data through SIMD slows the processing down significantly.
Julia memory alignment for dense vectors of numeric bitstypes is at least 16 bytes and may be 64 bytes. Which of these alignments obtains depends :). At the time of this writing on a Windows system, 512 Float32s align to 64 bytes while 500 or fewer Float32s may align to 16 bytes. Similarly, 256 Float64s align to 64 bytes while 250 or fewer may align to 16 bytes. Without this module, a dense vector of 2008 or fewer UInt8s may align to 16 bytes. If that is not enough uncertainty, the allocation mechanism on Windows differs from the allocation mechanism on Apple and 'nix compatible systems. The specifics are internal to Julia and may change going forward.
The take away is that for smallish dense vectors, you do not know what allocation alignment will be with certainty.
There is some good news. GPU allocations are written to work well with the GPU.
function encodings(bitwidth, typ=UInt16)
n = 2^bitwidth
codes = memalign_clear(typ, n)
codes[:] = collect(map(typ, 0:(n-1)))
codes
end
```
vec::DenseVector = memalign(itemtype, itemcount, byte_alignment = 64)
bitstype , > 0 , 2^p where p > 2
elementtype = Float32 # a type T for which isbitstype(T) is true elementcount = 1024 elementbytes = sizeof(elementtype) * element_count
bytesofalignment = 64 # bytes
vec = memalign(elementtype, elementcount, bytesofalignment)
vec behaves as a DenseVector with enhanced cache-line performance vec is unsafe_wrapped contiguous memory from LLVM intrinsic or C/C++ library function ```
also consider
ArrayAllocators.jl - a type for aligned arrays
Thank you
- Stephan Karpinski
- Gabriel Baraldi
- Diogo Netto
- Bradley
- chakravala
- Jakob Nybo Nissen
- Sinh Trung
- Daniel Wennberg
- foobar_lv2
Owner
- Name: Jeffrey Sarnoff
- Login: JeffreySarnoff
- Kind: user
- Location: New York
- Website: https://github.com/JeffreySarnoff
- Repositories: 32
- Profile: https://github.com/JeffreySarnoff
Citation (CITATION.cff)
# Go to https://citation-file-format.github.io/cff-initializer-javascript/#/ to finish this
cff-version: 1.2.0
title: AlignedAllocs.jl
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Jeffrey Sarnoff
email: jeffrey.sarnoff@gmail.com
doi: 10.5281/zenodo.15095672
GitHub Events
Total
- Create event: 15
- Commit comment event: 30
- Release event: 10
- Issues event: 3
- Delete event: 1
- Issue comment event: 18
- Public event: 1
- Push event: 169
- Pull request event: 4
- Fork event: 1
Last Year
- Create event: 15
- Commit comment event: 30
- Release event: 10
- Issues event: 3
- Delete event: 1
- Issue comment event: 18
- Public event: 1
- Push event: 169
- Pull request event: 4
- Fork event: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 2
- Total pull requests: 5
- Average time to close issues: 3 days
- Average time to close pull requests: 3 days
- Total issue authors: 2
- Total pull request authors: 2
- Average comments per issue: 1.5
- Average comments per pull request: 2.4
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 3
Past Year
- Issues: 2
- Pull requests: 5
- Average time to close issues: 3 days
- Average time to close pull requests: 3 days
- Issue authors: 2
- Pull request authors: 2
- Average comments per issue: 1.5
- Average comments per pull request: 2.4
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 3
Top Authors
Issue Authors
- chakravala (1)
- JuliaTagBot (1)
Pull Request Authors
- dependabot[bot] (3)
- PallHaraldsson (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- julia 3 total
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 11
juliahub.com: AlignedAllocs
lightweight cross-platform allocation of aligned memory for an n-Vector{T} where isbitstype(T)
- Homepage: https://github.com/JeffreySarnoff/AlignedAllocs.jl
- Documentation: https://docs.juliahub.com/General/AlignedAllocs/stable/
- License: MIT
-
Latest release: 0.1.12
published 9 months ago