Skip to main content

Module host_csr

Module host_csr 

Source
Expand description

Host-resident CSR matrix and shared CPU kernels for advanced solvers.

The public CsrMatrix stores its arrays in GPU device memory and therefore cannot be constructed or manipulated without a live CUDA context. The classical sparse linear-algebra algorithms in this crate – incomplete Cholesky with level-of-fill (ick), the LOBPCG eigensolver (lobpcg), and smoothed-aggregation algebraic multigrid (amg) – are inherently iterative host-driven procedures: they repeatedly form Galerkin products, solve small dense subproblems, and run sweeps that interleave CPU control flow with linear-algebra primitives.

This module provides HostCsr, a lightweight CPU-side CSR container holding plain Vec<i32>/Vec<f64> arrays, together with the shared building blocks (SpMV, transpose, sparse-sparse product, triangular solves, and a dense Gaussian-elimination solver) that the three algorithms reuse. A HostCsr can be lifted from a GPU CsrMatrix via HostCsr::from_gpu (which downloads the arrays through to_host) and materialised back onto the device through HostCsr::to_gpu.

Structs§

HostCsr
A square or rectangular sparse matrix stored on the host in CSR layout.

Functions§

dense_solve
Solves the dense linear system A x = b via Gaussian elimination with partial pivoting. a is row-major n × n; b has length n.
f64_to_gpu
Converts an f64 to a GpuFloat storage value.
gpu_to_f64
Converts a GpuFloat storage value to f64 using the crate’s bit-cast convention (matching the conversion helpers in the IC(0)/ILU(k) modules).