Skip to main content

select_format

Function select_format 

Source
pub fn select_format(avg_nnz_per_row: f64, n_rows: usize) -> SpMatFormat
Expand description

Select the recommended sparse format based on average nnz per row and matrix size.

This is a pure heuristic function with no GPU I/O and no format conversion. It is intended to guide decisions about which format to build, not to dispatch an existing GPU matrix.

§Selection rules (evaluated in order)

  1. avg_nnz_per_row <= 2.0SpMatFormat::Csr (scalar kernel territory)
  2. avg_nnz_per_row <= 32.0SpMatFormat::Ell (regular, coalesced ELL)
  3. avg_nnz_per_row > 128.0 && n_rows >= 1024SpMatFormat::Csr5 (load-balanced)
  4. Otherwise → SpMatFormat::Hyb (irregular overflow pattern)