Commit 31758dc
tinyasm: avoid copying the block dofmap in BlockJacobi::solve() (#5348)
dofsPerBlock is a vector<vector<PetscInt>>, so `auto dofmap =
dofsPerBlock[p]` deduces by value and heap-allocates + copies the block's
dofmap on every block, on every application of the preconditioner.
solve() runs once per Krylov iteration and block counts are typically in
the thousands, so this is on the order of a million small allocations per
linear solve.
Bind by const reference instead. No behavioural change: dofmap is only
read.
A standalone microbenchmark mirroring the loop structure (20k blocks,
dof in [4,20], 50 applications, -O2) measures the copy at 11-13% of
solve() runtime.1 parent 79030a6 commit 31758dc
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
0 commit comments