Why 64-Byte Alignment Matters: Designing the Storage Core
Decoupling tensor storage from metadata and enforcing 64-byte cache line alignment.
Standard Rust Vec<T> alignment is only 4 bytes for f32, causing AVX-512 unaligned load penalties on CPU.
Using std::alloc::alloc with Layout::from_size_align(size, 64) guarantees single-cycle vector register loading.
Why 64-Byte Alignment Matters: Designing the Storage Core
Standard Rust Vec<T> alignment is only 4 bytes for f32, causing AVX-512 unaligned load penalties on CPU.
Using std::alloc::alloc with Layout::from_size_align(size, 64) guarantees single-cycle vector register loading.
When building a machine learning framework in Rust, the most common trap is wrapping a Vec<f32> in a struct.
While simple, Vec<T> does not guarantee 64-byte alignment, meaning every SIMD instruction has to use unaligned load instructions (vmovups instead of vmovaps).
In Dark Forest, Storage<T, D> manages raw memory directly:
- Guarantees 64-byte memory boundary alignment.
- Enables direct conversion to CUDA pinned host memory.