Refactor islands to be memory contiguous.
PiperOrigin-RevId: 755803476 Change-Id: I41972b07e0d5ef5d0117c94f565b93367b87458b
This commit is contained in:
committed by
Copybara-Service
parent
449de73430
commit
ecb769fc3a
+49
-9
@@ -199,6 +199,7 @@ struct mjData_ {
|
||||
int nJ; // number of non-zeros in constraint Jacobian
|
||||
int nA; // number of non-zeros in constraint inverse inertia matrix
|
||||
int nisland; // number of detected constraint islands
|
||||
int nidof; // number of dofs in all islands
|
||||
|
||||
// global properties
|
||||
mjtNum time; // simulation time
|
||||
@@ -409,16 +410,51 @@ struct mjData_ {
|
||||
mjtNum* efc_R; // inverse constraint mass (nefc x 1)
|
||||
int* tendon_efcadr; // first efc address involving tendon; -1: none (ntendon x 1)
|
||||
|
||||
// computed by mj_island
|
||||
// computed by mj_island (island dof structure)
|
||||
int* dof_island; // island id of this dof; -1: none (nv x 1)
|
||||
int* island_dofnum; // number of dofs in island (nisland x 1)
|
||||
int* island_dofadr; // start address in island_dofind (nisland x 1)
|
||||
int* island_dofind; // island dof indices; -1: none (nv x 1)
|
||||
int* dof_islandind; // dof island indices; -1: none (nv x 1)
|
||||
int* island_nv; // number of dofs in this island (nisland x 1)
|
||||
int* island_idofadr; // island start address in idof vector (nisland x 1)
|
||||
int* island_dofadr; // island start address in dof vector (nisland x 1)
|
||||
int* map_dof2idof; // map from dof to idof (nv x 1)
|
||||
int* map_idof2dof; // map from idof to dof; idof >= ni: unconstrained (nv x 1)
|
||||
|
||||
// computed by mj_island (dofs sorted by island)
|
||||
mjtNum* ifrc_smooth; // net unconstrained force (nidof x 1)
|
||||
mjtNum* iacc_smooth; // unconstrained acceleration (nidof x 1)
|
||||
int* iM_rownnz; // inertia: non-zeros in each row (nidof x 1)
|
||||
int* iM_rowadr; // inertia: address of each row in iM_colind (nidof x 1)
|
||||
int* iM_diagnum; // inertia: num of consecutive diagonal elements (nidof x 1)
|
||||
int* iM_colind; // inertia: column indices of non-zeros (nM x 1)
|
||||
mjtNum* iM; // total inertia (sparse) (nM x 1)
|
||||
mjtNum* iLD; // L'*D*L factorization of M (sparse) (nM x 1)
|
||||
mjtNum* iLDiagInv; // 1/diag(D) (nidof x 1)
|
||||
mjtNum* iacc; // acceleration (nidof x 1)
|
||||
|
||||
// computed by mj_island (island constraint structure)
|
||||
int* efc_island; // island id of this constraint (nefc x 1)
|
||||
int* island_efcnum; // number of constraints in island (nisland x 1)
|
||||
int* island_efcadr; // start address in island_efcind (nisland x 1)
|
||||
int* island_efcind; // island constraint indices (nefc x 1)
|
||||
int* island_ne; // number of equality constraints in island (nisland x 1)
|
||||
int* island_nf; // number of friction constraints in island (nisland x 1)
|
||||
int* island_nefc; // number of constraints in island (nisland x 1)
|
||||
int* island_iefcadr; // start address in iefc vector (nisland x 1)
|
||||
int* map_efc2iefc; // map from efc to iefc (nefc x 1)
|
||||
int* map_iefc2efc; // map from iefc to efc (nefc x 1)
|
||||
|
||||
// computed by mj_island (constraints sorted by island)
|
||||
int* iefc_type; // constraint type (mjtConstraint) (nefc x 1)
|
||||
int* iefc_id; // id of object of specified type (nefc x 1)
|
||||
int* iefc_J_rownnz; // number of non-zeros in constraint Jacobian row (nefc x 1)
|
||||
int* iefc_J_rowadr; // row start address in colind array (nefc x 1)
|
||||
int* iefc_J_rowsuper; // number of subsequent rows in supernode (nefc x 1)
|
||||
int* iefc_J_colind; // column indices in constraint Jacobian (nJ x 1)
|
||||
int* iefc_JT_rownnz; // number of non-zeros in constraint Jacobian row T (nidof x 1)
|
||||
int* iefc_JT_rowadr; // row start address in colind array T (nidof x 1)
|
||||
int* iefc_JT_rowsuper; // number of subsequent rows in supernode T (nidof x 1)
|
||||
int* iefc_JT_colind; // column indices in constraint Jacobian T (nJ x 1)
|
||||
mjtNum* iefc_J; // constraint Jacobian (nJ x 1)
|
||||
mjtNum* iefc_JT; // constraint Jacobian transposed (nJ x 1)
|
||||
mjtNum* iefc_frictionloss; // frictionloss (friction) (nefc x 1)
|
||||
mjtNum* iefc_D; // constraint mass (nefc x 1)
|
||||
mjtNum* iefc_R; // inverse constraint mass (nefc x 1)
|
||||
|
||||
// computed by mj_projectConstraint (PGS solver)
|
||||
int* efc_AR_rownnz; // number of non-zeros in AR (nefc x 1)
|
||||
@@ -436,8 +472,12 @@ struct mjData_ {
|
||||
|
||||
// computed by mj_fwdConstraint/mj_inverse
|
||||
mjtNum* efc_b; // linear cost term: J*qacc_smooth - aref (nefc x 1)
|
||||
mjtNum* efc_force; // constraint force in constraint space (nefc x 1)
|
||||
mjtNum* iefc_aref; // reference pseudo-acceleration (nefc x 1)
|
||||
int* iefc_state; // constraint state (mjtConstraintState) (nefc x 1)
|
||||
mjtNum* iefc_force; // constraint force in constraint space (nefc x 1)
|
||||
int* efc_state; // constraint state (mjtConstraintState) (nefc x 1)
|
||||
mjtNum* efc_force; // constraint force in constraint space (nefc x 1)
|
||||
mjtNum* ifrc_constraint; // constraint force (nidof x 1)
|
||||
|
||||
// thread pool pointer
|
||||
uintptr_t threadpool;
|
||||
|
||||
@@ -677,7 +677,6 @@ struct mjvSceneState_ {
|
||||
mjtNum* bvh_aabb_dyn;
|
||||
mjtByte* bvh_active;
|
||||
int* island_dofadr;
|
||||
int* island_dofind;
|
||||
int* dof_island;
|
||||
int* efc_island;
|
||||
int* tendon_efcadr;
|
||||
|
||||
+49
-15
@@ -739,23 +739,56 @@
|
||||
X( int, efc_state, MJ_D(nefc), 1 )
|
||||
|
||||
// array fields of mjData that are used in the dual problem
|
||||
#define MJDATA_ARENA_POINTERS_DUAL \
|
||||
X( int, efc_AR_rownnz, MJ_D(nefc), 1 ) \
|
||||
X( int, efc_AR_rowadr, MJ_D(nefc), 1 ) \
|
||||
X( int, efc_AR_colind, MJ_D(nA), 1 ) \
|
||||
X( mjtNum, efc_AR, MJ_D(nA), 1 )
|
||||
#define MJDATA_ARENA_POINTERS_DUAL \
|
||||
X( int, efc_AR_rownnz, MJ_D(nefc), 1 ) \
|
||||
X( int, efc_AR_rowadr, MJ_D(nefc), 1 ) \
|
||||
X( int, efc_AR_colind, MJ_D(nA), 1 ) \
|
||||
X( mjtNum, efc_AR, MJ_D(nA), 1 )
|
||||
|
||||
// array fields of mjData that are used for constraint islands
|
||||
#define MJDATA_ARENA_POINTERS_ISLAND \
|
||||
X( int, dof_island, MJ_M(nv), 1 ) \
|
||||
X( int, island_dofnum, MJ_D(nisland), 1 ) \
|
||||
X( int, island_dofadr, MJ_D(nisland), 1 ) \
|
||||
X( int, island_dofind, MJ_M(nv), 1 ) \
|
||||
X( int, dof_islandind, MJ_M(nv), 1 ) \
|
||||
X( int, efc_island, MJ_D(nefc), 1 ) \
|
||||
X( int, island_efcnum, MJ_D(nisland), 1 ) \
|
||||
X( int, island_efcadr, MJ_D(nisland), 1 ) \
|
||||
X( int, island_efcind, MJ_D(nefc), 1 )
|
||||
#define MJDATA_ARENA_POINTERS_ISLAND \
|
||||
X( int, dof_island, MJ_M(nv), 1 ) \
|
||||
X( int, island_nv, MJ_D(nisland), 1 ) \
|
||||
X( int, island_idofadr, MJ_D(nisland), 1 ) \
|
||||
X( int, island_dofadr, MJ_D(nisland), 1 ) \
|
||||
X( int, map_dof2idof, MJ_M(nv), 1 ) \
|
||||
X( int, map_idof2dof, MJ_M(nv), 1 ) \
|
||||
X( mjtNum, ifrc_smooth, MJ_D(nidof), 1 ) \
|
||||
X( mjtNum, iacc_smooth, MJ_D(nidof), 1 ) \
|
||||
X( int, iM_rownnz, MJ_D(nidof), 1 ) \
|
||||
X( int, iM_rowadr, MJ_D(nidof), 1 ) \
|
||||
X( int, iM_diagnum, MJ_D(nidof), 1 ) \
|
||||
X( int, iM_colind, MJ_M(nM), 1 ) \
|
||||
X( mjtNum, iM, MJ_M(nM), 1 ) \
|
||||
X( mjtNum, iLD, MJ_M(nM), 1 ) \
|
||||
X( mjtNum, iLDiagInv, MJ_D(nidof), 1 ) \
|
||||
X( mjtNum, iacc, MJ_D(nidof), 1 ) \
|
||||
X( int, efc_island, MJ_D(nefc), 1 ) \
|
||||
X( int, island_ne, MJ_D(nisland), 1 ) \
|
||||
X( int, island_nf, MJ_D(nisland), 1 ) \
|
||||
X( int, island_nefc, MJ_D(nisland), 1 ) \
|
||||
X( int, island_iefcadr, MJ_D(nisland), 1 ) \
|
||||
X( int, map_efc2iefc, MJ_D(nefc), 1 ) \
|
||||
X( int, map_iefc2efc, MJ_D(nefc), 1 ) \
|
||||
X( int, iefc_type, MJ_D(nefc), 1 ) \
|
||||
X( int, iefc_id, MJ_D(nefc), 1 ) \
|
||||
X( int, iefc_J_rownnz, MJ_D(nefc), 1 ) \
|
||||
X( int, iefc_J_rowadr, MJ_D(nefc), 1 ) \
|
||||
X( int, iefc_J_rowsuper, MJ_D(nefc), 1 ) \
|
||||
X( int, iefc_J_colind, MJ_D(nJ), 1 ) \
|
||||
X( int, iefc_JT_rownnz, MJ_D(nidof), 1 ) \
|
||||
X( int, iefc_JT_rowadr, MJ_D(nidof), 1 ) \
|
||||
X( int, iefc_JT_rowsuper, MJ_D(nidof), 1 ) \
|
||||
X( int, iefc_JT_colind, MJ_D(nJ), 1 ) \
|
||||
X( mjtNum, iefc_J, MJ_D(nJ), 1 ) \
|
||||
X( mjtNum, iefc_JT, MJ_D(nJ), 1 ) \
|
||||
X( mjtNum, iefc_frictionloss, MJ_D(nefc), 1 ) \
|
||||
X( mjtNum, iefc_D, MJ_D(nefc), 1 ) \
|
||||
X( mjtNum, iefc_R, MJ_D(nefc), 1 ) \
|
||||
X( mjtNum, iefc_aref, MJ_D(nefc), 1 ) \
|
||||
X( int, iefc_state, MJ_D(nefc), 1 ) \
|
||||
X( mjtNum, iefc_force, MJ_D(nefc), 1 ) \
|
||||
X( mjtNum, ifrc_constraint, MJ_D(nidof), 1 )
|
||||
|
||||
// array fields of mjData that live in d->arena
|
||||
#define MJDATA_ARENA_POINTERS \
|
||||
@@ -785,6 +818,7 @@
|
||||
X( int, nJ ) \
|
||||
X( int, nA ) \
|
||||
X( int, nisland ) \
|
||||
X( int, nidof ) \
|
||||
X( mjtNum, time ) \
|
||||
X( uintptr_t, threadpool )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user