Sparse ten_J and ten_J_colind memory
PiperOrigin-RevId: 868834376 Change-Id: Iec92d9e09e3134666895e54a78cb02439d74a4de
This commit is contained in:
committed by
Copybara-Service
parent
b466829482
commit
336e1026a4
+11
-3
@@ -224,7 +224,7 @@ void mj_makeModel(mjModel** dest,
|
||||
// CHECK SIZE PARAMETERS
|
||||
{
|
||||
// dummy variables for MJMODEL_SIZES set after mjModel construction
|
||||
int nnames_map = 0, nJmom = 0, nJten = 0, ngravcomp = 0, nemax = 0, njmax = 0, nconmax=0;
|
||||
int nnames_map=0, nJmom=0, ngravcomp=0, nemax=0, njmax=0, nconmax=0;
|
||||
int nuserdata=0, nsensordata=0, npluginstate=0, nhistory=0, narena=0, nbuffer=0;
|
||||
|
||||
// sizes must be non-negative and fit in int, except for the byte arrays texdata and textdata
|
||||
@@ -240,10 +240,10 @@ void mj_makeModel(mjModel** dest,
|
||||
return; \
|
||||
}
|
||||
MJMODEL_SIZES
|
||||
#undef X
|
||||
#undef X
|
||||
|
||||
// suppress unused variable warnings
|
||||
(void)nnames_map; (void)nJmom; (void)nJten; (void)ngravcomp; (void)nemax; (void)njmax; (void)nconmax;
|
||||
(void)nnames_map; (void)nJmom; (void)ngravcomp; (void)nemax; (void)njmax; (void)nconmax;
|
||||
(void)nuserdata; (void)nsensordata; (void)npluginstate; (void)nhistory; (void)narena;
|
||||
(void)nbuffer;
|
||||
}
|
||||
@@ -964,6 +964,9 @@ void mj_makeDofDofMaps(int nv, int nM, int nC, int nD,
|
||||
static void mj_setPtrData(const mjModel* m, mjData* d) {
|
||||
char* ptr = (char*)d->buffer;
|
||||
|
||||
// prepare symbols needed by xmacro
|
||||
MJDATA_POINTERS_PREAMBLE(m);
|
||||
|
||||
// assign pointers with padding
|
||||
#define X(type, name, nr, nc) \
|
||||
d->name = (type*)(ptr + SKIP((intptr_t)ptr)); \
|
||||
@@ -1044,6 +1047,9 @@ void mj_makeRawData(mjData** dest, const mjModel* m) {
|
||||
mjERROR("could not allocate mjData");
|
||||
}
|
||||
|
||||
// prepare symbols needed by xmacro
|
||||
MJDATA_POINTERS_PREAMBLE(m);
|
||||
|
||||
// compute buffer size
|
||||
d->nbuffer = 0;
|
||||
d->buffer = d->arena = NULL;
|
||||
@@ -1154,6 +1160,7 @@ mjData* mj_copyDataVisual(mjData* dest, const mjModel* m, const mjData* src, int
|
||||
|
||||
// copy buffer
|
||||
{
|
||||
MJDATA_POINTERS_PREAMBLE(m)
|
||||
if (flg_all) {
|
||||
#define X(type, name, nr, nc) \
|
||||
memcpy((char*)dest->name, (const char*)src->name, sizeof(type)*(m->nr)*nc);
|
||||
@@ -1339,6 +1346,7 @@ static void _resetData(const mjModel* m, mjData* d, unsigned char debug_value) {
|
||||
#ifdef ADDRESS_SANITIZER
|
||||
{
|
||||
#define X(type, name, nr, nc) memset(d->name, (int)debug_value, sizeof(type)*(m->nr)*(nc));
|
||||
MJDATA_POINTERS_PREAMBLE(m)
|
||||
MJDATA_POINTERS
|
||||
#undef X
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ void SaveToWebp(int width, int height, const std::byte* data,
|
||||
|
||||
const void* GetValue(const mjModel* model, const mjData* data,
|
||||
const char* field, int index) {
|
||||
MJDATA_POINTERS_PREAMBLE(model);
|
||||
#define X(TYPE, NAME, NR, NC) \
|
||||
if (!std::strcmp(#NAME, field) && !std::strcmp(#TYPE, "mjtNum")) { \
|
||||
if (index >= 0 && index < model->NR * NC) { \
|
||||
|
||||
@@ -3226,16 +3226,7 @@ int mjCModel::CountNJmom(const mjModel* m) {
|
||||
return count;
|
||||
}
|
||||
|
||||
// compute non-zeros in ten_J matrix
|
||||
int mjCModel::CountNJten(const mjModel* m) {
|
||||
int nv = m->nv;
|
||||
int ntendon = m->ntendon;
|
||||
|
||||
// conservative upper bound: each tendon can have at most nv non-zeros
|
||||
// TODO(taylorhowell): compute tighter bound
|
||||
int count = ntendon * nv;
|
||||
return count;
|
||||
}
|
||||
|
||||
// copy objects outside kinematic tree
|
||||
void mjCModel::CopyObjects(mjModel* m) {
|
||||
@@ -5046,9 +5037,6 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
|
||||
// compute non-zeros in actuator_moment
|
||||
m->nJmom = nJmom = CountNJmom(m);
|
||||
|
||||
// compute non-zeros in ten_J
|
||||
m->nJten = nJten = CountNJten(m);
|
||||
|
||||
// scale mass
|
||||
if (compiler.settotalmass > 0) {
|
||||
mj_setTotalmass(m, compiler.settotalmass);
|
||||
|
||||
@@ -130,7 +130,6 @@ class mjCModel_ : public mjsElement {
|
||||
mjtSize nC; // number of non-zeros in reduced sparse dof-dof matrix
|
||||
mjtSize nD; // number of non-zeros in sparse dof-dof matrix
|
||||
mjtSize nJmom; // number of non-zeros in sparse actuator_moment matrix
|
||||
mjtSize nJten; // number of non-zeros in sparse ten_J matrix
|
||||
|
||||
// statistics, as computed by mj_setConst
|
||||
double meaninertia_auto; // mean diagonal inertia, as computed by mj_setConst
|
||||
@@ -369,7 +368,6 @@ class mjCModel : public mjCModel_, private mjSpec {
|
||||
void FinalizeSimple(mjModel* m); // finalize simple bodies/dofs including tendon information
|
||||
void CopyPlugins(mjModel*); // copy plugin data
|
||||
int CountNJmom(const mjModel* m); // compute number of non-zeros in actuator_moment matrix
|
||||
int CountNJten(const mjModel* m); // compute number of non-zeros in ten_J matrix
|
||||
|
||||
// remove plugins that are not referenced by any object
|
||||
void RemovePlugins();
|
||||
|
||||
Reference in New Issue
Block a user