[ODE] patch: Nguyen Binh's dSetZero() removal
Adam D. Moss
adam at gimp.org
Fri Oct 17 11:16:06 MST 2003
This patch isolates Nguyen's work that removes many
unnecessary dSetZero() calls (and a few other redundant
initializations). I've tested it briefly (only in StepFast
mode) and not seen anything unusual.
The patch is against ODE's CVS HEAD.
--Adam
--
Adam D. Moss . ,,^^ adam at gimp.org http://www.foxbox.org/ co:3
"i18n ought to be abbreviated i2n to make it quicker to write!"-snout
-------------- next part --------------
? ode/cheaders.patch
? ode/odeopsp.diff
? ode/include/ode/config.h
? ode/ode/doc/ode.html
Index: ode/ode/src/joint.cpp
===================================================================
RCS file: /cvsroot/opende/ode/ode/src/joint.cpp,v
retrieving revision 1.48
diff -u -r1.48 joint.cpp
--- ode/ode/src/joint.cpp 29 Jul 2003 14:00:05 -0000 1.48
+++ ode/ode/src/joint.cpp 17 Oct 2003 10:02:33 -0000
@@ -1161,11 +1161,13 @@
{
// default frictionless contact. hmmm, this info gets overwritten straight
// away anyway, so why bother?
+#if 0 /* so don't bother ;) */
j->contact.surface.mode = 0;
j->contact.surface.mu = 0;
dSetZero (j->contact.geom.pos,4);
dSetZero (j->contact.geom.normal,4);
j->contact.geom.depth = 0;
+#endif
}
Index: ode/ode/src/step.cpp
===================================================================
RCS file: /cvsroot/opende/ode/ode/src/step.cpp,v
retrieving revision 1.26
diff -u -r1.26 step.cpp
--- ode/ode/src/step.cpp 10 Nov 2002 23:20:36 -0000 1.26
+++ ode/ode/src/step.cpp 17 Oct 2003 10:02:35 -0000
@@ -329,8 +329,9 @@
// @@@ check computation of rotational force.
dReal *I = (dReal*) ALLOCA (3*nb*4 * sizeof(dReal));
dReal *invI = (dReal*) ALLOCA (3*nb*4 * sizeof(dReal));
- dSetZero (I,3*nb*4);
- dSetZero (invI,3*nb*4);
+
+ //dSetZero (I,3*nb*4);
+ //dSetZero (invI,3*nb*4);
for (i=0; i<nb; i++) {
dReal tmp[12];
// compute inertia tensor in global frame
@@ -414,8 +415,8 @@
// assemble some body vectors: fe = external forces, v = velocities
dReal *fe = (dReal*) ALLOCA (n6 * sizeof(dReal));
dReal *v = (dReal*) ALLOCA (n6 * sizeof(dReal));
- dSetZero (fe,n6);
- dSetZero (v,n6);
+ //dSetZero (fe,n6);
+ //dSetZero (v,n6);
for (i=0; i<nb; i++) {
for (j=0; j<3; j++) fe[i*6+j] = body[i]->facc[j];
for (j=0; j<3; j++) fe[i*6+3+j] = body[i]->tacc[j];
@@ -482,11 +483,11 @@
dTimerNow ("compute A");
# endif
dReal *JinvM = (dReal*) ALLOCA (m*nskip*sizeof(dReal));
- dSetZero (JinvM,m*nskip);
+ //dSetZero (JinvM,m*nskip);
dMultiply0 (JinvM,J,invM,m,n6,n6);
int mskip = dPAD(m);
dReal *A = (dReal*) ALLOCA (m*mskip*sizeof(dReal));
- dSetZero (A,m*mskip);
+ //dSetZero (A,m*mskip);
dMultiply2 (A,JinvM,J,m,n6,m);
// add cfm to the diagonal of A
@@ -501,11 +502,11 @@
dTimerNow ("compute rhs");
# endif
dReal *tmp1 = (dReal*) ALLOCA (n6 * sizeof(dReal));
- dSetZero (tmp1,n6);
+ //dSetZero (tmp1,n6);
dMultiply0 (tmp1,invM,fe,n6,n6,1);
for (i=0; i<n6; i++) tmp1[i] += v[i]/stepsize;
dReal *rhs = (dReal*) ALLOCA (m * sizeof(dReal));
- dSetZero (rhs,m);
+ //dSetZero (rhs,m);
dMultiply0 (rhs,J,tmp1,m,n6,1);
for (i=0; i<m; i++) rhs[i] = c[i]/stepsize - rhs[i];
@@ -640,8 +641,9 @@
// @@@ check computation of rotational force.
dReal *I = (dReal*) ALLOCA (3*nb*4 * sizeof(dReal));
dReal *invI = (dReal*) ALLOCA (3*nb*4 * sizeof(dReal));
- dSetZero (I,3*nb*4);
- dSetZero (invI,3*nb*4);
+
+ //dSetZero (I,3*nb*4);
+ //dSetZero (invI,3*nb*4);
for (i=0; i<nb; i++) {
dReal tmp[12];
// compute inertia tensor in global frame
@@ -885,7 +887,7 @@
dTimerNow ("compute rhs");
# endif
dReal *tmp1 = (dReal*) ALLOCA (nb*8 * sizeof(dReal));
- dSetZero (tmp1,nb*8);
+ //dSetZero (tmp1,nb*8);
// put v/h + invM*fe into tmp1
for (i=0; i<nb; i++) {
dReal body_invMass = body[i]->invMass;
@@ -897,7 +899,7 @@
}
// put J*tmp1 into rhs
dReal *rhs = (dReal*) ALLOCA (m * sizeof(dReal));
- dSetZero (rhs,m);
+ //dSetZero (rhs,m);
for (i=0; i<nj; i++) {
dReal *JJ = J + 2*8*ofs[i];
Multiply0_p81 (rhs+ofs[i],JJ,
Index: ode/ode/src/stepfast.cpp
===================================================================
RCS file: /cvsroot/opende/ode/ode/src/stepfast.cpp,v
retrieving revision 1.1
diff -u -r1.1 stepfast.cpp
--- ode/ode/src/stepfast.cpp 11 Jul 2003 04:36:58 -0000 1.1
+++ ode/ode/src/stepfast.cpp 17 Oct 2003 10:02:36 -0000
@@ -96,7 +96,7 @@
A += Askip + 1;
C += 8;
}
-
}
+}
static void
MultiplyAdd2_sym_p8p (dReal * A, dReal * B, dReal * C, int p, int Askip)
@@ -127,7 +127,7 @@
A += Askip + 1;
C += 8;
}
-
}
+}
// this assumes the 4th and 8th rows of B are zero.
@@ -352,7 +352,7 @@
dTimerNow ("compute A");
# endif
dReal JinvM[2 * 6 * 8];
- dSetZero (JinvM, 2 * m * 8);
+ //dSetZero (JinvM, 2 * m * 8);
dReal *Jsrc = Jinfo.J1l;
dReal *Jdst = JinvM;
@@ -385,7 +385,7 @@
// now compute A = JinvM * J'.
int mskip = dPAD (m);
dReal A[6 * 8];
- dSetZero (A, 6 * 8);
+ //dSetZero (A, 6 * 8);
if (body[0])
Multiply2_sym_p8p (A, JinvM, Jinfo.J1l, m, mskip);
@@ -401,7 +401,7 @@
dTimerNow ("compute rhs");
# endif
dReal tmp1[16];
- dSetZero (tmp1, 16);
+ //dSetZero (tmp1, 16);
// put v/h + invM*fe into tmp1
for (i = 0; i < 2; i++)
{
@@ -415,7 +415,7 @@
}
// put J*tmp1 into rhs
dReal rhs[6];
- dSetZero (rhs, 6);
+ //dSetZero (rhs, 6);
if (body[0])
Multiply0_p81 (rhs, Jinfo.J1l, tmp1, m);
@@ -582,7 +582,7 @@
// compute cforce = J'*lambda
dJointFeedback *fb = joint->feedback;
dReal cforce[16];
- dSetZero (cforce, 16);
+ //dSetZero (cforce, 16);
if (fb)
{
@@ -691,15 +691,25 @@
ofs[i] = m;
m += info[i].m;
}
+ dReal *c = NULL;
+ dReal *cfm = NULL;
+ dReal *lo = NULL;
+ dReal *hi = NULL;
+ int *findex = NULL;
+ dReal *J = NULL;
+ dxJoint::Info2 * Jinfo = NULL;
+
+ if (m)
+ {
// create a constraint equation right hand side vector `c', a constraint
// force mixing vector `cfm', and LCP low and high bound vectors, and an
// 'findex' vector.
- dReal *c = (dReal *) ALLOCA (m * sizeof (dReal));
- dReal *cfm = (dReal *) ALLOCA (m * sizeof (dReal));
- dReal *lo = (dReal *) ALLOCA (m * sizeof (dReal));
- dReal *hi = (dReal *) ALLOCA (m * sizeof (dReal));
- int *findex = (int *) ALLOCA (m * sizeof (int));
+ c = (dReal *) ALLOCA (m * sizeof (dReal));
+ cfm = (dReal *) ALLOCA (m * sizeof (dReal));
+ lo = (dReal *) ALLOCA (m * sizeof (dReal));
+ hi = (dReal *) ALLOCA (m * sizeof (dReal));
+ findex = (int *) ALLOCA (m * sizeof (int));
dSetZero (c, m);
dSetValue (cfm, m, world->global_cfm);
dSetValue (lo, m, -dInfinity);
@@ -727,9 +737,9 @@
# ifdef TIMING
dTimerNow ("create J");
# endif
- dReal *J = (dReal *) ALLOCA (2 * m * 8 * sizeof (dReal));
- dSetZero (J, 2 * m * 8);
- dxJoint::Info2 * Jinfo = (dxJoint::Info2 *) ALLOCA (nj * sizeof (dxJoint::Info2));
+ J = (dReal *) ALLOCA (2 * m * 8 * sizeof (dReal));
+ //dSetZero (J, 2 * m * 8);
+ Jinfo = (dxJoint::Info2 *) ALLOCA (nj * sizeof (dxJoint::Info2));
for (i = 0; i < nj; i++)
{
Jinfo[i].rowskip = 8;
@@ -747,6 +757,8 @@
//joints[i]->vtable->getInfo2 (joints[i], Jinfo+i);
}
+ }
+
dReal *saveFacc = (dReal *) ALLOCA (nb * 4 * sizeof (dReal));
dReal *saveTacc = (dReal *) ALLOCA (nb * 4 * sizeof (dReal));
dReal *globalI = (dReal *) ALLOCA (nb * 12 * sizeof (dReal));
@@ -857,8 +869,10 @@
//dInternalStepIslandFast is an exact copy of the old routine with one
//modification: the calculated forces are added back to the facc and tacc
//vectors instead of applying them to the bodies and moving them.
+ if (info[j].m > 0)
+ {
dInternalStepFast (world, bodyPair, GIPair, GinvIPair, joint, info[j], Jinfo[j], ministep);
-
+ }
}
// }
# ifdef TIMING
More information about the ODE
mailing list