Skip to content

Accept vector-valued per-qp kernels in the diagonal assembler - #337

Merged
lxmota merged 1 commit into
mainfrom
vector-diagonal-kernels
Aug 24, 2026
Merged

Accept vector-valued per-qp kernels in the diagonal assembler#337
lxmota merged 1 commit into
mainfrom
vector-diagonal-kernels

Conversation

@lxmota

@lxmota lxmota commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds one method to the diagonal assembly path: _accumulate_q_value(::AssembledDiagonal, ...) now also accepts a per-quadrature-point SVector, so a physics-side kernel can return the element diagonal directly instead of a full NxN element matrix that the assembler immediately reduces to its diagonal. The existing SMatrix method is untouched; the two dispatch on the kernel's return type.

Motivation

Carina's matrix-free Jacobi/Chebyshev/AMG preconditioner updates were computing every entry of the 24x24 element stiffness per quadrature point and keeping 24 of them. A CUPTI profile of a production Newmark step measured that kernel at 585 ms per Newton iteration on a V100 — ~100x the per-element cost of the matrix-free action (see Carina benchmark/crosscode/README.md §4). With this method, Carina provides diagonal-only kernels (diag(JxW·G·A·G') needs only the tangent entries pairing a component with itself): the preconditioner update drops 587 → 12.4 ms on a V100 (47x) and 290 → 6.5 ms on an A100 (45x), contributing to end-to-end per-step gains up to 1.9x.

Testing

  • Reviewed on CPU and GPU per the usual protocol:
    • CPU: full Carina test suite passes, including new testsets pinning the vector-returning diagonal kernels to the full-matrix diagonals (rtol 1e-13) at a deformed state, plus the LinearElastic tangent-at-zero specialization.
    • GPU: end-to-end torsion benchmarks on RX 7600 (ROCm), V100 and A100 (CUDA) hold all correctness invariants (4,455 CG iterations, |U|_max = 3.98e-02) with the diagonal path in use every Newton iteration.

A diagonal-only element kernel can now return the per-quadrature-point
diagonal directly as an SVector, so the full NxN element matrix is never
formed.  The existing SMatrix method is untouched; the two dispatch on
the kernel's return type.

Signed-off-by: Alejandro Mota <amota@sandia.gov>
@lxmota
lxmota requested a review from cmhamel August 24, 2026 00:15
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.99%. Comparing base (beda361) to head (76ad13e).

Files with missing lines Patch % Lines
src/assemblers/Assemblers.jl 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #337      +/-   ##
==========================================
- Coverage   69.01%   68.99%   -0.03%     
==========================================
  Files          55       55              
  Lines        6523     6525       +2     
==========================================
  Hits         4502     4502              
- Misses       2021     2023       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lxmota
lxmota merged commit ad91ed8 into main Aug 24, 2026
9 of 13 checks passed
@lxmota
lxmota deleted the vector-diagonal-kernels branch August 24, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants