Refactor Newton solver: move Hessian from arena back to the stack.

The changes in 9a0dc20821, moving the Hessian from the stack to the arena, should be rolled back: they prevent future threading over islands. Unlike the stack, arena allocations are not thread-friendly. The reason for the original move was to save memory, but the savings are small: `O(ctx->nH)` and only linear in `nv`. The significant reduction of the Cholesky factor, from quadratic in `nv` to quadratic in the largest dof island — the reduction afforded by 2dd518734f — remains in place.

Also refactor and improve readability.

PiperOrigin-RevId: 685717356
Change-Id: Ia9ec3e44a62d459a3b9cffb578cf6479d5aa1d7f
This commit is contained in:
Yuval Tassa
2024-10-14 08:32:44 -07:00
committed by Copybara-Service
parent ac91a7639d
commit 7ec94f46d4
4 changed files with 260 additions and 222 deletions
+3 -3
View File
@@ -89,7 +89,7 @@ MJAPI void mju_superSparse(int nr, int* rowsuper,
// res_rowadr is required to be precomputed
MJAPI void mju_sqrMatTDSparse(mjtNum* res, const mjtNum* mat, const mjtNum* matT,
const mjtNum* diag, int nr, int nc,
int* res_rownnz, int* res_rowadr, int* res_colind,
int* res_rownnz, const int* res_rowadr, int* res_colind,
const int* rownnz, const int* rowadr,
const int* colind, const int* rowsuper,
const int* rownnzT, const int* rowadrT,
@@ -106,8 +106,8 @@ MJAPI void mju_sqrMatTDSparseInit(int* res_rownnz, int* res_rowadr, int nr,
MJAPI void mju_sqrMatTDUncompressedInit(int* res_rowadr, int nc);
// compute row non-zeros of reverse-Cholesky factor L, return total
MJAPI int mju_cholFactorNNZ(int* L_rownnz, int* parent, int* flag, const int* rownnz,
const int* rowadr, const int* colind, int n);
MJAPI int mju_cholFactorNNZ(int* L_rownnz, const int* rownnz, const int* rowadr, const int* colind,
int n, mjData* d);
#ifdef __cplusplus
}