Skip to content

[teeny] Reimplement the posdef matrix kernels on teeny (all 5 layouts) #113

Description

@balbasty

Part of the teeny refactor (umbrella fastfields-lib#21).

Replace the template-hack per-layout posdef kernels (posdef/{eye,diag,estatics,full}.inl + cholesky.h/utils.h machinery) with a single, readable posdef/matrix.h that expresses each per-voxel SPD layout on teeny views.

Scope

  • One header posdef/matrix.h, namespaces ff::<FF_DEVICE>::posdef::{eye,diag,estatics,sym,full} + chol.
  • All five packed layouts selected by packed length via guess_type(C, CC): Eye (CC=1), Diag (CC=C), ESTATICS (CC=2C-1), Sym (CC=C(C+1)/2, diag-then-rows), Full (CC=C²). The Eye>Diag>ESTATICS>Sym>Full priority is the efficiency order; collisions are exact equivalents (C=1: all layouts == a scalar; C=2: ESTATICS == Sym, same matrix + packing).
  • Ops per layout: matvec / addmatvec_ / submatvec_ / matvec_backward (Sym) / solve(_) / invert(_), plus the Cholesky helpers with weighted-workspace variants for Sym/Full.

Numerics preserved

  • reduce_t = double accumulation regardless of scalar_t (float/double), so mat-vec dot products and the Cholesky factorisation don't lose precision — mirrors jitfields.
  • The 1.000001 diagonal ridge and 1e-40 pivot floor are carried over verbatim.

Gate

Validated bit-exactly against the old per-layout kernels and vs a brute-force double reference (fable review: 22,210 bit-exact old-vs-new checks + sanitizers, zero correctness bugs). The cpu-lib oracle (test_posdef.cpp) is the CI gate.

Part of fastfields-lib#21.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions