Add mj_stackAllocInt to get correct size for allocating ints on mjData stack. Reducing stack memory usage by 10% - 15%.

PiperOrigin-RevId: 517672195
Change-Id: Ie14e6c9c99e8b9e1c5d3686b77631f2df0651c67
This commit is contained in:
Kyle Bayes
2023-03-18 13:03:11 -07:00
committed by Copybara-Service
parent fae5e822c0
commit 8696247f9d
17 changed files with 103 additions and 48 deletions
+3 -3
View File
@@ -399,8 +399,8 @@ void mj_tendon(const mjModel* m, mjData* d) {
jacdif = mj_stackAlloc(d, 3*nv);
tmp = mj_stackAlloc(d, nv);
if (issparse) {
chain = (int*)mj_stackAlloc(d, nv);
buf_ind = (int*)mj_stackAlloc(d, nv);
chain = mj_stackAllocInt(d, nv);
buf_ind = mj_stackAllocInt(d, nv);
sparse_buf = mj_stackAlloc(d, nv);
}
@@ -869,7 +869,7 @@ void mj_transmission(const mjModel* m, mjData* d) {
jacdifp = mj_stackAlloc(d, 3*nv);
jac1p = mj_stackAlloc(d, 3*nv);
jac2p = mj_stackAlloc(d, 3*nv);
chain = issparse ? (int*)mj_stackAlloc(d, nv) : NULL;
chain = issparse ? mj_stackAllocInt(d, nv) : NULL;
}
// clear efc_force and moment_exclude