Skip to main content

TileIO

Trait TileIO 

Source
pub trait TileIO {
    // Required method
    unsafe fn address(&self, base: *const f32, c: Coord2) -> *const f32;

    // Provided methods
    unsafe fn load(&self, base: *const f32, c: Coord2) -> f32 { ... }
    unsafe fn store(&self, base: *mut f32, c: Coord2, v: f32) { ... }
    unsafe fn prefetch(&self, base: *const f32, c: Coord2) { ... }
}
Expand description

Tile I/O trait — load / store / prefetch parameterized over the physical layout. Two impls today: RowMajorTile (the standard flat layout) and StridedTile (when reading a non-contiguous view, e.g. last-axis Narrow into Attention).

Methods take pointers (not slices) so the abstraction works for both owned and aliased buffers.

Required Methods§

Source

unsafe fn address(&self, base: *const f32, c: Coord2) -> *const f32

Compute the byte address for a coordinate. Used by load / store / prefetch so impls only need to define the address arithmetic once. SAFETY: caller checks bounds.

Provided Methods§

Source

unsafe fn load(&self, base: *const f32, c: Coord2) -> f32

Load a tile element by (row, col). SAFETY: caller ensures the address is valid for read.

Source

unsafe fn store(&self, base: *mut f32, c: Coord2, v: f32)

Store an element by (row, col). SAFETY: caller ensures the address is valid for write.

Source

unsafe fn prefetch(&self, base: *const f32, c: Coord2)

Hint to the prefetcher. On aarch64 issues a single prfm pldl1keep (load into L1, retain). Elsewhere a no-op. SAFETY: caller ensures the address is in a valid mapping.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§