Skip to main content

TilingStrategy

Trait TilingStrategy 

Source
pub trait TilingStrategy<T, Arch, Align>
where Arch: SimdArch, Align: Alignment,
{ const TILE_M: usize; const TILE_N: usize; // Required methods fn gemm( a: &SimdView<'_, T, Arch, Align>, b: &SimdView<'_, T, Arch, Align>, c: &mut [T], m: usize, n: usize, k: usize, ) -> Result<(), SimdError>; fn gemv( a: &SimdView<'_, T, Arch, Align>, x: &SimdView<'_, T, Arch, Align>, y: &mut [T], nrows: usize, ncols: usize, ) -> Result<(), SimdError>; fn gemv_transpose( a: &SimdView<'_, T, Arch, Align>, x: &SimdView<'_, T, Arch, Align>, y: &mut [T], nrows: usize, ncols: usize, ) -> Result<(), SimdError>; fn gemv_strided( a: &SimdView<'_, T, Arch, Align>, x: &SimdView<'_, T, Arch, Align>, y: &mut [T], nrows: usize, ncols: usize, lda: usize, ) -> Result<(), SimdError>; fn gemv_transpose_strided( a: &SimdView<'_, T, Arch, Align>, x: &SimdView<'_, T, Arch, Align>, y: &mut [T], nrows: usize, ncols: usize, lda: usize, ) -> Result<(), SimdError>; fn dot( a: &SimdView<'_, T, Arch, Align>, b: &SimdView<'_, T, Arch, Align>, ) -> Result<T, SimdError>; }
Expand description

Trait representing a monomorphized register-blocking/tiling strategy.

Implemented as a blanket over TilingPolicy<TILE_M, TILE_N>. The const generic parameters encode the tile shape so the compiler emits loop-unrolled, register-blocked kernels with zero runtime overhead.

§Examples

use hermes_simd_core::tiling::{TilingPolicy, TilingStrategy};
use hermes_simd_core::view::SimdView;
use hermes_simd_core::align::Unaligned;
use hermes_simd_intrinsics::Scalar;

let a = [1.0_f32; 4];
let b = [2.0_f32; 4];
let va = SimdView::<f32, Scalar, Unaligned>::new(&a).unwrap();
let vb = SimdView::<f32, Scalar, Unaligned>::new(&b).unwrap();
let dot = <TilingPolicy<1, 1> as TilingStrategy<f32, Scalar, Unaligned>>::dot(&va, &vb)
    .expect("lengths equal");
assert!((dot - 8.0_f32).abs() < 1e-6);

Required Associated Constants§

Source

const TILE_M: usize

The number of rows in the register block.

Source

const TILE_N: usize

The number of columns (vectors of size LANE_COUNT) in the register block.

Required Methods§

Source

fn gemm( a: &SimdView<'_, T, Arch, Align>, b: &SimdView<'_, T, Arch, Align>, c: &mut [T], m: usize, n: usize, k: usize, ) -> Result<(), SimdError>

Perform tiled matrix multiplication c += a * b using this strategy.

Source

fn gemv( a: &SimdView<'_, T, Arch, Align>, x: &SimdView<'_, T, Arch, Align>, y: &mut [T], nrows: usize, ncols: usize, ) -> Result<(), SimdError>

Perform tiled matrix-vector multiplication y += A * x using this strategy.

Source

fn gemv_transpose( a: &SimdView<'_, T, Arch, Align>, x: &SimdView<'_, T, Arch, Align>, y: &mut [T], nrows: usize, ncols: usize, ) -> Result<(), SimdError>

Perform tiled transposed matrix-vector multiplication y += Aᵀ * x (A row-major nrows × ncols, x length nrows, y length ncols).

Source

fn gemv_strided( a: &SimdView<'_, T, Arch, Align>, x: &SimdView<'_, T, Arch, Align>, y: &mut [T], nrows: usize, ncols: usize, lda: usize, ) -> Result<(), SimdError>

Perform tiled matrix-vector multiplication y += A * x over a row-major sub-matrix: nrows × ncols with row stride lda ≥ ncols (lda = ncols is the packed Self::gemv).

Source

fn gemv_transpose_strided( a: &SimdView<'_, T, Arch, Align>, x: &SimdView<'_, T, Arch, Align>, y: &mut [T], nrows: usize, ncols: usize, lda: usize, ) -> Result<(), SimdError>

Perform tiled transposed matrix-vector multiplication y += Aᵀ * x over a row-major sub-matrix: nrows × ncols with row stride lda ≥ ncols (lda = ncols is the packed Self::gemv_transpose).

Source

fn dot( a: &SimdView<'_, T, Arch, Align>, b: &SimdView<'_, T, Arch, Align>, ) -> Result<T, SimdError>

Perform tiled dot product computation using this strategy.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<T, Arch, Align, const TILE_M: usize, const TILE_N: usize> TilingStrategy<T, Arch, Align> for TilingPolicy<TILE_M, TILE_N>
where Arch: SimdArch + SimdKernel<T>, Align: Alignment, T: NumericElement,

Source§

const TILE_M: usize = TILE_M

Source§

const TILE_N: usize = TILE_N