Align all arrays in mjData's buffer to 64 byte boundaries.

The introduction of additional mjData arrays for the implicit integrator caused in a shift in data alignment in memory. In certain combinations of machines and models, this change resulted in ~5% performance regression that appears to be attributable to L2 cache misses.

This change aligns all arrays in mjData to the boundary of a typical L2 cache line size. Benchmarking shows that this resolves the performance regression on a Broadwell machine.

PiperOrigin-RevId: 451652783
Change-Id: I4ed2c2d03453a83a0b4a9b8e224e2fd7c0dadea9
This commit is contained in:
Saran Tunyasuvunakool
2022-05-28 13:02:49 -07:00
committed by Copybara-Service
parent 981fa22302
commit 5cc73c30bf
6 changed files with 28 additions and 30 deletions
+3 -1
View File
@@ -626,7 +626,9 @@ void mj_RungeKutta(const mjModel* m, mjData* d, int N) {
// compute Xfinal
d->time = time + h;
mju_copy(d->qpos, X[0], nq+nv+na);
mju_copy(d->qpos, X[0], nq);
mju_copy(d->qvel, X[0]+nq, nv);
mju_copy(d->act, X[0]+nq+nv, na);
mj_integratePos(m, d->qpos, dX, h);
mju_addToScl(d->qvel, dX+nv, h, nv);
if (na) {